first step in refactoring/cleaning up demos

This commit is contained in:
ejcoumans
2006-09-11 05:31:22 +00:00
parent a27c35ecaa
commit 43370aaa4f
33 changed files with 2449 additions and 7548 deletions

View 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 CONTINUOUS_CONVEX_COLLISION_DEMO_H
#define CONTINUOUS_CONVEX_COLLISION_DEMO_H
#include "DemoApplication.h"
///ContinuousConvexCollisionDemo shows the working of the continuous collision detection, including linear and angular motion
class ContinuousConvexCollisionDemo : public DemoApplication
{
public:
void initPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
virtual void clientResetScene()
{
}
};
#endif //CONTINUOUS_CONVEX_COLLISION_DEMO_H

View File

@@ -36,19 +36,11 @@
#include "CollisionShapes/Simplex1to4Shape.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 "NarrowPhaseCollision/VoronoiSimplexSolver.h"
#include "NarrowPhaseCollision/ConvexPenetrationDepthSolver.h"
#include "GL_ShapeDrawer.h"
#include "ContinuousConvexCollision.h"
#include "GlutStuff.h"
@@ -65,21 +57,24 @@ PolyhedralConvexShape* shapePtr[maxNumObjects];
SimdTransform fromTrans[maxNumObjects];
SimdTransform toTrans[maxNumObjects];
//SimdTransform tr[numObjects];
void DrawRasterizerLine(float const* , float const*, int)
{
}
int screenWidth = 640.f;
int screenHeight = 480.f;
int main(int argc,char** argv)
{
ContinuousConvexCollisionDemo* ccdDemo = new ContinuousConvexCollisionDemo();
setCameraDistance(40.f);
ccdDemo->setCameraDistance(40.f);
ccdDemo->initPhysics();
return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo",ccdDemo);
}
void ContinuousConvexCollisionDemo::initPhysics()
{
fromTrans[0].setOrigin(SimdVector3(0,10,20));
toTrans[0].setOrigin(SimdVector3(0,10,-20));
fromTrans[1].setOrigin(SimdVector3(-2,7,0));
@@ -101,17 +96,17 @@ int main(int argc,char** argv)
toTrans[1].setBasis(identBasis);
SimdVector3 boxHalfExtentsA(10,1,1);
SimdVector3 boxHalfExtentsB(1.1f,1.1f,1.1f);
BoxShape boxA(boxHalfExtentsA);
// BU_Simplex1to4 boxA(SimdPoint3(-2,0,-2),SimdPoint3(2,0,-2),SimdPoint3(0,0,2),SimdPoint3(0,2,0));
// BU_Simplex1to4 boxA(SimdPoint3(-12,0,0),SimdPoint3(12,0,0));
BoxShape* boxA = new BoxShape(boxHalfExtentsA);
// BU_Simplex1to4* boxA = new BU_Simplex1to4(SimdPoint3(-2,0,-2),SimdPoint3(2,0,-2),SimdPoint3(0,0,2),SimdPoint3(0,2,0));
// BU_Simplex1to4* boxA = new BU_Simplex1to4(SimdPoint3(-12,0,0),SimdPoint3(12,0,0));
BoxShape boxB(boxHalfExtentsB);
BoxShape* boxB = new BoxShape(boxHalfExtentsB);
// BU_Simplex1to4 boxB(SimdPoint3(0,10,0),SimdPoint3(0,-10,0));
shapePtr[0] = &boxA;
shapePtr[1] = &boxB;
shapePtr[0] = boxA;
shapePtr[1] = boxB;
shapePtr[0]->SetMargin(0.01f);
shapePtr[1]->SetMargin(0.01f);
@@ -121,18 +116,15 @@ int main(int argc,char** argv)
SimdTransformUtil::CalculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
}
return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo");
}
//to be implemented by the demo
void clientMoveAndDisplay()
void ContinuousConvexCollisionDemo::clientMoveAndDisplay()
{
clientDisplay();
displayCallback();
}
#include "NarrowPhaseCollision/VoronoiSimplexSolver.h"
#include "NarrowPhaseCollision/ConvexPenetrationDepthSolver.h"
static VoronoiSimplexSolver sVoronoiSimplexSolver;
@@ -145,7 +137,7 @@ int minlines = 0;
int maxlines = 512;
void clientDisplay(void) {
void ContinuousConvexCollisionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
@@ -206,12 +198,10 @@ void clientDisplay(void) {
fromTrans[1].setRotation(orn);
toTrans[1].setRotation(orn);
extern bool stepping;
extern bool singleStep;
if (stepping || singleStep)
if (m_stepping || m_singleStep)
{
singleStep = false;
m_singleStep = false;
pitch += 0.005f;
// yaw += 0.01f;
}
@@ -299,26 +289,4 @@ void clientDisplay(void) {
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)
{
}