diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp index 93660331e..998b87723 100644 --- a/Demos/AllBulletDemos/DemoEntries.cpp +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -18,12 +18,19 @@ subject to the following restrictions: #include "../CcdPhysicsDemo/CcdPhysicsDemo.h" #include "../BspDemo/BspDemo.h" #include "../BasicDemo/BasicDemo.h" +#include "../ConcaveDemo/ConcaveDemo.h" +#include "../ConvexDecompositionDemo/ConvexDecompositionDemo.h" +#include "../RagdollDemo/RagdollDemo.h" + btDemoEntry g_demoEntries[] = { + {"RagdollDemo",RagdollDemo::Create}, + {"ConvexDecomposition",ConvexDecompositionDemo::Create}, {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, {"BasicDemo", BasicDemo::Create}, {"BspDemo", BspDemo::Create}, + {"ConcaveDemo",ConcaveDemo::Create}, {0, 0} }; diff --git a/Demos/AllBulletDemos/Jamfile b/Demos/AllBulletDemos/Jamfile index 3019367f7..2b3600852 100644 --- a/Demos/AllBulletDemos/Jamfile +++ b/Demos/AllBulletDemos/Jamfile @@ -7,5 +7,7 @@ FrameWorkDemo AllBulletDemos : ../BspDemo/BspDemo.cpp ../BspDemo/BspConverter.cpp ../BspDemo/BspLoader.cpp - + ../ConcaveDemo/ConcavePhysicsDemo.cpp + ../ConvexDecompositionDemo/ConvexDecompositionDemo.cpp + ../RagdollDemo/RagdollDemo.cpp ; diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index 48c29444e..37a925504 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -22,7 +22,6 @@ #include "LinearMath/btScalar.h" #include "LinearMath/btMinMax.h" -#include "Render.h" #include "DemoApplication.h" #include "DemoEntries.h" @@ -57,8 +56,6 @@ void Resize(int w, int h) glLoadIdentity(); double ratio = (double)tw / (double)th; - gluOrtho2D(viewZoom * (viewX - ratio), viewZoom * (ratio + viewX), - viewZoom * (viewY - 0.1), viewZoom * (viewY + 1.9)); if (demo) demo->reshape(w, h); @@ -165,7 +162,7 @@ int main(int argc, char** argv) glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); + glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH); glutInitWindowSize(width, height); mainWindow = glutCreateWindow("http://bulletphysics.com"); //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); glutMotionFunc(MouseMotion); + glui = GLUI_Master.create_glui_subwindow( mainWindow, GLUI_SUBWINDOW_RIGHT ); diff --git a/Demos/AllBulletDemos/Render.cpp b/Demos/AllBulletDemos/Render.cpp deleted file mode 100644 index 95277dbd2..000000000 --- a/Demos/AllBulletDemos/Render.cpp +++ /dev/null @@ -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 -#include -#include -#else -#include -#endif - -#include -#include -#include - -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); -} - diff --git a/Demos/AllBulletDemos/Render.h b/Demos/AllBulletDemos/Render.h deleted file mode 100644 index d2bcd8f06..000000000 --- a/Demos/AllBulletDemos/Render.h +++ /dev/null @@ -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 diff --git a/Demos/BasicDemo/BasicDemo.cpp b/Demos/BasicDemo/BasicDemo.cpp index 8aaa7b6e8..1e33be9e9 100644 --- a/Demos/BasicDemo/BasicDemo.cpp +++ b/Demos/BasicDemo/BasicDemo.cpp @@ -54,7 +54,6 @@ btScalar deltaTime = btScalar(1./60.); //////////////////////////////////// -GLDebugDrawer debugDrawer; class myTest { @@ -178,7 +177,6 @@ void BasicDemo::initPhysics() m_dynamicsWorld->setGravity(btVector3(0,-10,0)); - m_dynamicsWorld->setDebugDrawer(&debugDrawer); ///create a few basic rigid bodies diff --git a/Demos/ConcaveDemo/ConcaveDemo.h b/Demos/ConcaveDemo/ConcaveDemo.h index f46388503..32faa4731 100644 --- a/Demos/ConcaveDemo/ConcaveDemo.h +++ b/Demos/ConcaveDemo/ConcaveDemo.h @@ -40,6 +40,14 @@ class ConcaveDemo : public DemoApplication void setVertexPositions(float waveheight, float offset); 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 diff --git a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp index 2c0cb3168..e83c63c98 100644 --- a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp @@ -29,8 +29,6 @@ subject to the following restrictions: -GLDebugDrawer debugDrawer; -class btIDebugDraw* debugDrawerPtr=0; btVector3* gVertices=0; int* gIndices=0; @@ -97,20 +95,6 @@ bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject 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_Y = 30; const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y; @@ -156,6 +140,9 @@ void ConcaveDemo::initPhysics() { #define TRISIZE 10.f + gContactAddedCallback = CustomMaterialCombinerCallback; + + int vertStride = sizeof(btVector3); int indexStride = 3*sizeof(int); @@ -274,8 +261,6 @@ btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollision #ifdef USE_PARALLEL_DISPATCHER m_dynamicsWorld->getDispatchInfo().m_enableSPU=true; #endif //USE_PARALLEL_DISPATCHER - m_dynamicsWorld->setDebugDrawer(&debugDrawer); - debugDrawerPtr = &debugDrawer; float mass = 0.f; btTransform startTransform; diff --git a/Demos/ConcaveDemo/main.cpp b/Demos/ConcaveDemo/main.cpp new file mode 100644 index 000000000..2c72b3bf1 --- /dev/null +++ b/Demos/ConcaveDemo/main.cpp @@ -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); +} + diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index 19458e753..8caead641 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -39,7 +39,6 @@ subject to the following restrictions: #include //printf debugging #include -float deltaTime = 1.f/60.f; #include "ConvexDecompositionDemo.h" #include "GL_ShapeDrawer.h" @@ -48,13 +47,13 @@ float deltaTime = 1.f/60.f; const int maxNumObjects = 450; -int shapeIndex[maxNumObjects]; +static int shapeIndex[maxNumObjects]; btVector3 centroid; #define CUBE_HALF_EXTENTS 4 -btCollisionShape* shapePtr[maxNumObjects]; +static btCollisionShape* shapePtr[maxNumObjects]; @@ -65,24 +64,6 @@ unsigned int tcount = 0; 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) { ConvexDecomposition::WavefrontObj wo; diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.h b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.h index 469e93559..f1bcf3969 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.h +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.h @@ -27,7 +27,14 @@ class ConvexDecompositionDemo : public DemoApplication virtual void clientMoveAndDisplay(); virtual void displayCallback(); - + + static DemoApplication* Create() + { + ConvexDecompositionDemo* demo = new ConvexDecompositionDemo(); + demo->myinit(); + demo->initPhysics("file.obj"); + return demo; + } }; diff --git a/Demos/ConvexDecompositionDemo/main.cpp b/Demos/ConvexDecompositionDemo/main.cpp new file mode 100644 index 000000000..ba7855d3e --- /dev/null +++ b/Demos/ConvexDecompositionDemo/main.cpp @@ -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); +} + diff --git a/Demos/Jamfile b/Demos/Jamfile index 41199429c..1161ff5f5 100644 --- a/Demos/Jamfile +++ b/Demos/Jamfile @@ -35,15 +35,17 @@ if $(GLUT.AVAILABLE) = "yes" rule FrameWorkDemo { Application $(<) : $(>) : noinstall console nomanifest ; - LinkWith $(<) : bulletopenglsupport bulletdynamics bulletcollision bulletmath glui ; + LinkWith $(<) : bulletopenglsupport convexdecomposition bulletdynamics bulletcollision bulletmath glui ; CFlags $(<) : [ FIncludes $(TOP)/Extras ] [ FIncludes $(TOP)/Demos/OpenGL ] + [ FIncludes $(TOP)/Extras/ConvexDecomposition ] ; MsvcIncDirs $(<) : "../../Extras" "../../src" "../../Demos/OpenGL" + "../../Extras/ConvexDecomposition" ; } diff --git a/Demos/RagdollDemo/RagdollDemo.cpp b/Demos/RagdollDemo/RagdollDemo.cpp index 295f06172..91dcbbf15 100644 --- a/Demos/RagdollDemo/RagdollDemo.cpp +++ b/Demos/RagdollDemo/RagdollDemo.cpp @@ -26,7 +26,6 @@ Written by: Marten Svanfeldt #include "GLDebugDrawer.h" #include "RagdollDemo.h" -GLDebugDrawer debugDrawer; // 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() { @@ -330,7 +319,6 @@ void RagdollDemo::initPhysics() m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration); - m_dynamicsWorld->setDebugDrawer(&debugDrawer); // Setup a big ground box { diff --git a/Demos/RagdollDemo/RagdollDemo.h b/Demos/RagdollDemo/RagdollDemo.h index dfc305967..becd87427 100644 --- a/Demos/RagdollDemo/RagdollDemo.h +++ b/Demos/RagdollDemo/RagdollDemo.h @@ -37,6 +37,15 @@ public: virtual void displayCallback(); virtual void keyboardCallback(unsigned char key, int x, int y); + + static DemoApplication* Create() + { + RagdollDemo* demo = new RagdollDemo(); + demo->myinit(); + demo->initPhysics(); + return demo; + } + }; diff --git a/Demos/RagdollDemo/main.cpp b/Demos/RagdollDemo/main.cpp new file mode 100644 index 000000000..1897939dc --- /dev/null +++ b/Demos/RagdollDemo/main.cpp @@ -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); +}