diff --git a/Demos/BasicDemo/BasicDemoPhysicsSetup.cpp b/Demos/BasicDemo/BasicDemoPhysicsSetup.cpp index f33d68e3b..c3c03ba77 100644 --- a/Demos/BasicDemo/BasicDemoPhysicsSetup.cpp +++ b/Demos/BasicDemo/BasicDemoPhysicsSetup.cpp @@ -39,7 +39,7 @@ void BasicDemoPhysicsSetup::initPhysics() { btScalar mass(0.); - createRigidBody(mass,groundTransform,groundShape); + createRigidBody(mass,groundTransform,groundShape, btVector4(0,0,1,1)); } @@ -99,7 +99,7 @@ btBoxShape* BasicDemoPhysicsSetup::createBoxShape(const btVector3& halfExtents) return box; } -btRigidBody* BasicDemoPhysicsSetup::createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape) +btRigidBody* BasicDemoPhysicsSetup::createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color) { btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE)); diff --git a/Demos/BasicDemo/BasicDemoPhysicsSetup.h b/Demos/BasicDemo/BasicDemoPhysicsSetup.h index e335a3861..b275a6a78 100644 --- a/Demos/BasicDemo/BasicDemoPhysicsSetup.h +++ b/Demos/BasicDemo/BasicDemoPhysicsSetup.h @@ -11,6 +11,7 @@ class btDiscreteDynamicsWorld; class btTransform; class btVector3; class btBoxShape; +#include "LinearMath/btVector3.h" #include "LinearMath/btAlignedObjectArray.h" @@ -31,7 +32,7 @@ struct BasicDemoPhysicsSetup virtual void stepSimulation(float deltaTime); - virtual btRigidBody* createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape); + virtual btRigidBody* createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color=btVector4(1,0,0,1)); virtual btBoxShape* createBoxShape(const btVector3& halfExtents); diff --git a/Demos3/bullet2/BasicDemo/BasicDemo.cpp b/Demos3/bullet2/BasicDemo/BasicDemo.cpp index f0386862b..b47fb12de 100644 --- a/Demos3/bullet2/BasicDemo/BasicDemo.cpp +++ b/Demos3/bullet2/BasicDemo/BasicDemo.cpp @@ -68,13 +68,13 @@ void BasicDemo::exitPhysics() //SimpleOpenGL3App* m_glApp; -btRigidBody* MyBasicDemoPhysicsSetup::createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape) +btRigidBody* MyBasicDemoPhysicsSetup::createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color) { btRigidBody* body = BasicDemoPhysicsSetup::createRigidBody(mass,startTransform,shape); int graphicsShapeId = shape->getUserIndex(); btAssert(graphicsShapeId>=0); btVector3 localScaling = shape->getLocalScaling(); - float color[]={0.3,0.3,1,1}; + int graphicsInstanceId = m_glApp->m_instancingRenderer->registerGraphicsInstance(graphicsShapeId,startTransform.getOrigin(),startTransform.getRotation(),color,localScaling); body->setUserIndex(graphicsInstanceId); diff --git a/Demos3/bullet2/BasicDemo/BasicDemo.h b/Demos3/bullet2/BasicDemo/BasicDemo.h index d1da7ac62..283004929 100644 --- a/Demos3/bullet2/BasicDemo/BasicDemo.h +++ b/Demos3/bullet2/BasicDemo/BasicDemo.h @@ -11,7 +11,7 @@ struct MyBasicDemoPhysicsSetup : public BasicDemoPhysicsSetup { SimpleOpenGL3App* m_glApp; - virtual btRigidBody* createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape); + virtual btRigidBody* createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color); virtual btBoxShape* createBoxShape(const btVector3& halfExtents); }; diff --git a/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp b/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp index 517a9d08b..72069c2b6 100644 --- a/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp +++ b/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.cpp @@ -5,7 +5,9 @@ Bullet2RigidBodyDemo::Bullet2RigidBodyDemo(SimpleOpenGL3App* app) :m_glApp(app), m_pickedBody(0), - m_pickedConstraint(0) + m_pickedConstraint(0), +m_controlPressed(false), +m_altPressed(false) { m_config = 0; m_dispatcher = 0; @@ -113,8 +115,8 @@ btVector3 Bullet2RigidBodyDemo::getRayTo(int x,int y) bool Bullet2RigidBodyDemo::mouseMoveCallback(float x,float y) { -// if (m_data->m_altPressed!=0 || m_data->m_controlPressed!=0) -// return false; + //if (m_data->m_altPressed!=0 || m_data->m_controlPressed!=0) + //return false; if (m_pickedBody && m_pickedConstraint) { @@ -143,7 +145,7 @@ bool Bullet2RigidBodyDemo::mouseButtonCallback(int button, int state, float x, f if (state==1) { - if(button==0)// && (m_data->m_altPressed==0 && m_data->m_controlPressed==0)) + if(button==0 && (!m_altPressed && !m_controlPressed)) { btVector3 camPos; m_glApp->m_instancingRenderer->getCameraPosition(camPos); diff --git a/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.h b/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.h index 53ddbb17b..3cabd9e17 100644 --- a/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.h +++ b/Demos3/bullet2/BasicDemo/Bullet2RigidBodyDemo.h @@ -5,6 +5,8 @@ #include "../../AllBullet2Demos/BulletDemoInterface.h" +#include "OpenGLWindow/b3gWindowInterface.h" + class Bullet2RigidBodyDemo : public BulletDemoInterface { public: @@ -19,7 +21,8 @@ public: btVector3 m_oldPickingPos; btVector3 m_hitPos; btScalar m_oldPickingDist; - + bool m_controlPressed; + bool m_altPressed; public: @@ -35,6 +38,14 @@ public: virtual bool mouseButtonCallback(int button, int state, float x, float y); virtual bool keyboardCallback(int key, int state) { + if (key==B3G_CONTROL) + { + m_controlPressed = (state==1); + } + if (key==B3G_ALT) + { + m_altPressed = (state==1); + } return false; }