Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/ogrebullet/Dynamics/Constraints/OgreBulletDynamicsRaycastVehicle.h @ 2122

Last change on this file since 2122 was 2119, checked in by rgrieder, 16 years ago

Merged physics branch into physics_new branch.

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/***************************************************************************
2
3This source file is part of OGREBULLET
4(Object-oriented Graphics Rendering Engine Bullet Wrapper)
5For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
6
7Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
8
9
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GPL General Public License with runtime exception as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
19
20You should have received a copy of the GPL General Public License with runtime exception along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24-----------------------------------------------------------------------------
25*/
26#ifndef _OGREBULLETDYNAMICS_RaycastVehicle_H
27#define _OGREBULLETDYNAMICS_RaycastVehicle_H
28
29#include "OgreBulletDynamicsPreRequisites.h"
30
31#include "OgreBulletDynamicsConstraint.h"
32
33
34namespace OgreBulletDynamics
35{
36
37    // -------------------------------------------------------------------------
38    // VehicleRayCaster  class
39    class VehicleRayCaster
40    {
41    public:
42        VehicleRayCaster(DynamicsWorld *world);
43        virtual ~VehicleRayCaster();
44       
45        btVehicleRaycaster *getBulletVehicleRayCaster()
46        {return static_cast <btVehicleRaycaster*> (mBulletVehicleRayCaster);};
47         
48    private:
49        btDefaultVehicleRaycaster *mBulletVehicleRayCaster;       
50    };
51    // -------------------------------------------------------------------------
52    // VehicleTuning  class
53    class VehicleTuning
54    {
55    public:
56        VehicleTuning(
57            const Ogre::Real suspensionStiffness,
58            const Ogre::Real suspensionCompression,
59            const Ogre::Real suspensionDamping,
60            const Ogre::Real maxSuspensionTravelCm,
61            const Ogre::Real frictionSlip);
62        virtual ~VehicleTuning();
63       
64        btRaycastVehicle::btVehicleTuning *getBulletTuning()
65        {return mBulletTuning;};
66       
67    private:
68        btRaycastVehicle::btVehicleTuning *mBulletTuning;       
69    };
70    // -------------------------------------------------------------------------
71    // RaycastVehicle  class
72    class WheelInfo
73    {
74    public:
75        WheelInfo(btWheelInfo &w): 
76          mWheel(&w)
77          {};
78        virtual ~WheelInfo(){};
79
80        btWheelInfo *getBulletWheelInfo(){return static_cast<btWheelInfo *> (mWheel);}
81       
82    protected:
83        btWheelInfo                   *mWheel;
84    };
85    // -------------------------------------------------------------------------
86    // RaycastVehicle  class
87    class RaycastVehicle : public TypedConstraint
88    {
89    public:
90        RaycastVehicle(WheeledRigidBody *body, 
91            VehicleTuning        *vt,
92            VehicleRayCaster     *caster = 0);
93
94        virtual ~RaycastVehicle();
95
96        btRaycastVehicle *getBulletVehicle()
97        {return static_cast<btRaycastVehicle *> (mConstraint);};
98        void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex);
99
100        void addWheel(
101            Ogre::SceneNode *node,
102            const Ogre::Vector3 &connectionPoint,
103            const Ogre::Vector3 &wheelDirection,
104            const Ogre::Vector3 &wheelAxle,
105            const Ogre::Real suspensionRestLength,
106            const Ogre::Real wheelRadius,
107            const bool isFrontWheel,
108            const Ogre::Real wheelFriction,
109            const Ogre::Real rollInfluence);
110
111        // when all wheels are attached, make vehicle aware of it
112        void setWheelsAttached();
113        // update wheels when needed.
114        void setTransform();
115
116        void applyEngineForce (float engineForce, int wheel);
117        void setSteeringValue(float steering, int wheel);
118
119     protected:
120         VehicleTuning                   *mTuning;
121         VehicleRayCaster                *mRayCaster;
122   
123         std::vector<btWheelInfo *>         mWheelsInfo;
124         std::vector<Ogre::SceneNode *>      mWheelNodes;
125
126         WheeledRigidBody* mChassisBody;
127         Ogre::SceneNode *mNode;
128         
129    };
130}
131#endif //_OGREBULLETDYNAMICS_RaycastVehicle_H
132
Note: See TracBrowser for help on using the repository browser.