From bb9ea22bf09868dd1e8dcef21768baf502f27b07 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 21 Oct 2014 17:49:57 -0700 Subject: [PATCH 1/3] fix mac build --- Demos3/ImportColladaDemo/btMatrix4x4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Demos3/ImportColladaDemo/btMatrix4x4.h b/Demos3/ImportColladaDemo/btMatrix4x4.h index d39c37101..5d6ec3a30 100644 --- a/Demos3/ImportColladaDemo/btMatrix4x4.h +++ b/Demos3/ImportColladaDemo/btMatrix4x4.h @@ -118,7 +118,7 @@ ATTRIBUTE_ALIGNED16(class) btMatrix4x4 } SIMD_FORCE_INLINE btMatrix4x4 - btMatrix4x4::operator*=(const btMatrix4x4& m) + operator*=(const btMatrix4x4& m) { setValue( m.tdotx(m_el[0]), m.tdoty(m_el[0]), m.tdotz(m_el[0]),m.tdotw(m_el[0]), From 29650871109e4dc9aabcd268f12d367c25fc1fc3 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 21 Oct 2014 18:06:36 -0700 Subject: [PATCH 2/3] remove unnecessary header --- Demos3/ImportColladaDemo/LoadMeshFromCollada.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Demos3/ImportColladaDemo/LoadMeshFromCollada.cpp b/Demos3/ImportColladaDemo/LoadMeshFromCollada.cpp index 61a627e0e..5991c95b7 100644 --- a/Demos3/ImportColladaDemo/LoadMeshFromCollada.cpp +++ b/Demos3/ImportColladaDemo/LoadMeshFromCollada.cpp @@ -20,7 +20,6 @@ subject to the following restrictions: #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" #include -#include "OpenGLWindow/OpenGLInclude.h" #include "tinyxml/tinyxml.h" #include "Bullet3Common/b3FileUtils.h" From 2e1cbc0133384954c45970f510aaacd081039975 Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Wed, 22 Oct 2014 11:17:13 -0700 Subject: [PATCH 3/3] add basic concept demo, Coordinate System for a start. set the up axis for some of the demos. --- Demos3/AllBullet2Demos/BulletDemoEntries.h | 8 +- .../BasicConcepts/CoordinateSystemDemo.h | 143 ++++++++++++++++++ .../CollisionDetection/SupportFuncDemo.h | 1 + .../BulletMultiBodyDemos.cpp | 1 + .../MultiDofDemo.cpp | 1 + Demos3/bullet2/LuaDemo/LuaPhysicsSetup.cpp | 1 + 6 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h diff --git a/Demos3/AllBullet2Demos/BulletDemoEntries.h b/Demos3/AllBullet2Demos/BulletDemoEntries.h index 535df282d..c2106dbd8 100644 --- a/Demos3/AllBullet2Demos/BulletDemoEntries.h +++ b/Demos3/AllBullet2Demos/BulletDemoEntries.h @@ -23,6 +23,7 @@ #include "../../Demos/SerializeDemo/SerializeSetup.h" #include "../bullet2/MultiBodyDemo/TestJointTorqueSetup.h" #include "../bullet2/CollisionDetection/SupportFuncDemo.h" +#include "../bullet2/BasicConcepts/CoordinateSystemDemo.h" static BulletDemoInterface* TestJointTorqueCreateFunc(CommonGraphicsApp* app) { @@ -83,6 +84,7 @@ static BulletDemoInterface* MyImportColladaCreateFunc(CommonGraphicsApp* app) + struct BulletDemoEntry { int m_menuLevel; @@ -94,9 +96,9 @@ struct BulletDemoEntry static BulletDemoEntry allDemos[]= { - {0,"LowLevel",0}, - {1,"SupportFunc", &MySupportFuncDemo::CreateFunc}, - + {0,"Basic Concepts",0}, + {1,"Basis Frame", &CoordinateSystemDemo::CreateFunc}, + {1,"SupportFunc", &MySupportFuncDemo::CreateFunc}, //{"emptydemo",EmptyBulletDemo::MyCreateFunc}, {0,"API Demos", 0}, diff --git a/Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h b/Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h new file mode 100644 index 000000000..69e3dc229 --- /dev/null +++ b/Demos3/bullet2/BasicConcepts/CoordinateSystemDemo.h @@ -0,0 +1,143 @@ +#ifndef COORDINATE_SYSTEM_DEMO_H +#define COORDINATE_SYSTEM_DEMO_H + +#include "Bullet3AppSupport/BulletDemoInterface.h" +#include "OpenGLWindow/CommonGraphicsApp.h" + + +///quick demo showing the right-handed coordinate system and positive rotations around each axis +class CoordinateSystemDemo : public BulletDemoInterface +{ + CommonGraphicsApp* m_app; + float m_x; + float m_y; + float m_z; + +public: + + CoordinateSystemDemo(CommonGraphicsApp* app) + :m_app(app), + m_x(0), + m_y(0), + m_z(0) + { + m_app->setUpAxis(2); + + { + int boxId = m_app->registerCubeShape(0.1,0.1,0.1); + btVector3 pos(0,0,0); + btQuaternion orn(0,0,0,1); + btVector4 color(0.3,0.3,0.3,1); + btVector3 scaling(1,1,1); + m_app->m_renderer->registerGraphicsInstance(boxId,pos,orn,color,scaling); + } + + m_app->m_renderer->writeTransforms(); + } + virtual ~CoordinateSystemDemo() + { + m_app->m_renderer->enableBlend(false); + } + static BulletDemoInterface* CreateFunc(CommonGraphicsApp* app) + { + return new CoordinateSystemDemo(app); + } + + virtual void initPhysics() + { + } + virtual void exitPhysics() + { + + } + virtual void stepSimulation(float deltaTime) + { + m_x+=0.01f; + m_y+=0.01f; + m_z+=0.01f; + + } + virtual void renderScene() + { + m_app->m_renderer->renderScene(); + } + + virtual void drawArc(const btVector3& center, const btVector3& normal, const btVector3& axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle, + const btVector3& color, bool drawSect, btScalar stepDegrees = btScalar(10.f)) + { + btScalar lineWidth = 3; + const btVector3& vx = axis; + btVector3 vy = normal.cross(axis); + btScalar step = stepDegrees * SIMD_RADS_PER_DEG; + int nSteps = (int)btFabs((maxAngle - minAngle) / step); + if(!nSteps) nSteps = 1; + btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle); + if(drawSect) + { + m_app->m_renderer->drawLine(center, prev, color,lineWidth); + } + for(int i = 1; i <= nSteps; i++) + { + btScalar angle = minAngle + (maxAngle - minAngle) * btScalar(i) / btScalar(nSteps); + btVector3 next = center + radiusA * vx * btCos(angle) + radiusB * vy * btSin(angle); + m_app->m_renderer->drawLine(prev, next, color,lineWidth); + prev = next; + } + if(drawSect) + { + m_app->m_renderer->drawLine(center, prev, color,lineWidth); + } + } + + virtual void physicsDebugDraw() + { + + btVector3 xUnit(1,0,0); + btVector3 yUnit(0,1,0); + btVector3 zUnit(0,0,1); + + btScalar lineWidth=3; + + btQuaternion rotAroundX(xUnit,m_x); + btQuaternion rotAroundY(yUnit,m_y); + btQuaternion rotAroundZ(zUnit,m_z); + + btScalar radius=0.5; + btVector3 toX=radius*quatRotate(rotAroundX,yUnit); + btVector3 toY=radius*quatRotate(rotAroundY,xUnit); + btVector3 toZ=radius*quatRotate(rotAroundZ,xUnit); + + m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,0.1,-0.2)),xUnit+toX,xUnit,lineWidth); + m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,-0.2,-0.2)),xUnit+toX,xUnit,lineWidth); + //draw the letter 'x' on the x-axis + //m_app->m_renderer->drawLine(xUnit-0.1*zUnit+0.1*yUnit,xUnit+0.1*zUnit-0.1*yUnit,xUnit,lineWidth); + //m_app->m_renderer->drawLine(xUnit+0.1*zUnit+0.1*yUnit,xUnit-0.1*zUnit-0.1*yUnit,xUnit,lineWidth); + + m_app->m_renderer->drawLine(xUnit+toX+quatRotate(rotAroundX,btVector3(0,-0.2,-0.2)),xUnit+toX,xUnit,lineWidth); + + m_app->m_renderer->drawLine(yUnit+toY+quatRotate(rotAroundY,btVector3(-0.2,0,0.2)),yUnit+toY,yUnit,lineWidth); + m_app->m_renderer->drawLine(yUnit+toY+quatRotate(rotAroundY,btVector3(0.1,0,0.2)),yUnit+toY,yUnit,lineWidth); + m_app->m_renderer->drawLine(zUnit+toZ+quatRotate(rotAroundZ,btVector3(0.1,-0.2,0)),zUnit+toZ,zUnit,lineWidth); + m_app->m_renderer->drawLine(zUnit+toZ+quatRotate(rotAroundZ,btVector3(-0.2,-0.2,0)),zUnit+toZ,zUnit,lineWidth); + + + drawArc(xUnit,xUnit,toX.normalized(),radius,radius,0.4,SIMD_2_PI,xUnit,false); + drawArc(yUnit,yUnit,toY.normalized(),radius,radius,0.4,SIMD_2_PI,yUnit,false); + drawArc(zUnit,zUnit,toZ.normalized(),radius,radius,0.4,SIMD_2_PI,zUnit,false); + } + virtual bool mouseMoveCallback(float x,float y) + { + return false; + } + virtual bool mouseButtonCallback(int button, int state, float x, float y) + { + return false; + } + virtual bool keyboardCallback(int key, int state) + { + return false; + } + +}; +#endif //COORDINATE_SYSTEM_DEMO_H + diff --git a/Demos3/bullet2/CollisionDetection/SupportFuncDemo.h b/Demos3/bullet2/CollisionDetection/SupportFuncDemo.h index 7e28b274b..ad26b2d66 100644 --- a/Demos3/bullet2/CollisionDetection/SupportFuncDemo.h +++ b/Demos3/bullet2/CollisionDetection/SupportFuncDemo.h @@ -22,6 +22,7 @@ public: m_x(0), m_y(0) { + m_app->setUpAxis(1); m_sphere = new btSphereShape(1); { int boxId = m_app->registerCubeShape(10,0.1,10); diff --git a/Demos3/bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.cpp b/Demos3/bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.cpp index 49e48c862..3a20a8ddf 100644 --- a/Demos3/bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.cpp +++ b/Demos3/bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.cpp @@ -55,6 +55,7 @@ m_pickedConstraint(0), m_pickingMultiBodyPoint2Point(0) { + app->setUpAxis(1); m_collisionConfiguration = 0; m_dispatcher = 0; m_broadphase = 0; diff --git a/Demos3/bullet2/FeatherstoneMultiBodyDemo/MultiDofDemo.cpp b/Demos3/bullet2/FeatherstoneMultiBodyDemo/MultiDofDemo.cpp index 3f75032e9..db813c25e 100644 --- a/Demos3/bullet2/FeatherstoneMultiBodyDemo/MultiDofDemo.cpp +++ b/Demos3/bullet2/FeatherstoneMultiBodyDemo/MultiDofDemo.cpp @@ -35,6 +35,7 @@ static float friction = 1.; MultiDofDemo::MultiDofDemo(CommonGraphicsApp* app) :FeatherstoneDemo1(app) { + app->setUpAxis(1); } MultiDofDemo::~MultiDofDemo() { diff --git a/Demos3/bullet2/LuaDemo/LuaPhysicsSetup.cpp b/Demos3/bullet2/LuaDemo/LuaPhysicsSetup.cpp index 6a7189306..58fe896a7 100644 --- a/Demos3/bullet2/LuaDemo/LuaPhysicsSetup.cpp +++ b/Demos3/bullet2/LuaDemo/LuaPhysicsSetup.cpp @@ -35,6 +35,7 @@ m_bp(0), m_solver(0), m_dynamicsWorld(0) { + app->setUpAxis(1); sLuaDemo = this; }