add option to create mp4 videos from App_AllBullet2Demos, using the
--mp4=video.mp4 note that you have to re-convert for Quicktime ffmpeg -f mp4 -vcodec h264 -i test.mp4 -pix_fmt yuv420p test2.mp4 add the option to display text in 3d, used in Coriolis demo
This commit is contained in:
@@ -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;i<m_dynamicsWorld->getNumCollisionObjects();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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ struct GyroscopicSetup : public CommonRigidBodySetup
|
||||
{
|
||||
virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge);
|
||||
|
||||
virtual void syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
{
|
||||
'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"',
|
||||
'VALID_ARCHS = "x86_64 i386"',
|
||||
-- 'SDKROOT = "macosx10.9"',
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user