Changeset 1923 for code/branches/physics/src/ogreode/OgreOdeFrameListener.h
- Timestamp:
- Oct 14, 2008, 10:07:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/ogreode/OgreOdeFrameListener.h
r1919 r1923 8 8 #define _PHYSICSFRAMELISTENER_H_ 9 9 10 #include "OgreOdePreReqs.h" 11 #include <OgreSceneQuery.h> 12 #include <OgreFrameListener.h> 13 10 14 // Uncomment this if you're planning to use the Plane2D joint 11 15 // But you'll have to have modified ODE first! … … 15 19 A physical thing 16 20 */ 17 class PhysicalThing : public RaySceneQueryListener21 class PhysicalThing : public Ogre::RaySceneQueryListener 18 22 { 19 23 public: … … 23 27 24 28 // Just create geoms 25 void makePlane( Real a,Real b,Real c,Real d); // Plane26 void makeBox( Real x,Real y,Real z,Real lx,Real ly,Real lz); // Box27 void makeSphere( Real x,Real y,Real z,Real r); // Sphere29 void makePlane(Ogre::Real a, Ogre::Real b, Ogre::Real c, Ogre::Real d); // Plane 30 void makeBox(Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Real lx, Ogre::Real ly, Ogre::Real lz); // Box 31 void makeSphere(Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Real r); // Sphere 28 32 29 33 // Create bodies and geoms 30 void makePlane(dWorld *world, SceneNode *node);31 void makeBox(dWorld *world, SceneNode *node,Real mass = 1,Vector3 const &offs =Vector3(0,0,0));32 void makeSphere(dWorld *world, SceneNode *node,Real mass = 1);33 void makeTerrainTriMesh(dWorld *world, SceneManager *mgr,Real grid_size,Real grid_spacing);34 void makePlane(dWorld *world, Ogre::SceneNode *node); 35 void makeBox(dWorld *world, Ogre::SceneNode *node, Ogre::Real mass = 1, Ogre::Vector3 const &offs = Ogre::Vector3(0,0,0)); 36 void makeSphere(dWorld *world, Ogre::SceneNode *node, Ogre::Real mass = 1); 37 void makeTerrainTriMesh(dWorld *world, Ogre::SceneManager *mgr, Ogre::Real grid_size, Ogre::Real grid_spacing); 34 38 35 39 // Callback functions for the ray scene query functionality 36 virtual bool queryResult( SceneQuery::WorldFragment *fragment,Real distance);37 virtual bool queryResult( MovableObject *obj,Real distance);40 virtual bool queryResult(Ogre::SceneQuery::WorldFragment *fragment, Ogre::Real distance); 41 virtual bool queryResult(Ogre::MovableObject *obj, Ogre::Real distance); 38 42 39 43 // Update the position and orientation of the scene node we're controlling … … 41 45 42 46 // Utility functions to get at internal stuff 43 SceneNode *getNode(void);47 Ogre::SceneNode *getNode(void); 44 48 dBodyID getBodyID(void); 45 49 dSpaceID getSpaceID(void); … … 49 53 dBody *_body; 50 54 dSpace *_space; 51 SceneNode *_node;55 Ogre::SceneNode *_node; 52 56 53 std::list< Vector3> _frag;57 std::list<Ogre::Vector3> _frag; 54 58 55 59 dVector3 *_vertices; … … 60 64 A Frame listener that implements the physics 61 65 */ 62 class PhysicsFrameListener : public FrameListener66 class PhysicsFrameListener : public Ogre::FrameListener 63 67 { 64 68 protected: … … 76 80 77 81 // Adjustable variables 78 Real total_time,step_size;79 Real k_spring,k_damper,k_tyre,k_mu,k_erp,k_cfm;82 Ogre::Real total_time,step_size; 83 Ogre::Real k_spring,k_damper,k_tyre,k_mu,k_erp,k_cfm; 80 84 81 85 // Utility function to find the physical thing associated with an Ogre scene node 82 dBodyID getBodyID( SceneNode *node);86 dBodyID getBodyID(Ogre::SceneNode *node); 83 87 84 88 public: … … 88 92 89 93 // Tell us when every frame's about to be started 90 bool frameStarted(const FrameEvent& evt);94 bool frameStarted(const Ogre::FrameEvent& evt); 91 95 void pause(bool p = true); 92 96 … … 98 102 // Create things manually, no physical bodies 99 103 // so they won't move, but things will collide with them 100 PhysicalThing *createPlane( Real a,Real b,Real c,Real d);101 PhysicalThing *createBox( Real x,Real y,Real z,Real lx,Real ly,Real lz);102 PhysicalThing *createSphere( Real x,Real y,Real z,Real r);104 PhysicalThing *createPlane(Ogre::Real a,Ogre::Real b,Ogre::Real c,Ogre::Real d); 105 PhysicalThing *createBox(Ogre::Real x,Ogre::Real y,Ogre::Real z,Ogre::Real lx,Ogre::Real ly,Ogre::Real lz); 106 PhysicalThing *createSphere(Ogre::Real x,Ogre::Real y,Ogre::Real z,Ogre::Real r); 103 107 104 108 // Create objects based on Ogre nodes, these nodes will then … … 107 111 // Except for the plane, which can't actually be a physical body 108 112 // and the trimesh which we're not going to allow to be a physical body 109 PhysicalThing *createPlane( SceneNode *node);110 PhysicalThing *createBox( SceneNode *node,Real mass = 1,Vector3 const &offs =Vector3(0,0,0));111 PhysicalThing *createSphere( SceneNode *node,Real mass = 1);112 PhysicalThing *createTerrainTriMesh( SceneManager *mgr,Real grid_size,Real grid_spacing);113 PhysicalThing *createPlane(Ogre::SceneNode *node); 114 PhysicalThing *createBox(Ogre::SceneNode *node,Ogre::Real mass = 1,Ogre::Vector3 const &offs = Ogre::Vector3(0,0,0)); 115 PhysicalThing *createSphere(Ogre::SceneNode *node,Ogre::Real mass = 1); 116 PhysicalThing *createTerrainTriMesh(Ogre::SceneManager *mgr,Ogre::Real grid_size,Ogre::Real grid_spacing); 113 117 114 118 // Create and activate a new space inside the standard hash space … … 120 124 // The order of n1/n2 does matter; n1 is what you want attaching 121 125 // and n2 is what you want it attaching to 122 dJoint *createHinge2( SceneNode *n1,SceneNode *n2,const Vector3 &suspension = Vector3(0,1,0),const Vector3 &axle =Vector3(1,0,0));123 dJoint *createHinge( SceneNode *n1,SceneNode *n2,const Vector3 &axis =Vector3(1,0,0));124 dJoint *createSlider( SceneNode *n1,SceneNode *n2,const Vector3 &axis =Vector3(0,1,0));125 dJoint *createBall( SceneNode *n1,SceneNode *n2);126 dJoint *createHinge2(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &suspension = Ogre::Vector3(0,1,0),const Ogre::Vector3 &axle = Ogre::Vector3(1,0,0)); 127 dJoint *createHinge(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &axis = Ogre::Vector3(1,0,0)); 128 dJoint *createSlider(Ogre::SceneNode *n1,Ogre::SceneNode *n2,const Ogre::Vector3 &axis = Ogre::Vector3(0,1,0)); 129 dJoint *createBall(Ogre::SceneNode *n1,Ogre::SceneNode *n2); 126 130 #ifdef INCLUDE_PLANE2D_JOINT 127 dJoint *createPlane2D( SceneNode *n);131 dJoint *createPlane2D(Ogre::SceneNode *n); 128 132 #endif 129 133 130 134 // Apply forces to a body under our control 131 void addTorque( SceneNode *n,constVector3 &force);135 void addTorque(Ogre::SceneNode *n,const Ogre::Vector3 &force); 132 136 133 137 // Set the parameters used for the CFM/ERP joint parameters 134 void setSuspension( Real spring,Real damper);138 void setSuspension(Ogre::Real spring,Ogre::Real damper); 135 139 136 140 // Set the acceleration due to gravity 137 void setGravity( Real g);141 void setGravity(Ogre::Real g); 138 142 139 143 // Get our constants 140 Real getTyre(void){return k_tyre;};141 Real getMu(void){return k_mu;};142 Real getCFM(void){return k_cfm;};143 Real getERP(void){return k_erp;};144 Ogre::Real getTyre(void){return k_tyre;}; 145 Ogre::Real getMu(void){return k_mu;}; 146 Ogre::Real getCFM(void){return k_cfm;}; 147 Ogre::Real getERP(void){return k_erp;}; 144 148 145 149 // Static function for ODE to call when collisions (potentially) occur
Note: See TracChangeset
for help on using the changeset viewer.