Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/external/bullet/BulletDynamics/Vehicle/btRaycastVehicle.h

Last change on this file was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/*
2 * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
3 *
4 * Permission to use, copy, modify, distribute and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appear in all copies.
7 * Erwin Coumans makes no representations about the suitability
8 * of this software for any purpose. 
9 * It is provided "as is" without express or implied warranty.
10*/
11#ifndef RAYCASTVEHICLE_H
12#define RAYCASTVEHICLE_H
13
14#include "BulletDynamics/Dynamics/btRigidBody.h"
15#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
16#include "btVehicleRaycaster.h"
17class btDynamicsWorld;
18#include "LinearMath/btAlignedObjectArray.h"
19#include "btWheelInfo.h"
20#include "BulletDynamics/Dynamics/btActionInterface.h"
21
22class btVehicleTuning;
23
24///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
25class btRaycastVehicle : public btActionInterface
26{
27
28                btAlignedObjectArray<btVector3> m_forwardWS;
29                btAlignedObjectArray<btVector3> m_axle;
30                btAlignedObjectArray<btScalar>  m_forwardImpulse;
31                btAlignedObjectArray<btScalar>  m_sideImpulse;
32       
33                ///backwards compatibility
34                int     m_userConstraintType;
35                int     m_userConstraintId;
36
37public:
38        class btVehicleTuning
39                {
40                        public:
41
42                        btVehicleTuning()
43                                :m_suspensionStiffness(btScalar(5.88)),
44                                m_suspensionCompression(btScalar(0.83)),
45                                m_suspensionDamping(btScalar(0.88)),
46                                m_maxSuspensionTravelCm(btScalar(500.)),
47                                m_frictionSlip(btScalar(10.5)),
48                                m_maxSuspensionForce(btScalar(6000.))
49                        {
50                        }
51                        btScalar        m_suspensionStiffness;
52                        btScalar        m_suspensionCompression;
53                        btScalar        m_suspensionDamping;
54                        btScalar        m_maxSuspensionTravelCm;
55                        btScalar        m_frictionSlip;
56                        btScalar        m_maxSuspensionForce;
57
58                };
59private:
60
61        btScalar        m_tau;
62        btScalar        m_damping;
63        btVehicleRaycaster*     m_vehicleRaycaster;
64        btScalar                m_pitchControl;
65        btScalar        m_steeringValue; 
66        btScalar m_currentVehicleSpeedKmHour;
67
68        btRigidBody* m_chassisBody;
69
70        int m_indexRightAxis;
71        int m_indexUpAxis;
72        int     m_indexForwardAxis;
73
74        void defaultInit(const btVehicleTuning& tuning);
75
76public:
77
78        //constructor to create a car from an existing rigidbody
79        btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis,    btVehicleRaycaster* raycaster );
80
81        virtual ~btRaycastVehicle() ;
82
83
84        ///btActionInterface interface
85        virtual void updateAction( btCollisionWorld* collisionWorld, btScalar step)
86        {
87        (void) collisionWorld;
88                updateVehicle(step);
89        }
90       
91
92        ///btActionInterface interface
93        void    debugDraw(btIDebugDraw* debugDrawer);
94                       
95        const btTransform& getChassisWorldTransform() const;
96       
97        btScalar rayCast(btWheelInfo& wheel);
98
99        virtual void updateVehicle(btScalar step);
100       
101       
102        void resetSuspension();
103
104        btScalar        getSteeringValue(int wheel) const;
105
106        void    setSteeringValue(btScalar steering,int wheel);
107
108
109        void    applyEngineForce(btScalar force, int wheel);
110
111        const btTransform&      getWheelTransformWS( int wheelIndex ) const;
112
113        void    updateWheelTransform( int wheelIndex, bool interpolatedTransform = true );
114       
115        void    setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth);
116
117        btWheelInfo&    addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel);
118
119        inline int              getNumWheels() const {
120                return int (m_wheelInfo.size());
121        }
122       
123        btAlignedObjectArray<btWheelInfo>       m_wheelInfo;
124
125
126        const btWheelInfo&      getWheelInfo(int index) const;
127
128        btWheelInfo&    getWheelInfo(int index);
129
130        void    updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true);
131
132       
133        void setBrake(btScalar brake,int wheelIndex);
134
135        void    setPitchControl(btScalar pitch)
136        {
137                m_pitchControl = pitch;
138        }
139       
140        void    updateSuspension(btScalar deltaTime);
141
142        virtual void    updateFriction(btScalar timeStep);
143
144
145
146        inline btRigidBody* getRigidBody()
147        {
148                return m_chassisBody;
149        }
150
151        const btRigidBody* getRigidBody() const
152        {
153                return m_chassisBody;
154        }
155
156        inline int      getRightAxis() const
157        {
158                return m_indexRightAxis;
159        }
160        inline int getUpAxis() const
161        {
162                return m_indexUpAxis;
163        }
164
165        inline int getForwardAxis() const
166        {
167                return m_indexForwardAxis;
168        }
169
170       
171        ///Worldspace forward vector
172        btVector3 getForwardVector() const
173        {
174                const btTransform& chassisTrans = getChassisWorldTransform(); 
175
176                btVector3 forwardW ( 
177                          chassisTrans.getBasis()[0][m_indexForwardAxis], 
178                          chassisTrans.getBasis()[1][m_indexForwardAxis], 
179                          chassisTrans.getBasis()[2][m_indexForwardAxis]); 
180
181                return forwardW;
182        }
183
184        ///Velocity of vehicle (positive if velocity vector has same direction as foward vector)
185        btScalar        getCurrentSpeedKmHour() const
186        {
187                return m_currentVehicleSpeedKmHour;
188        }
189
190        virtual void    setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
191        {
192                m_indexRightAxis = rightIndex;
193                m_indexUpAxis = upIndex;
194                m_indexForwardAxis = forwardIndex;
195        }
196
197
198        ///backwards compatibility
199        int getUserConstraintType() const
200        {
201                return m_userConstraintType ;
202        }
203
204        void    setUserConstraintType(int userConstraintType)
205        {
206                m_userConstraintType = userConstraintType;
207        };
208
209        void    setUserConstraintId(int uid)
210        {
211                m_userConstraintId = uid;
212        }
213
214        int getUserConstraintId() const
215        {
216                return m_userConstraintId;
217        }
218
219};
220
221class btDefaultVehicleRaycaster : public btVehicleRaycaster
222{
223        btDynamicsWorld*        m_dynamicsWorld;
224public:
225        btDefaultVehicleRaycaster(btDynamicsWorld* world)
226                :m_dynamicsWorld(world)
227        {
228        }
229
230        virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result);
231
232};
233
234
235#endif //RAYCASTVEHICLE_H
236
Note: See TracBrowser for help on using the repository browser.