first step in refactoring/cleaning up demos
This commit is contained in:
@@ -30,19 +30,10 @@ subject to the following restrictions:
|
||||
#include "NarrowPhaseCollision/VoronoiSimplexSolver.h"
|
||||
#include "NarrowPhaseCollision/ConvexPenetrationDepthSolver.h"
|
||||
|
||||
#include "CollisionDemo.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#ifdef WIN32 //needed for glut.h
|
||||
#include <windows.h>
|
||||
#endif
|
||||
//think different
|
||||
#if defined(__APPLE__) && !defined (VMDMESA)
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#include "GlutStuff.h"
|
||||
#include "IDebugDraw.h"
|
||||
|
||||
|
||||
float yaw=0.f,pitch=0.f,roll=0.f;
|
||||
@@ -64,7 +55,22 @@ void DrawRasterizerLine(float const* , float const*, int)
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
setCameraDistance(20.f);
|
||||
CollisionDemo* colDemo = new CollisionDemo();
|
||||
|
||||
colDemo->setCameraDistance(18.f);
|
||||
|
||||
colDemo->initPhysics();
|
||||
|
||||
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Collision Demo",colDemo);
|
||||
}
|
||||
|
||||
void CollisionDemo::initPhysics()
|
||||
{
|
||||
m_debugMode |= IDebugDraw::DBG_DrawWireframe;
|
||||
m_azi = 250.f;
|
||||
m_ele = 25.f;
|
||||
|
||||
tr[0].setOrigin(SimdVector3(0.0013328250f,8.1363249f,7.0390840f));
|
||||
tr[1].setOrigin(SimdVector3(0.00000000f,9.1262732f,2.0343180f));
|
||||
@@ -90,25 +96,17 @@ int main(int argc,char** argv)
|
||||
SimdVector3 boxHalfExtentsA(1.0000004768371582f,1.0000004768371582f,1.0000001192092896f);
|
||||
SimdVector3 boxHalfExtentsB(3.2836332321166992f,3.2836332321166992f,3.2836320400238037f);
|
||||
|
||||
BoxShape boxA(boxHalfExtentsA);
|
||||
BoxShape boxB(boxHalfExtentsB);
|
||||
shapePtr[0] = &boxA;
|
||||
shapePtr[1] = &boxB;
|
||||
|
||||
BoxShape* boxA = new BoxShape(boxHalfExtentsA);
|
||||
BoxShape* boxB = new BoxShape(boxHalfExtentsB);
|
||||
shapePtr[0] = boxA;
|
||||
shapePtr[1] = boxB;
|
||||
|
||||
SimdTransform tr;
|
||||
tr.setIdentity();
|
||||
|
||||
|
||||
return glutmain(argc, argv,screenWidth,screenHeight,"Collision Demo");
|
||||
}
|
||||
|
||||
//to be implemented by the demo
|
||||
|
||||
void clientMoveAndDisplay()
|
||||
void CollisionDemo::clientMoveAndDisplay()
|
||||
{
|
||||
|
||||
clientDisplay();
|
||||
displayCallback();
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +115,7 @@ SimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver;
|
||||
|
||||
|
||||
|
||||
void clientDisplay(void) {
|
||||
void CollisionDemo::displayCallback(void) {
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
@@ -182,37 +180,10 @@ void clientDisplay(void) {
|
||||
orn.setEuler(yaw,pitch,roll);
|
||||
tr[0].setRotation(orn);
|
||||
|
||||
// pitch += 0.005f;
|
||||
// yaw += 0.01f;
|
||||
pitch += 0.005f;
|
||||
yaw += 0.01f;
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void clientResetScene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void clientSpecialKeyboard(int key, int x, int y)
|
||||
{
|
||||
defaultSpecialKeyboard(key,x,y);
|
||||
}
|
||||
|
||||
void clientKeyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
defaultKeyboard(key, x, y);
|
||||
}
|
||||
|
||||
|
||||
void clientMouseFunc(int button, int state, int x, int y)
|
||||
{
|
||||
|
||||
}
|
||||
void clientMotionFunc(int x,int y)
|
||||
{
|
||||
}
|
||||
|
||||
36
Demos/CollisionDemo/CollisionDemo.h
Normal file
36
Demos/CollisionDemo/CollisionDemo.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#ifndef COLLISION_DEMO_H
|
||||
#define COLLISION_DEMO_H
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
///CollisionDemo shows the low-level direct access to GJK
|
||||
class CollisionDemo : public DemoApplication
|
||||
{
|
||||
public:
|
||||
|
||||
void initPhysics();
|
||||
|
||||
virtual void clientMoveAndDisplay();
|
||||
|
||||
virtual void displayCallback();
|
||||
|
||||
virtual void clientResetScene()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif //COLLISION_DEMO_H
|
||||
Reference in New Issue
Block a user