00001 /* 00002 * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/ 00003 * 00004 * Permission to use, copy, modify, distribute and sell this software 00005 * and its documentation for any purpose is hereby granted without fee, 00006 * provided that the above copyright notice appear in all copies. 00007 * Erwin Coumans makes no representations about the suitability 00008 * of this software for any purpose. 00009 * It is provided "as is" without express or implied warranty. 00010 */ 00011 #ifndef BT_WHEEL_INFO_H 00012 #define BT_WHEEL_INFO_H 00013 00014 #include "LinearMath/btVector3.h" 00015 #include "LinearMath/btTransform.h" 00016 00017 class btRigidBody; 00018 00019 struct btWheelInfoConstructionInfo 00020 { 00021 btVector3 m_chassisConnectionCS; 00022 btVector3 m_wheelDirectionCS; 00023 btVector3 m_wheelAxleCS; 00024 btScalar m_suspensionRestLength; 00025 btScalar m_maxSuspensionTravelCm; 00026 btScalar m_wheelRadius; 00027 00028 btScalar m_suspensionStiffness; 00029 btScalar m_wheelsDampingCompression; 00030 btScalar m_wheelsDampingRelaxation; 00031 btScalar m_frictionSlip; 00032 btScalar m_maxSuspensionForce; 00033 bool m_bIsFrontWheel; 00034 00035 }; 00036 00038 struct btWheelInfo 00039 { 00040 struct RaycastInfo 00041 { 00042 //set by raycaster 00043 btVector3 m_contactNormalWS;//contactnormal 00044 btVector3 m_contactPointWS;//raycast hitpoint 00045 btScalar m_suspensionLength; 00046 btVector3 m_hardPointWS;//raycast starting point 00047 btVector3 m_wheelDirectionWS; //direction in worldspace 00048 btVector3 m_wheelAxleWS; // axle in worldspace 00049 bool m_isInContact; 00050 void* m_groundObject; //could be general void* ptr 00051 }; 00052 00053 RaycastInfo m_raycastInfo; 00054 00055 btTransform m_worldTransform; 00056 00057 btVector3 m_chassisConnectionPointCS; //const 00058 btVector3 m_wheelDirectionCS;//const 00059 btVector3 m_wheelAxleCS; // const or modified by steering 00060 btScalar m_suspensionRestLength1;//const 00061 btScalar m_maxSuspensionTravelCm; 00062 btScalar getSuspensionRestLength() const; 00063 btScalar m_wheelsRadius;//const 00064 btScalar m_suspensionStiffness;//const 00065 btScalar m_wheelsDampingCompression;//const 00066 btScalar m_wheelsDampingRelaxation;//const 00067 btScalar m_frictionSlip; 00068 btScalar m_steering; 00069 btScalar m_rotation; 00070 btScalar m_deltaRotation; 00071 btScalar m_rollInfluence; 00072 btScalar m_maxSuspensionForce; 00073 00074 btScalar m_engineForce; 00075 00076 btScalar m_brake; 00077 00078 bool m_bIsFrontWheel; 00079 00080 void* m_clientInfo;//can be used to store pointer to sync transforms... 00081 00082 btWheelInfo(btWheelInfoConstructionInfo& ci) 00083 00084 { 00085 00086 m_suspensionRestLength1 = ci.m_suspensionRestLength; 00087 m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm; 00088 00089 m_wheelsRadius = ci.m_wheelRadius; 00090 m_suspensionStiffness = ci.m_suspensionStiffness; 00091 m_wheelsDampingCompression = ci.m_wheelsDampingCompression; 00092 m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation; 00093 m_chassisConnectionPointCS = ci.m_chassisConnectionCS; 00094 m_wheelDirectionCS = ci.m_wheelDirectionCS; 00095 m_wheelAxleCS = ci.m_wheelAxleCS; 00096 m_frictionSlip = ci.m_frictionSlip; 00097 m_steering = btScalar(0.); 00098 m_engineForce = btScalar(0.); 00099 m_rotation = btScalar(0.); 00100 m_deltaRotation = btScalar(0.); 00101 m_brake = btScalar(0.); 00102 m_rollInfluence = btScalar(0.1); 00103 m_bIsFrontWheel = ci.m_bIsFrontWheel; 00104 m_maxSuspensionForce = ci.m_maxSuspensionForce; 00105 00106 } 00107 00108 void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); 00109 00110 btScalar m_clippedInvContactDotSuspension; 00111 btScalar m_suspensionRelativeVelocity; 00112 //calculated by suspension 00113 btScalar m_wheelsSuspensionForce; 00114 btScalar m_skidInfo; 00115 00116 }; 00117 00118 #endif //BT_WHEEL_INFO_H 00119