From aa28f8c2230705e119eb4a19aeab5222dc52fdfa Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Tue, 23 Oct 2007 02:22:18 +0000 Subject: [PATCH] Updated allbulletdemos glui framework, to work better with DemoApplication. --- Demos/AllBulletDemos/DemoEntries.cpp | 29 +++ Demos/AllBulletDemos/DemoEntries.h | 34 +++ Demos/AllBulletDemos/Main.cpp | 139 +++------- Demos/AllBulletDemos/Test.cpp | 331 ------------------------ Demos/AllBulletDemos/Test.h | 89 ------- Demos/AllBulletDemos/TestEntries.cpp | 63 ----- Demos/BasicDemo/BasicDemo.h | 8 + Demos/BspDemo/BspDemo.h | 8 +- Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp | 2 +- Demos/CcdPhysicsDemo/CcdPhysicsDemo.h | 8 + 10 files changed, 129 insertions(+), 582 deletions(-) create mode 100644 Demos/AllBulletDemos/DemoEntries.cpp create mode 100644 Demos/AllBulletDemos/DemoEntries.h delete mode 100644 Demos/AllBulletDemos/Test.cpp delete mode 100644 Demos/AllBulletDemos/Test.h delete mode 100644 Demos/AllBulletDemos/TestEntries.cpp diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp new file mode 100644 index 000000000..93660331e --- /dev/null +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -0,0 +1,29 @@ +/* +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. +*/ + +#include "DemoEntries.h" + +#include "../CcdPhysicsDemo/CcdPhysicsDemo.h" +#include "../BspDemo/BspDemo.h" +#include "../BasicDemo/BasicDemo.h" + +btDemoEntry g_demoEntries[] = +{ + {"CcdPhysicsDemo", CcdPhysicsDemo::Create}, + {"BasicDemo", BasicDemo::Create}, + {"BspDemo", BspDemo::Create}, + {0, 0} +}; + diff --git a/Demos/AllBulletDemos/DemoEntries.h b/Demos/AllBulletDemos/DemoEntries.h new file mode 100644 index 000000000..030754624 --- /dev/null +++ b/Demos/AllBulletDemos/DemoEntries.h @@ -0,0 +1,34 @@ +/* +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 BT_DEMO_ENTRIES_H +#define BT_DEMO_ENTRIES_H + + +class DemoApplication; + +typedef DemoApplication* DemoCreateFcn(); + +struct btDemoEntry +{ + const char *name; + DemoCreateFcn *createFcn; +}; + +extern btDemoEntry g_demoEntries[]; + + + +#endif //BT_DEMO_ENTRIES_H \ No newline at end of file diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index 31bf5e246..48c29444e 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -23,20 +23,22 @@ #include "LinearMath/btMinMax.h" #include "Render.h" -#include "Test.h" +#include "DemoApplication.h" +#include "DemoEntries.h" namespace { int testIndex = 0; int testSelection = 0; - TestEntry* entry; - Test* test; - Settings settings; + btDemoEntry* entry; + DemoApplication* demo; + int iterationCount = 10; int width = 640; int height = 480; int framePeriod = 16; int mainWindow; GLUI *glui; + float hz; float viewZoom = 20.0f; float viewX = 0.0f; float viewY = 0.0f; @@ -57,6 +59,9 @@ void Resize(int w, int h) gluOrtho2D(viewZoom * (viewX - ratio), viewZoom * (ratio + viewX), viewZoom * (viewY - 0.1), viewZoom * (viewY + 1.9)); + + if (demo) + demo->reshape(w, h); } /*b2Vec2 ConvertScreenToWorld(int x, int y) @@ -87,8 +92,10 @@ void SimulationLoop() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - test->SetTextLine(30); - test->Step(&settings); + //test->SetTextLine(30); + //test->Step(&settings); + demo->clientMoveAndDisplay(); + /// DrawString(5, 15, entry->name); @@ -97,9 +104,9 @@ void SimulationLoop() if (testSelection != testIndex) { testIndex = testSelection; - delete test; - entry = g_testEntries + testIndex; - test = entry->createFcn(); + delete demo; + entry = g_demoEntries + testIndex; + demo = entry->createFcn(); viewZoom = 20.0f; viewX = 0.0f; viewY = 0.0f; @@ -116,40 +123,17 @@ void Keyboard(unsigned char key, int x, int y) exit(0); break; - // Press 'a' to zoom in. - case 'a': - viewZoom = btMax(viewZoom - 1.0f, 1.0f); - Resize(width, height); - break; - - // Press 'z' to zoom out. - case 'z': - viewZoom = btMin(viewZoom + 1.0f, 100.0f); - Resize(width, height); - break; - // Press 'r' to reset. case 'r': - delete test; - test = entry->createFcn(); - break; - - // Press space to launch a bomb. - case ' ': - if (test) - { - test->LaunchBomb(); - } - break; - - case 'h': - settings.pause = !settings.pause; + delete demo; + demo = entry->createFcn(); + Resize(width,height); break; default: - if (test) + if (demo) { - test->Keyboard(key); + demo->keyboardCallback(key,x,y); } } } @@ -157,70 +141,28 @@ void Keyboard(unsigned char key, int x, int y) void KeyboardSpecial(int key, int x, int y) { - switch (key) + if (demo) { - // Press left to pan left. - case GLUT_KEY_LEFT: - viewX += 0.1f; - Resize(width, height); - break; - - // Press right to pan right. - case GLUT_KEY_RIGHT: - viewX -= 0.1f; - Resize(width, height); - break; - - // Press down to pan down. - case GLUT_KEY_DOWN: - viewY += 0.1f; - Resize(width, height); - break; - - // Press up to pan up. - case GLUT_KEY_UP: - viewY -= 0.1f; - Resize(width, height); - break; - - // Press home to reset the view. - case GLUT_KEY_HOME: - viewZoom = 20.0f; - viewX = 0.0f; - viewY = 0.0f; - Resize(width, height); - break; + demo->specialKeyboard(key,x,y); } + } + void Mouse(int button, int state, int x, int y) { - // Use the mouse to move things around. - if (button == GLUT_LEFT_BUTTON) - { - if (state == GLUT_DOWN) - { - // b2Vec2 p = ConvertScreenToWorld(x, y); - // test->MouseDown(p); - } - - if (state == GLUT_UP) - { - test->MouseUp(); - } - } + if (demo) + demo->mouseFunc(button,state,x,y); } void MouseMotion(int x, int y) { -// b2Vec2 p = ConvertScreenToWorld(x, y); -// test->MouseMove(p); + demo->mouseMotionFunc(x,y); } int main(int argc, char** argv) { - entry = g_testEntries + testIndex; - test = entry->createFcn(); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); @@ -228,6 +170,9 @@ int main(int argc, char** argv) mainWindow = glutCreateWindow("http://bulletphysics.com"); //glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); + entry = g_demoEntries + testIndex; + demo = entry->createFcn(); + glutDisplayFunc(SimulationLoop); GLUI_Master.set_glutReshapeFunc(Resize); GLUI_Master.set_glutKeyboardFunc(Keyboard); @@ -245,27 +190,27 @@ int main(int argc, char** argv) glui->add_separator(); GLUI_Spinner* iterationSpinner = - glui->add_spinner("Iterations", GLUI_SPINNER_INT, &settings.iterationCount); + glui->add_spinner("Iterations", GLUI_SPINNER_INT, &iterationCount); iterationSpinner->set_int_limits(1, 100); GLUI_Spinner* hertzSpinner = - glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &settings.hz); + glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &hz); hertzSpinner->set_float_limits(5.0f, 200.0f); - glui->add_checkbox("Position Correction", &settings.enablePositionCorrection); - glui->add_checkbox("Warm Starting", &settings.enablePositionCorrection); +// glui->add_checkbox("Position Correction", &settings.enablePositionCorrection); +// glui->add_checkbox("Warm Starting", &settings.enablePositionCorrection); glui->add_separator(); GLUI_Panel* drawPanel = glui->add_panel("Draw"); - glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs); - glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs); - glui->add_checkbox_to_panel(drawPanel, "Contacts", &settings.drawContacts); - glui->add_checkbox_to_panel(drawPanel, "Impulses", &settings.drawImpulses); - glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats); +// glui->add_checkbox_to_panel(drawPanel, "AABBs", &settings.drawAABBs); +// glui->add_checkbox_to_panel(drawPanel, "Pairs", &settings.drawPairs); +// glui->add_checkbox_to_panel(drawPanel, "Contacts", &settings.drawContacts); +// glui->add_checkbox_to_panel(drawPanel, "Impulses", &settings.drawImpulses); +// glui->add_checkbox_to_panel(drawPanel, "Statistics", &settings.drawStats); int testCount = 0; - TestEntry* e = g_testEntries; + btDemoEntry* e = g_demoEntries; while (e->createFcn) { testList->add_item(testCount, e->name); diff --git a/Demos/AllBulletDemos/Test.cpp b/Demos/AllBulletDemos/Test.cpp deleted file mode 100644 index 77ce173ac..000000000 --- a/Demos/AllBulletDemos/Test.cpp +++ /dev/null @@ -1,331 +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 "Test.h" -#include "Render.h" - -//#include "freeglut/gl/glut.h" -//think different -#if defined(__APPLE__) && !defined (VMDMESA) -#include -#include -#include -#else -#include -#endif - -#include - - -Test::Test() -{ - m_textLine = 30; - -} - -Test::~Test() -{ - // By deleting the world, we delete the bomb, mouse joint, etc. -} -/* -void Test::MouseDown(const b2Vec2& p) -{ - b2Assert(m_mouseJoint == NULL); - - // Make a small box. - b2AABB aabb; - b2Vec2 d; - d.Set(0.001f, 0.001f); - aabb.minVertex = p - d; - aabb.maxVertex = p + d; - - // Query the world for overlapping shapes. - const int32 k_maxCount = 10; - b2Shape* shapes[k_maxCount]; - int32 count = m_world->Query(aabb, shapes, k_maxCount); - b2Body* body = NULL; - for (int32 i = 0; i < count; ++i) - { - if (shapes[i]->m_body->IsStatic() == false) - { - bool inside = shapes[i]->TestPoint(p); - if (inside) - { - body = shapes[i]->m_body; - break; - } - } - } - - if (body) - { - b2MouseJointDef md; - md.body1 = m_world->m_groundBody; - md.body2 = body; - md.target = p; - md.motorForce = 400.0f * body->m_mass; - m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md); - body->WakeUp(); - } -} -*/ - -void Test::MouseUp() -{ -/* - if (m_mouseJoint) - { - m_world->DestroyJoint(m_mouseJoint); - m_mouseJoint = NULL; - } -*/ -} - -/*void Test::MouseMove(const b2Vec2& p) -{ - - if (m_mouseJoint) - { - m_mouseJoint->SetTarget(p); - } - -} -*/ - -void Test::LaunchBomb() -{ -/* - if (m_bomb) - { - m_world->DestroyBody(m_bomb); - m_bomb = NULL; - } - - b2BoxDef sd; - float32 a = 0.5f; - sd.type = e_boxShape; - sd.extents.Set(a, a); - sd.density = 20.0f; - - b2BodyDef bd; - bd.AddShape(&sd); - bd.allowSleep = true; - bd.position.Set(b2Random(-15.0f, 15.0f), 30.0f); - bd.rotation = b2Random(-1.5f, 1.5f); - bd.linearVelocity = -1.0f * bd.position; - bd.angularVelocity = b2Random(-20.0f, 20.0f); - - m_bomb = m_world->CreateBody(&bd); -*/ -} - -//typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGEXT_T)( void ); - -void Test::Step(const Settings* settings) -{ -/* - float32 timeStep = settings->hz > 0.0f ? 1.0f / settings->hz : 0.0f; - - if (settings->pause) - { - timeStep = 0.0f; - } - - b2World::s_enableWarmStarting = settings->enableWarmStarting; - b2World::s_enablePositionCorrection = settings->enablePositionCorrection; - - m_world->Step(timeStep, settings->iterationCount); - - m_world->m_broadPhase->Validate(); - - for (b2Body* b = m_world->m_bodyList; b; b = b->m_next) - { - for (b2Shape* s = b->m_shapeList; s; s = s->m_next) - { - if (b->IsStatic()) - { - DrawShape(s, Color(0.5f, 0.9f, 0.5f)); - } - else if (b->IsSleeping()) - { - DrawShape(s, Color(0.5f, 0.5f, 0.9f)); - } - else if (b == m_bomb) - { - DrawShape(s, Color(0.9f, 0.9f, 0.4f)); - } - else - { - DrawShape(s, Color(0.9f, 0.9f, 0.9f)); - } - } - } - - for (b2Joint* j = m_world->m_jointList; j; j = j->m_next) - { - if (j != m_mouseJoint) - { - DrawJoint(j); - } - } - - if (settings->drawContacts) - { - for (b2Contact* c = m_world->m_contactList; c; c = c->m_next) - { - b2Manifold* ms = c->GetManifolds(); - for (int32 i = 0; i < c->GetManifoldCount(); ++i) - { - b2Manifold* m = ms + i; - glPointSize(4.0f); - glColor3f(1.0f, 0.0f, 0.0f); - glBegin(GL_POINTS); - for (int j = 0; j < m->pointCount; ++j) - { - b2Vec2 v = m->points[j].position; - glVertex2f(v.x, v.y); - } - glEnd(); - glPointSize(1.0f); - } - } - } - - if (settings->drawImpulses) - { - for (b2Contact* c = m_world->m_contactList; c; c = c->m_next) - { - b2Manifold* ms = c->GetManifolds(); - for (int32 i = 0; i < c->GetManifoldCount(); ++i) - { - b2Manifold* m = ms + i; - - glColor3f(0.9f, 0.9f, 0.3f); - glBegin(GL_LINES); - for (int32 j = 0; j < m->pointCount; ++j) - { - b2Vec2 v1 = m->points[j].position; - b2Vec2 v2 = v1 + m->points[j].normalImpulse * m->normal; - glVertex2f(v1.x, v1.y); - glVertex2f(v2.x, v2.y); - } - glEnd(); - } - } - } - - if (settings->drawPairs) - { - b2BroadPhase* bp = m_world->m_broadPhase; - b2Vec2 invQ; - invQ.Set(1.0f / bp->m_quantizationFactor.x, 1.0f / bp->m_quantizationFactor.y); - glColor3f(0.9f, 0.9f, 0.3f); - glBegin(GL_LINES); - for (int32 i = 0; i < bp->m_pairManager.m_pairCount; ++i) - { - b2Pair* pair = bp->m_pairManager.m_pairs + i; - uint16 id1 = pair->proxyId1; - uint16 id2 = pair->proxyId2; - b2Proxy* p1 = bp->m_proxyPool + id1; - b2Proxy* p2 = bp->m_proxyPool + id2; - - b2AABB b1, b2; - b1.minVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p1->lowerBounds[0]].value; - b1.minVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p1->lowerBounds[1]].value; - b1.maxVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p1->upperBounds[0]].value; - b1.maxVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p1->upperBounds[1]].value; - b2.minVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p2->lowerBounds[0]].value; - b2.minVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p2->lowerBounds[1]].value; - b2.maxVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p2->upperBounds[0]].value; - b2.maxVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p2->upperBounds[1]].value; - - b2Vec2 x1 = 0.5f * (b1.minVertex + b1.maxVertex); - b2Vec2 x2 = 0.5f * (b2.minVertex + b2.maxVertex); - - glVertex2f(x1.x, x1.y); - glVertex2f(x2.x, x2.y); - } - glEnd(); - } - - if (settings->drawAABBs) - { - b2BroadPhase* bp = m_world->m_broadPhase; - b2Vec2 invQ; - invQ.Set(1.0f / bp->m_quantizationFactor.x, 1.0f / bp->m_quantizationFactor.y); - glColor3f(0.9f, 0.3f, 0.9f); - for (int32 i = 0; i < b2_maxProxies; ++i) - { - b2Proxy* p = bp->m_proxyPool + i; - if (p->IsValid() == false) - { - continue; - } - - b2AABB b; - b.minVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p->lowerBounds[0]].value; - b.minVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p->lowerBounds[1]].value; - b.maxVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p->upperBounds[0]].value; - b.maxVertex.y = bp->m_worldAABB.minVertex.y + invQ.y * bp->m_bounds[1][p->upperBounds[1]].value; - - glBegin(GL_LINE_LOOP); - glVertex2f(b.minVertex.x, b.minVertex.y); - glVertex2f(b.maxVertex.x, b.minVertex.y); - glVertex2f(b.maxVertex.x, b.maxVertex.y); - glVertex2f(b.minVertex.x, b.maxVertex.y); - glEnd(); - } - } - - if (settings->drawStats) - { - DrawString(5, m_textLine, "proxies(max) = %d(%d), pairs(max) = %d(%d)", - m_world->m_broadPhase->m_proxyCount, b2_maxProxies, - m_world->m_broadPhase->m_pairManager.m_pairCount, b2_maxPairs); - - m_textLine += 15; - - DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", - m_world->m_bodyCount, m_world->m_contactCount, m_world->m_jointCount); - - m_textLine += 15; - } - - if (m_mouseJoint) - { - b2Body* body = m_mouseJoint->m_body2; - b2Vec2 p1 = body->m_position + b2Mul(body->m_R, m_mouseJoint->m_localAnchor); - b2Vec2 p2 = m_mouseJoint->m_target; - - glPointSize(4.0f); - glColor3f(0.0f, 1.0f, 0.0f); - glBegin(GL_POINTS); - glVertex2f(p1.x, p1.y); - glVertex2f(p2.x, p2.y); - glEnd(); - glPointSize(1.0f); - - glColor3f(0.8f, 0.8f, 0.8f); - glBegin(GL_LINES); - glVertex2f(p1.x, p1.y); - glVertex2f(p2.x, p2.y); - glEnd(); - } -*/ - -} diff --git a/Demos/AllBulletDemos/Test.h b/Demos/AllBulletDemos/Test.h deleted file mode 100644 index 2e24dcb6e..000000000 --- a/Demos/AllBulletDemos/Test.h +++ /dev/null @@ -1,89 +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 TEST_H -#define TEST_H - - -class Test; -struct Settings; -#include - -typedef Test* TestCreateFcn(); - -struct Settings -{ - Settings() : - hz(60.0f), - iterationCount(10), - drawStats(0), - drawContacts(0), - drawImpulses(0), - drawAABBs(0), - drawPairs(0), - enableWarmStarting(1), - enablePositionCorrection(1), - pause(0) - {} - - float hz; - int iterationCount; - int drawStats; - int drawContacts; - int drawImpulses; - int drawAABBs; - int drawPairs; - int enableWarmStarting; - int enablePositionCorrection; - int pause; -}; - -struct TestEntry -{ - const char *name; - TestCreateFcn *createFcn; -}; - -extern TestEntry g_testEntries[]; - - -class Test -{ -public: - - Test(); - virtual ~Test(); - - void SetTextLine(int line) { m_textLine = line; } - virtual void Step(const Settings* settings); - virtual void Keyboard(unsigned char key) { -} -// void MouseDown(const b2Vec2& p); - void MouseUp(); -// void MouseMove(const b2Vec2& p); - void LaunchBomb(); - -protected: - - int m_textLine; -// b2World* m_world; -// b2Body* m_bomb; -// b2MouseJoint* m_mouseJoint; -}; - -#endif diff --git a/Demos/AllBulletDemos/TestEntries.cpp b/Demos/AllBulletDemos/TestEntries.cpp deleted file mode 100644 index bfd0e5219..000000000 --- a/Demos/AllBulletDemos/TestEntries.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -#include "Test.h" - -#include "../CcdPhysicsDemo/CcdPhysicsDemo.h" - -class CcdPhysicsTest : public Test -{ - CcdPhysicsDemo* m_demo; - CcdPhysicsTest() - { - m_demo = new CcdPhysicsDemo(); - m_demo->initPhysics(); - } - virtual ~CcdPhysicsTest() - { - delete m_demo; - } -public: - void Step(const Settings* settings) - { - m_demo->clientMoveAndDisplay(); - } - static Test* Create() - { - return new CcdPhysicsTest; - } -}; - -#include "../BspDemo/BspDemo.h" - -class BspDemoTest : public Test -{ - BspDemo* m_demo; - - BspDemoTest() - { - m_demo = new BspDemo(); - m_demo->initPhysics("BspDemo.bsp"); - } - virtual ~BspDemoTest() - { - delete m_demo; - } -public: - void Step(const Settings* settings) - { - m_demo->clientMoveAndDisplay(); - } - static Test* Create() - { - return new BspDemoTest; - } -}; - - -TestEntry g_testEntries[] = -{ - {"CcdPhysics Test", CcdPhysicsTest::Create}, - {"BspDemo Test", BspDemoTest::Create}, - {0, 0} -}; - diff --git a/Demos/BasicDemo/BasicDemo.h b/Demos/BasicDemo/BasicDemo.h index b7b622b01..89ad89910 100644 --- a/Demos/BasicDemo/BasicDemo.h +++ b/Demos/BasicDemo/BasicDemo.h @@ -52,6 +52,14 @@ class BasicDemo : public DemoApplication virtual void displayCallback(); + static DemoApplication* Create() + { + BasicDemo* demo = new BasicDemo; + demo->myinit(); + demo->initPhysics(); + return demo; + } + }; diff --git a/Demos/BspDemo/BspDemo.h b/Demos/BspDemo/BspDemo.h index cd7b5ccc0..eaf12ac56 100644 --- a/Demos/BspDemo/BspDemo.h +++ b/Demos/BspDemo/BspDemo.h @@ -30,7 +30,13 @@ class BspDemo : public DemoApplication virtual void displayCallback(); - + static DemoApplication* Create() + { + BspDemo* demo = new BspDemo; + demo->myinit(); + demo->initPhysics("BspDemo.bsp"); + return demo; + } }; diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 0b2bf9e2e..ee40f8ecf 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -66,7 +66,7 @@ subject to the following restrictions: #include "LinearMath/btQuickprof.h" #include "LinearMath/btIDebugDraw.h" -#include "GLDebugDrawer.h" + #include "BMF_Api.h" #include //printf debugging diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.h b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.h index 24b373e0d..3e0768e8d 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.h +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.h @@ -30,6 +30,14 @@ class CcdPhysicsDemo : public DemoApplication void createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos ); + static DemoApplication* Create() + { + CcdPhysicsDemo* demo = new CcdPhysicsDemo; + demo->myinit(); + demo->initPhysics(); + return demo; + } + }; #endif //CCD_PHYSICS_DEMO_H