00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _OGREBULLETDYNAMICS_RaycastVehicle_H
00031 #define _OGREBULLETDYNAMICS_RaycastVehicle_H
00032
00033 #include "OgreBulletDynamicsPreRequisites.h"
00034
00035 #include "OgreBulletDynamicsConstraint.h"
00036
00037
00038 namespace OgreBulletDynamics
00039 {
00040
00041
00042
00043 class VehicleRayCaster
00044 {
00045 public:
00046 VehicleRayCaster(DynamicsWorld *world);
00047 virtual ~VehicleRayCaster();
00048
00049 btVehicleRaycaster *getBulletVehicleRayCaster()
00050 {return static_cast <btVehicleRaycaster*> (mBulletVehicleRayCaster);};
00051
00052 private:
00053 btDefaultVehicleRaycaster *mBulletVehicleRayCaster;
00054 };
00055
00056
00057 class VehicleTuning
00058 {
00059 public:
00060 VehicleTuning(
00061 const Ogre::Real suspensionStiffness,
00062 const Ogre::Real suspensionCompression,
00063 const Ogre::Real suspensionDamping,
00064 const Ogre::Real maxSuspensionTravelCm,
00065 const Ogre::Real frictionSlip);
00066 virtual ~VehicleTuning();
00067
00068 btRaycastVehicle::btVehicleTuning *getBulletTuning()
00069 {return mBulletTuning;};
00070
00071 private:
00072 btRaycastVehicle::btVehicleTuning *mBulletTuning;
00073 };
00074
00075
00076 class WheelInfo
00077 {
00078 public:
00079 WheelInfo(btWheelInfo &w):
00080 mWheel(&w)
00081 {};
00082 virtual ~WheelInfo(){};
00083
00084 btWheelInfo *getBulletWheelInfo(){return static_cast<btWheelInfo *> (mWheel);}
00085
00086 protected:
00087 btWheelInfo *mWheel;
00088 };
00089
00090
00091 class RaycastVehicle : public ActionInterface
00092 {
00093 public:
00094 RaycastVehicle(WheeledRigidBody *body,
00095 VehicleTuning *vt,
00096 VehicleRayCaster *caster = 0);
00097
00098 virtual ~RaycastVehicle();
00099
00100 btRaycastVehicle *getBulletVehicle()
00101 {return static_cast<btRaycastVehicle *> (mActionInterface);};
00102 void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex);
00103
00104 void addWheel(
00105 Ogre::SceneNode *node,
00106 const Ogre::Vector3 &connectionPoint,
00107 const Ogre::Vector3 &wheelDirection,
00108 const Ogre::Vector3 &wheelAxle,
00109 const Ogre::Real suspensionRestLength,
00110 const Ogre::Real wheelRadius,
00111 const bool isFrontWheel,
00112 const Ogre::Real wheelFriction,
00113 const Ogre::Real rollInfluence);
00114
00115
00116 void setWheelsAttached();
00117
00118 void setTransform();
00119
00120 void applyEngineForce (float engineForce, int wheel);
00121 void setSteeringValue(float steering, int wheel);
00122
00123 protected:
00124 VehicleTuning *mTuning;
00125 VehicleRayCaster *mRayCaster;
00126
00127 std::vector<btWheelInfo *> mWheelsInfo;
00128 std::vector<Ogre::SceneNode *> mWheelNodes;
00129
00130 WheeledRigidBody* mChassisBody;
00131 Ogre::SceneNode *mNode;
00132
00133 };
00134 }
00135 #endif //_OGREBULLETDYNAMICS_RaycastVehicle_H
00136