| [1963] | 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 | */ | 
|---|
| [8393] | 11 | #ifndef BT_WHEEL_INFO_H | 
|---|
|  | 12 | #define BT_WHEEL_INFO_H | 
|---|
| [1963] | 13 |  | 
|---|
|  | 14 | #include "LinearMath/btVector3.h" | 
|---|
|  | 15 | #include "LinearMath/btTransform.h" | 
|---|
|  | 16 |  | 
|---|
|  | 17 | class btRigidBody; | 
|---|
|  | 18 |  | 
|---|
|  | 19 | struct btWheelInfoConstructionInfo | 
|---|
|  | 20 | { | 
|---|
|  | 21 | btVector3       m_chassisConnectionCS; | 
|---|
|  | 22 | btVector3       m_wheelDirectionCS; | 
|---|
|  | 23 | btVector3       m_wheelAxleCS; | 
|---|
|  | 24 | btScalar        m_suspensionRestLength; | 
|---|
|  | 25 | btScalar        m_maxSuspensionTravelCm; | 
|---|
|  | 26 | btScalar        m_wheelRadius; | 
|---|
|  | 27 |  | 
|---|
|  | 28 | btScalar                m_suspensionStiffness; | 
|---|
|  | 29 | btScalar                m_wheelsDampingCompression; | 
|---|
|  | 30 | btScalar                m_wheelsDampingRelaxation; | 
|---|
|  | 31 | btScalar                m_frictionSlip; | 
|---|
| [8351] | 32 | btScalar                m_maxSuspensionForce; | 
|---|
| [1963] | 33 | bool m_bIsFrontWheel; | 
|---|
|  | 34 |  | 
|---|
|  | 35 | }; | 
|---|
|  | 36 |  | 
|---|
|  | 37 | /// btWheelInfo contains information per wheel about friction and suspension. | 
|---|
|  | 38 | struct btWheelInfo | 
|---|
|  | 39 | { | 
|---|
|  | 40 | struct RaycastInfo | 
|---|
|  | 41 | { | 
|---|
|  | 42 | //set by raycaster | 
|---|
|  | 43 | btVector3       m_contactNormalWS;//contactnormal | 
|---|
|  | 44 | btVector3       m_contactPointWS;//raycast hitpoint | 
|---|
|  | 45 | btScalar        m_suspensionLength; | 
|---|
|  | 46 | btVector3       m_hardPointWS;//raycast starting point | 
|---|
|  | 47 | btVector3       m_wheelDirectionWS; //direction in worldspace | 
|---|
|  | 48 | btVector3       m_wheelAxleWS; // axle in worldspace | 
|---|
|  | 49 | bool            m_isInContact; | 
|---|
|  | 50 | void*           m_groundObject; //could be general void* ptr | 
|---|
|  | 51 | }; | 
|---|
|  | 52 |  | 
|---|
|  | 53 | RaycastInfo     m_raycastInfo; | 
|---|
|  | 54 |  | 
|---|
|  | 55 | btTransform     m_worldTransform; | 
|---|
|  | 56 |  | 
|---|
|  | 57 | btVector3       m_chassisConnectionPointCS; //const | 
|---|
|  | 58 | btVector3       m_wheelDirectionCS;//const | 
|---|
|  | 59 | btVector3       m_wheelAxleCS; // const or modified by steering | 
|---|
|  | 60 | btScalar        m_suspensionRestLength1;//const | 
|---|
|  | 61 | btScalar        m_maxSuspensionTravelCm; | 
|---|
|  | 62 | btScalar getSuspensionRestLength() const; | 
|---|
|  | 63 | btScalar        m_wheelsRadius;//const | 
|---|
|  | 64 | btScalar        m_suspensionStiffness;//const | 
|---|
|  | 65 | btScalar        m_wheelsDampingCompression;//const | 
|---|
|  | 66 | btScalar        m_wheelsDampingRelaxation;//const | 
|---|
|  | 67 | btScalar        m_frictionSlip; | 
|---|
|  | 68 | btScalar        m_steering; | 
|---|
|  | 69 | btScalar        m_rotation; | 
|---|
|  | 70 | btScalar        m_deltaRotation; | 
|---|
|  | 71 | btScalar        m_rollInfluence; | 
|---|
| [8351] | 72 | btScalar        m_maxSuspensionForce; | 
|---|
| [1963] | 73 |  | 
|---|
|  | 74 | btScalar        m_engineForce; | 
|---|
|  | 75 |  | 
|---|
|  | 76 | btScalar        m_brake; | 
|---|
|  | 77 |  | 
|---|
|  | 78 | bool m_bIsFrontWheel; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | void*           m_clientInfo;//can be used to store pointer to sync transforms... | 
|---|
|  | 81 |  | 
|---|
|  | 82 | btWheelInfo(btWheelInfoConstructionInfo& ci) | 
|---|
|  | 83 |  | 
|---|
|  | 84 | { | 
|---|
|  | 85 |  | 
|---|
|  | 86 | m_suspensionRestLength1 = ci.m_suspensionRestLength; | 
|---|
|  | 87 | m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm; | 
|---|
|  | 88 |  | 
|---|
|  | 89 | m_wheelsRadius = ci.m_wheelRadius; | 
|---|
|  | 90 | m_suspensionStiffness = ci.m_suspensionStiffness; | 
|---|
|  | 91 | m_wheelsDampingCompression = ci.m_wheelsDampingCompression; | 
|---|
|  | 92 | m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation; | 
|---|
|  | 93 | m_chassisConnectionPointCS = ci.m_chassisConnectionCS; | 
|---|
|  | 94 | m_wheelDirectionCS = ci.m_wheelDirectionCS; | 
|---|
|  | 95 | m_wheelAxleCS = ci.m_wheelAxleCS; | 
|---|
|  | 96 | m_frictionSlip = ci.m_frictionSlip; | 
|---|
|  | 97 | m_steering = btScalar(0.); | 
|---|
|  | 98 | m_engineForce = btScalar(0.); | 
|---|
|  | 99 | m_rotation = btScalar(0.); | 
|---|
|  | 100 | m_deltaRotation = btScalar(0.); | 
|---|
|  | 101 | m_brake = btScalar(0.); | 
|---|
|  | 102 | m_rollInfluence = btScalar(0.1); | 
|---|
|  | 103 | m_bIsFrontWheel = ci.m_bIsFrontWheel; | 
|---|
| [8351] | 104 | m_maxSuspensionForce = ci.m_maxSuspensionForce; | 
|---|
| [1963] | 105 |  | 
|---|
|  | 106 | } | 
|---|
|  | 107 |  | 
|---|
|  | 108 | void    updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); | 
|---|
|  | 109 |  | 
|---|
|  | 110 | btScalar        m_clippedInvContactDotSuspension; | 
|---|
|  | 111 | btScalar        m_suspensionRelativeVelocity; | 
|---|
|  | 112 | //calculated by suspension | 
|---|
|  | 113 | btScalar        m_wheelsSuspensionForce; | 
|---|
|  | 114 | btScalar        m_skidInfo; | 
|---|
|  | 115 |  | 
|---|
|  | 116 | }; | 
|---|
|  | 117 |  | 
|---|
| [8393] | 118 | #endif //BT_WHEEL_INFO_H | 
|---|
| [1963] | 119 |  | 
|---|