diff --git a/Demos/GyroscopicDemo/GyroscopicSetup.cpp b/Demos/GyroscopicDemo/GyroscopicSetup.cpp index 065d1a624..c443bc2d5 100644 --- a/Demos/GyroscopicDemo/GyroscopicSetup.cpp +++ b/Demos/GyroscopicDemo/GyroscopicSetup.cpp @@ -1,5 +1,22 @@ #include "GyroscopicSetup.h" +static int gyroflags[5] = { + 0,//none, no gyroscopic term + BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT, + BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_EWERT, + BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_CATTO, + BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_COOPER, +}; + +static const char* gyroNames[5] = { + "No Coriolis", + "Explicit", + "Ewert", + "Catto", + "Cooper", +}; + + void GyroscopicSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge) { gfxBridge.setUpAxis(2); @@ -7,16 +24,7 @@ void GyroscopicSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge) m_dynamicsWorld->setGravity(btVector3(0, 0, 0)); gfxBridge.createPhysicsDebugDrawer(m_dynamicsWorld); - //btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(0.5))); - btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0, 0, 1), 0); - - m_collisionShapes.push_back(groundShape); - btTransform groundTransform; - groundTransform.setIdentity(); - groundTransform.setOrigin(btVector3(0, 0, 0)); - btRigidBody* groundBody; - groundBody = createRigidBody(0, groundTransform, groundShape); - groundBody->setFriction(btSqrt(2)); + btVector3 positions[5] = { btVector3( -10, 8,4), btVector3( -5, 8,4), @@ -24,14 +32,7 @@ void GyroscopicSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge) btVector3( 5, 8,4), btVector3( 10, 8,4), }; - int gyroflags[5] = { - 0,//none, no gyroscopic term - BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT, - BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_EWERT, - BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_COOPER, - BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_CATTO, - - }; + for (int i = 0; i<5; i++) { @@ -64,6 +65,34 @@ void GyroscopicSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge) } + { + //btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(0.5))); + btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0, 0, 1), 0); + + m_collisionShapes.push_back(groundShape); + btTransform groundTransform; + groundTransform.setIdentity(); + groundTransform.setOrigin(btVector3(0, 0, 0)); + btRigidBody* groundBody; + groundBody = createRigidBody(0, groundTransform, groundShape); + groundBody->setFriction(btSqrt(2)); + } gfxBridge.autogenerateGraphicsObjects(m_dynamicsWorld); } - + +void GyroscopicSetup::syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge) +{ + CommonRigidBodySetup::syncPhysicsToGraphics(gfxBridge); + //render method names above objects + for (int i=0;igetNumCollisionObjects();i++) + { + btRigidBody* body = btRigidBody::upcast(m_dynamicsWorld->getCollisionObjectArray()[i]); + if (body && body->getInvMass()>0) + { + btTransform tr = body->getWorldTransform(); + btVector3 pos = tr.getOrigin()+btVector3(0,0,2); + btScalar size=1; + gfxBridge.drawText3D(gyroNames[i],pos.x(),pos.y(),pos.z(),size); + } + } +} diff --git a/Demos/GyroscopicDemo/GyroscopicSetup.h b/Demos/GyroscopicDemo/GyroscopicSetup.h index 1a797c8c6..0a7f8a197 100644 --- a/Demos/GyroscopicDemo/GyroscopicSetup.h +++ b/Demos/GyroscopicDemo/GyroscopicSetup.h @@ -8,6 +8,8 @@ struct GyroscopicSetup : public CommonRigidBodySetup { virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge); + virtual void syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge); + }; diff --git a/Demos3/AllBullet2Demos/main.cpp b/Demos3/AllBullet2Demos/main.cpp index 42d075a9c..aec219c93 100644 --- a/Demos3/AllBullet2Demos/main.cpp +++ b/Demos3/AllBullet2Demos/main.cpp @@ -32,6 +32,7 @@ #include "Bullet3AppSupport/GwenTextureWindow.h" #include "Bullet3AppSupport/GraphingTexture.h" #include "Bullet3AppSupport/Common2dCanvasInterface.h" +#include "Bullet3Common/b3CommandLineArgs.h" #include "OpenGLWindow/SimpleCamera.h" #include "OpenGLWindow/SimpleOpenGL2Renderer.h" @@ -462,6 +463,8 @@ struct QuickCanvas : public Common2dCanvasInterface extern float shadowMapWorldSize; int main(int argc, char* argv[]) { + b3CommandLineArgs args(argc,argv); + shadowMapWorldSize = 25; b3Clock clock; @@ -483,7 +486,13 @@ int main(int argc, char* argv[]) simpleApp = new SimpleOpenGL3App("AllBullet2Demos",width,height); app = simpleApp; } + char* gVideoFileName = 0; + args.GetCmdLineArgument("mp4",gVideoFileName); + if (gVideoFileName) + simpleApp->dumpFramesToVideo(gVideoFileName); + + s_instancingRenderer = app->m_renderer; s_window = app->m_window; prevMouseMoveCallback = s_window->getMouseMoveCallback(); diff --git a/btgui/Bullet3AppSupport/Bullet2RigidBodyDemo.cpp b/btgui/Bullet3AppSupport/Bullet2RigidBodyDemo.cpp index f08c79ad5..13dcc7817 100644 --- a/btgui/Bullet3AppSupport/Bullet2RigidBodyDemo.cpp +++ b/btgui/Bullet3AppSupport/Bullet2RigidBodyDemo.cpp @@ -275,6 +275,12 @@ struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge } } + + virtual void drawText3D( const char* txt, float posX, float posY, float posZ, float size) + { + btAssert(m_glApp); + m_glApp->drawText3D(txt,posX,posY,posZ,size); + } }; Bullet2RigidBodyDemo::Bullet2RigidBodyDemo(CommonGraphicsApp* app, CommonPhysicsSetup* physicsSetup) diff --git a/btgui/Bullet3AppSupport/CommonPhysicsSetup.h b/btgui/Bullet3AppSupport/CommonPhysicsSetup.h index 6d4e37366..b1146e2a4 100644 --- a/btgui/Bullet3AppSupport/CommonPhysicsSetup.h +++ b/btgui/Bullet3AppSupport/CommonPhysicsSetup.h @@ -55,6 +55,11 @@ struct GraphicsPhysicsBridge virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) { } + + virtual void drawText3D( const char* txt, float posX, float posZY, float posZ, float size) + { + + } }; ///Bullet 2 specific physics setup, that allows to share code between old and new demo frameworks diff --git a/btgui/OpenGLWindow/SimpleOpenGL3App.cpp b/btgui/OpenGLWindow/SimpleOpenGL3App.cpp index d836cacfc..814e65196 100644 --- a/btgui/OpenGLWindow/SimpleOpenGL3App.cpp +++ b/btgui/OpenGLWindow/SimpleOpenGL3App.cpp @@ -744,6 +744,7 @@ void SimpleOpenGL3App::swapBuffer() } m_window->startRendering(); } + // see also http://blog.mmacklin.com/2013/06/11/real-time-video-capture-with-ffmpeg/ void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName) { @@ -751,8 +752,17 @@ void SimpleOpenGL3App::dumpFramesToVideo(const char* mp4FileName) int height = (int)m_window->getRetinaScale()*m_instancingRenderer->getScreenHeight(); char cmd[8192]; - sprintf(cmd,"ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - " - "-threads 0 -y -crf 0 -b 50000k -vf vflip %s",width,height,mp4FileName); +#ifdef _WIN32 + sprintf(cmd, "ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - " + "-y -crf 0 -b:v 1500000 -an -vcodec h264 -vf vflip %s", width, height, mp4FileName); +#else + + sprintf(cmd, "ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - " + "-threads 0 -y -crf 0 -b 50000k -vf vflip %s", width, height, mp4FileName); +#endif + + //sprintf(cmd,"ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - " + // "-threads 0 -y -crf 0 -b 50000k -vf vflip %s",width,height,mp4FileName); // sprintf(cmd,"ffmpeg -r 60 -f rawvideo -pix_fmt rgba -s %dx%d -i - " // "-threads 0 -preset fast -y -crf 21 -vf vflip %s",width,height,mp4FileName); diff --git a/build3/premake4.lua b/build3/premake4.lua index c6a678f87..f6f9bd39b 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -94,6 +94,7 @@ { 'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"', 'VALID_ARCHS = "x86_64 i386"', +-- 'SDKROOT = "macosx10.9"', } end diff --git a/src/BulletDynamics/Dynamics/btRigidBody.cpp b/src/BulletDynamics/Dynamics/btRigidBody.cpp index 1a71887c6..5df324fe7 100644 --- a/src/BulletDynamics/Dynamics/btRigidBody.cpp +++ b/src/BulletDynamics/Dynamics/btRigidBody.cpp @@ -434,9 +434,8 @@ if (dInvertMatrix3(itInv, Itild) != 0) { } #endif btVector3 tau0 = Itild * L; - printf("tau0 = %f,%f,%f\n",tau0.x(),tau0.y(),tau0.z()); +// printf("tau0 = %f,%f,%f\n",tau0.x(),tau0.y(),tau0.z()); return tau0; - return btVector3(0, 0, 0); } btVector3 btRigidBody::computeGyroscopicImpulseImplicit_Ewert(btScalar step) const