22 #ifndef __ND_BODY_PLAYER_CAPSULE_H__
23 #define __ND_BODY_PLAYER_CAPSULE_H__
25 #include "ndCollisionStdafx.h"
26 #include "ndBodyKinematicBase.h"
37 D_COLLISION_API
ndBodyPlayerCapsule(
const ndMatrix& localAxis, ndFloat32 mass, ndFloat32 radius, ndFloat32 height, ndFloat32 stepHeight);
42 ndFloat32 GetForwardSpeed()
const;
43 void SetForwardSpeed(ndFloat32 speed);
45 ndFloat32 GetLateralSpeed()
const;
46 void SetLateralSpeed(ndFloat32 speed);
48 ndFloat32 GetHeadingAngle()
const;
49 void SetHeadingAngle(ndFloat32 angle);
51 bool IsOnFloor()
const;
53 virtual void ApplyInputs(ndFloat32 timestep);
54 virtual ndFloat32 ContactFrictionCallback(
const ndVector& position,
const ndVector& normal, ndInt32 contactId,
const ndBodyKinematic*
const otherbody)
const;
64 virtual void IntegrateExternalForce(ndFloat32 timestep);
65 D_COLLISION_API
virtual void SpecialUpdate(ndFloat32 timestep);
75 void IntegrateVelocity(ndFloat32 timestep);
84 ndFloat32 m_headingAngle;
85 ndFloat32 m_forwardSpeed;
86 ndFloat32 m_lateralSpeed;
87 ndFloat32 m_stepHeight;
88 ndFloat32 m_contactPatch;
91 ndFloat32 m_weistScale;
92 ndFloat32 m_crouchScale;
96 } D_GCC_NEWTON_ALIGN_32;
103 inline void ndBodyPlayerCapsule::SetCollisionShape(
const ndShapeInstance&)
108 inline void ndBodyPlayerCapsule::ApplyInputs(ndFloat32)
114 return ndFloat32 (2.0f);
117 inline ndFloat32 ndBodyPlayerCapsule::GetForwardSpeed()
const
119 return -m_forwardSpeed;
122 inline void ndBodyPlayerCapsule::SetForwardSpeed(ndFloat32 speed)
124 m_forwardSpeed = -speed;
127 inline ndFloat32 ndBodyPlayerCapsule::GetLateralSpeed()
const
129 return -m_lateralSpeed;
132 inline void ndBodyPlayerCapsule::SetLateralSpeed(ndFloat32 speed)
134 m_lateralSpeed = -speed;
137 inline ndFloat32 ndBodyPlayerCapsule::GetHeadingAngle()
const
139 return m_headingAngle;
142 inline void ndBodyPlayerCapsule::SetHeadingAngle(ndFloat32 angle)
145 const ndFloat32 interpolation = ndFloat32(0.3f);
146 ndFloat32 deltaAngle = ndAnglesAdd(angle, -m_headingAngle) * interpolation;
147 ndFloat32 headingAngle = ndAnglesAdd(m_headingAngle, deltaAngle);
149 m_headingAngle = headingAngle;
152 inline void ndBodyPlayerCapsule::IntegrateVelocity(ndFloat32)
154 m_accel = ndVector::m_zero;
155 m_alpha = ndVector::m_zero;
158 inline bool ndBodyPlayerCapsule::IsOnFloor()
const
163 inline void ndBodyPlayerCapsule::IntegrateExternalForce(ndFloat32)