updated AllBulletDemo

This commit is contained in:
ejcoumans
2007-10-23 05:46:16 +00:00
parent aa28f8c223
commit ce0ce3b135
16 changed files with 97 additions and 159 deletions

View File

@@ -18,12 +18,19 @@ subject to the following restrictions:
#include "../CcdPhysicsDemo/CcdPhysicsDemo.h" #include "../CcdPhysicsDemo/CcdPhysicsDemo.h"
#include "../BspDemo/BspDemo.h" #include "../BspDemo/BspDemo.h"
#include "../BasicDemo/BasicDemo.h" #include "../BasicDemo/BasicDemo.h"
#include "../ConcaveDemo/ConcaveDemo.h"
#include "../ConvexDecompositionDemo/ConvexDecompositionDemo.h"
#include "../RagdollDemo/RagdollDemo.h"
btDemoEntry g_demoEntries[] = btDemoEntry g_demoEntries[] =
{ {
{"RagdollDemo",RagdollDemo::Create},
{"ConvexDecomposition",ConvexDecompositionDemo::Create},
{"CcdPhysicsDemo", CcdPhysicsDemo::Create}, {"CcdPhysicsDemo", CcdPhysicsDemo::Create},
{"BasicDemo", BasicDemo::Create}, {"BasicDemo", BasicDemo::Create},
{"BspDemo", BspDemo::Create}, {"BspDemo", BspDemo::Create},
{"ConcaveDemo",ConcaveDemo::Create},
{0, 0} {0, 0}
}; };

View File

@@ -7,5 +7,7 @@ FrameWorkDemo AllBulletDemos :
../BspDemo/BspDemo.cpp ../BspDemo/BspDemo.cpp
../BspDemo/BspConverter.cpp ../BspDemo/BspConverter.cpp
../BspDemo/BspLoader.cpp ../BspDemo/BspLoader.cpp
../ConcaveDemo/ConcavePhysicsDemo.cpp
../ConvexDecompositionDemo/ConvexDecompositionDemo.cpp
../RagdollDemo/RagdollDemo.cpp
; ;

View File

@@ -22,7 +22,6 @@
#include "LinearMath/btScalar.h" #include "LinearMath/btScalar.h"
#include "LinearMath/btMinMax.h" #include "LinearMath/btMinMax.h"
#include "Render.h"
#include "DemoApplication.h" #include "DemoApplication.h"
#include "DemoEntries.h" #include "DemoEntries.h"
@@ -57,8 +56,6 @@ void Resize(int w, int h)
glLoadIdentity(); glLoadIdentity();
double ratio = (double)tw / (double)th; double ratio = (double)tw / (double)th;
gluOrtho2D(viewZoom * (viewX - ratio), viewZoom * (ratio + viewX),
viewZoom * (viewY - 0.1), viewZoom * (viewY + 1.9));
if (demo) if (demo)
demo->reshape(w, h); demo->reshape(w, h);
@@ -165,7 +162,7 @@ int main(int argc, char** argv)
glutInit(&argc, argv); glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH);
glutInitWindowSize(width, height); glutInitWindowSize(width, height);
mainWindow = glutCreateWindow("http://bulletphysics.com"); mainWindow = glutCreateWindow("http://bulletphysics.com");
//glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); //glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
@@ -180,6 +177,7 @@ int main(int argc, char** argv)
GLUI_Master.set_glutMouseFunc(Mouse); GLUI_Master.set_glutMouseFunc(Mouse);
glutMotionFunc(MouseMotion); glutMotionFunc(MouseMotion);
glui = GLUI_Master.create_glui_subwindow( mainWindow, glui = GLUI_Master.create_glui_subwindow( mainWindow,
GLUI_SUBWINDOW_RIGHT ); GLUI_SUBWINDOW_RIGHT );

View File

@@ -1,67 +0,0 @@
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* 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.
*/
#include "Render.h"
//#include "freeglut/gl/glut.h"
//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 <stdio.h>
#include <stdarg.h>
#include <string.h>
void DrawString(int x, int y, const char *string, ...)
{
char buffer[128];
va_list arg;
va_start(arg, string);
vsprintf(buffer, string, arg);
va_end(arg);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
gluOrtho2D(0, w, h, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glColor3f(0.9f, 0.6f, 0.6f);
glRasterPos2i(x, y);
int length = (int)strlen(buffer);
for (int i = 0; i < length; ++i)
{
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, buffer[i]);
}
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}

View File

@@ -1,32 +0,0 @@
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* 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 RENDER_H
#define RENDER_H
#include "LinearMath/btScalar.h"
struct Color
{
Color() { cx = 1.0f; cy = 1.0f; cz = 1.0f; }
Color(float x, float y, float z) { cx = x; cy = y; cz = z; }
float cx, cy, cz;
};
#endif

View File

@@ -54,7 +54,6 @@ btScalar deltaTime = btScalar(1./60.);
//////////////////////////////////// ////////////////////////////////////
GLDebugDrawer debugDrawer;
class myTest class myTest
{ {
@@ -178,7 +177,6 @@ void BasicDemo::initPhysics()
m_dynamicsWorld->setGravity(btVector3(0,-10,0)); m_dynamicsWorld->setGravity(btVector3(0,-10,0));
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
///create a few basic rigid bodies ///create a few basic rigid bodies

View File

@@ -40,6 +40,14 @@ class ConcaveDemo : public DemoApplication
void setVertexPositions(float waveheight, float offset); void setVertexPositions(float waveheight, float offset);
virtual void keyboardCallback(unsigned char key, int x, int y); virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
ConcaveDemo* demo = new ConcaveDemo();
demo->myinit();
demo->initPhysics();
return demo;
};
}; };
#endif //CONCAVE_DEMO_H #endif //CONCAVE_DEMO_H

View File

@@ -29,8 +29,6 @@ subject to the following restrictions:
GLDebugDrawer debugDrawer;
class btIDebugDraw* debugDrawerPtr=0;
btVector3* gVertices=0; btVector3* gVertices=0;
int* gIndices=0; int* gIndices=0;
@@ -97,20 +95,6 @@ bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject
extern ContactAddedCallback gContactAddedCallback; extern ContactAddedCallback gContactAddedCallback;
int main(int argc,char** argv)
{
gContactAddedCallback = CustomMaterialCombinerCallback;
ConcaveDemo* concaveDemo = new ConcaveDemo();
concaveDemo->initPhysics();
concaveDemo->setCameraDistance(30.f);
return glutmain(argc, argv,640,480,"Static Concave Mesh Demo",concaveDemo);
}
const int NUM_VERTS_X = 30; const int NUM_VERTS_X = 30;
const int NUM_VERTS_Y = 30; const int NUM_VERTS_Y = 30;
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y; const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
@@ -156,6 +140,9 @@ void ConcaveDemo::initPhysics()
{ {
#define TRISIZE 10.f #define TRISIZE 10.f
gContactAddedCallback = CustomMaterialCombinerCallback;
int vertStride = sizeof(btVector3); int vertStride = sizeof(btVector3);
int indexStride = 3*sizeof(int); int indexStride = 3*sizeof(int);
@@ -274,8 +261,6 @@ btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollision
#ifdef USE_PARALLEL_DISPATCHER #ifdef USE_PARALLEL_DISPATCHER
m_dynamicsWorld->getDispatchInfo().m_enableSPU=true; m_dynamicsWorld->getDispatchInfo().m_enableSPU=true;
#endif //USE_PARALLEL_DISPATCHER #endif //USE_PARALLEL_DISPATCHER
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
debugDrawerPtr = &debugDrawer;
float mass = 0.f; float mass = 0.f;
btTransform startTransform; btTransform startTransform;

View File

@@ -0,0 +1,15 @@
#include "ConcaveDemo.h"
#include "GlutStuff.h"
int main(int argc,char** argv)
{
ConcaveDemo* concaveDemo = new ConcaveDemo();
concaveDemo->initPhysics();
concaveDemo->setCameraDistance(30.f);
return glutmain(argc, argv,640,480,"Static Concave Mesh Demo",concaveDemo);
}

View File

@@ -39,7 +39,6 @@ subject to the following restrictions:
#include <stdio.h> //printf debugging #include <stdio.h> //printf debugging
#include <vector> #include <vector>
float deltaTime = 1.f/60.f;
#include "ConvexDecompositionDemo.h" #include "ConvexDecompositionDemo.h"
#include "GL_ShapeDrawer.h" #include "GL_ShapeDrawer.h"
@@ -48,13 +47,13 @@ float deltaTime = 1.f/60.f;
const int maxNumObjects = 450; const int maxNumObjects = 450;
int shapeIndex[maxNumObjects]; static int shapeIndex[maxNumObjects];
btVector3 centroid; btVector3 centroid;
#define CUBE_HALF_EXTENTS 4 #define CUBE_HALF_EXTENTS 4
btCollisionShape* shapePtr[maxNumObjects]; static btCollisionShape* shapePtr[maxNumObjects];
@@ -65,24 +64,6 @@ unsigned int tcount = 0;
GLDebugDrawer debugDrawer; GLDebugDrawer debugDrawer;
int main(int argc,char** argv)
{
const char* filename = "file.obj";
ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo();
convexDecompDemo->initPhysics(filename);
convexDecompDemo->clientResetScene();
convexDecompDemo->setCameraDistance(26.f);
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",convexDecompDemo);
}
void ConvexDecompositionDemo::initPhysics(const char* filename) void ConvexDecompositionDemo::initPhysics(const char* filename)
{ {
ConvexDecomposition::WavefrontObj wo; ConvexDecomposition::WavefrontObj wo;

View File

@@ -27,7 +27,14 @@ class ConvexDecompositionDemo : public DemoApplication
virtual void clientMoveAndDisplay(); virtual void clientMoveAndDisplay();
virtual void displayCallback(); virtual void displayCallback();
static DemoApplication* Create()
{
ConvexDecompositionDemo* demo = new ConvexDecompositionDemo();
demo->myinit();
demo->initPhysics("file.obj");
return demo;
}
}; };

View File

@@ -0,0 +1,24 @@
#include "ConvexDecompositionDemo.h"
#include "GlutStuff.h"
int main(int argc,char** argv)
{
const char* filename = "file.obj";
ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo();
convexDecompDemo->initPhysics(filename);
convexDecompDemo->clientResetScene();
convexDecompDemo->setCameraDistance(26.f);
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",convexDecompDemo);
}

View File

@@ -35,15 +35,17 @@ if $(GLUT.AVAILABLE) = "yes"
rule FrameWorkDemo rule FrameWorkDemo
{ {
Application $(<) : $(>) : noinstall console nomanifest ; Application $(<) : $(>) : noinstall console nomanifest ;
LinkWith $(<) : bulletopenglsupport bulletdynamics bulletcollision bulletmath glui ; LinkWith $(<) : bulletopenglsupport convexdecomposition bulletdynamics bulletcollision bulletmath glui ;
CFlags $(<) : CFlags $(<) :
[ FIncludes $(TOP)/Extras ] [ FIncludes $(TOP)/Extras ]
[ FIncludes $(TOP)/Demos/OpenGL ] [ FIncludes $(TOP)/Demos/OpenGL ]
[ FIncludes $(TOP)/Extras/ConvexDecomposition ]
; ;
MsvcIncDirs $(<) : MsvcIncDirs $(<) :
"../../Extras" "../../Extras"
"../../src" "../../src"
"../../Demos/OpenGL" "../../Demos/OpenGL"
"../../Extras/ConvexDecomposition"
; ;
} }

View File

@@ -26,7 +26,6 @@ Written by: Marten Svanfeldt
#include "GLDebugDrawer.h" #include "GLDebugDrawer.h"
#include "RagdollDemo.h" #include "RagdollDemo.h"
GLDebugDrawer debugDrawer;
// Enrico: Shouldn't these three variables be real constants and not defines? // Enrico: Shouldn't these three variables be real constants and not defines?
@@ -303,16 +302,6 @@ public:
int main(int argc,char* argv[])
{
RagdollDemo demoApp;
demoApp.initPhysics();
demoApp.setCameraDistance(btScalar(10.));
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&demoApp);
}
void RagdollDemo::initPhysics() void RagdollDemo::initPhysics()
{ {
@@ -330,7 +319,6 @@ void RagdollDemo::initPhysics()
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration); m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
// Setup a big ground box // Setup a big ground box
{ {

View File

@@ -37,6 +37,15 @@ public:
virtual void displayCallback(); virtual void displayCallback();
virtual void keyboardCallback(unsigned char key, int x, int y); virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
RagdollDemo* demo = new RagdollDemo();
demo->myinit();
demo->initPhysics();
return demo;
}
}; };

View File

@@ -0,0 +1,13 @@
#include "RagdollDemo.h"
#include "GlutStuff.h"
int main(int argc,char* argv[])
{
RagdollDemo demoApp;
demoApp.initPhysics();
demoApp.setCameraDistance(btScalar(10.));
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",&demoApp);
}