Start re-organizing demos so the physics setup can be shared easier (explicit create graphics objects, init/exit physics etc)
Add B3G_RETURN key code, only implemented in Windows so far (todo: Mac, Linux) Fix Windows key management (use WM_CHAR event instead of WM_KEYUP Add Return (OnKeyReturn) key support TreeNode, so we can select an item using the return key.
This commit is contained in:
53
Demos/CommonPhysicsSetup.h
Normal file
53
Demos/CommonPhysicsSetup.h
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
#ifndef COMMON_PHYSICS_SETUP_H
|
||||
#define COMMON_PHYSICS_SETUP_H
|
||||
|
||||
class btRigidBody;
|
||||
class btBoxShape;
|
||||
class btTransform;
|
||||
class btCollisionShape;
|
||||
#include "LinearMath/btVector3.h"
|
||||
class btDiscreteDynamicsWorld;
|
||||
|
||||
///The GraphicsPhysicsBridge let's the graphics engine create graphics representation and synchronize
|
||||
struct GraphicsPhysicsBridge
|
||||
{
|
||||
virtual void createRigidBodyGraphicsObject(btRigidBody* body,const btVector3& color)
|
||||
{
|
||||
}
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)
|
||||
{
|
||||
}
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct CommonPhysicsSetup
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CommonPhysicsSetup() {}
|
||||
|
||||
virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge) = 0;
|
||||
|
||||
virtual void exitPhysics()=0;
|
||||
|
||||
virtual void stepSimulation(float deltaTime)=0;
|
||||
|
||||
virtual bool pickBody(const btVector3& rayFromWorld, const btVector3& rayToWorld) = 0;
|
||||
virtual bool movePickedBody(const btVector3& rayFromWorld, const btVector3& rayToWorld)=0;
|
||||
virtual void removePickingConstraint() = 0;
|
||||
|
||||
virtual void syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge) = 0;
|
||||
|
||||
virtual btRigidBody* createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color=btVector4(1,0,0,1))=0;
|
||||
|
||||
virtual btBoxShape* createBoxShape(const btVector3& halfExtents)=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //COMMON_PHYSICS_SETUP_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user