SuperTuxKart
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
btKart Class Reference

rayCast vehicle, very special constraint that turn a rigidbody into a vehicle. More...

#include <btKart.hpp>

Inheritance diagram for btKart:
Inheritance graph
[legend]

Classes

class  btVehicleTuning
 

Public Member Functions

 btKart (btRigidBody *chassis, btVehicleRaycaster *raycaster, Kart *kart)
 Constructor to create a car from an existing rigidbody. More...
 
void reset ()
 Resets the kart before a (re)start, to make sure all physics variable are properly defined. More...
 
void debugDraw (btIDebugDraw *debugDrawer)
 
const btTransform & getChassisWorldTransform () const
 
btScalar rayCast (unsigned int index, float fraction=1.0f)
 
virtual void updateVehicle (btScalar step)
 
void resetSuspension ()
 
btScalar getSteeringValue (int wheel) const
 
void setSteeringValue (btScalar steering, int wheel)
 
void applyEngineForce (btScalar force, int wheel)
 
const btTransform & getWheelTransformWS (int wheelIndex) const
 
void updateWheelTransform (int wheelIndex, bool interpolatedTransform=true)
 
btWheelInfo & addWheel (const btVector3 &connectionPointCS0, const btVector3 &wheelDirectionCS0, const btVector3 &wheelAxleCS, btScalar suspensionRestLength, btScalar wheelRadius, const btVehicleTuning &tuning, bool isFrontWheel)
 
const btWheelInfo & getWheelInfo (int index) const
 
btWheelInfo & getWheelInfo (int index)
 
void updateAllWheelTransformsWS ()
 Updates all wheel transform informations. More...
 
void setAllBrakes (btScalar brake)
 
void updateSuspension (btScalar deltaTime)
 
virtual void updateFriction (btScalar timeStep)
 
void setSliding (bool active)
 Enables or disables sliding. More...
 
void instantSpeedIncreaseTo (btScalar speed)
 
void adjustSpeed (btScalar min_speed, btScalar max_speed)
 Adjusts the velocity of this kart to be at least the specified minimum, and less than or equal to the maximum. More...
 
void updateAllWheelPositions ()
 
void getVisualContactPoint (const btTransform &chassis_trans, btVector3 *left, btVector3 *right)
 Returns the contact point of a visual wheel. More...
 
bool visualWheelsTouchGround () const
 Returns true if both rear visual wheels touch the ground. More...
 
virtual void updateAction (btCollisionWorld *collisionWorld, btScalar step)
 btActionInterface interface. More...
 
int getNumWheels () const
 Returns the number of wheels of this vehicle. More...
 
btRigidBody * getRigidBody ()
 Returns the chassis (rigid) body. More...
 
const btRigidBody * getRigidBody () const
 Returns the chassis (rigid) body. More...
 
int getRightAxis () const
 Returns the index of the right axis. More...
 
int getUpAxis () const
 Returns the index of the up axis. More...
 
int getForwardAxis () const
 Returns the index of the forward axis. More...
 
int getUserConstraintType () const
 Backwards compatibility. More...
 
void setUserConstraintType (int userConstraintType)
 
void setUserConstraintId (int uid)
 
int getUserConstraintId () const
 
unsigned int getNumWheelsOnGround () const
 Returns the number of wheels on the ground. More...
 
void setTimedCentralImpulse (uint16_t t, const btVector3 &imp, bool rewind=false)
 Sets an impulse that is applied for a certain amount of time. More...
 
uint16_t getCentralImpulseTicks () const
 Returns the time an additional impulse is activated. More...
 
const btVector3 & getAdditionalImpulse () const
 
void setTimedRotation (uint16_t t, float rot_in_y_axis)
 Sets a rotation that is applied over a certain amount of time (to avoid a too rapid changes in the kart). More...
 
float getTimedRotation () const
 
uint16_t getTimedRotationTicks () const
 
void setMaxSpeed (float new_max_speed)
 Sets the maximum speed for this kart. More...
 
virtual void resetMaxSpeed ()
 Resets the maximum so any new maximum value from the application will be accepted. More...
 
void setMinSpeed (float s)
 Sets the minimum speed for this kart. More...
 
btScalar getMinSpeed () const
 Returns the minimum speed for this kart. More...
 

Private Member Functions

btScalar calcRollingFriction (btWheelContactPoint &contactPoint)
 
void defaultInit ()
 
btScalar rayCast (btWheelInfo &wheel, const btVector3 &ray)
 
void updateWheelTransformsWS (btWheelInfo &wheel, btTransform chassis_trans, bool interpolatedTransform=true, float fraction=1.0f)
 

Static Private Member Functions

static btRigidBody & getFixedBody ()
 

Private Attributes

btAlignedObjectArray< btVector3 > m_forwardWS
 
btAlignedObjectArray< btVector3 > m_axle
 
btAlignedObjectArray< btScalar > m_forwardImpulse
 
btAlignedObjectArray< btScalar > m_sideImpulse
 
int m_userConstraintType
 backwards compatibility
 
int m_userConstraintId
 
btScalar m_damping
 
btVehicleRaycaster * m_vehicleRaycaster
 
bool m_allow_sliding
 Sliding (skidding) will only be permited when this is true. More...
 
btVector3 m_additional_impulse
 An additional impulse that is applied for a certain amount of time. More...
 
uint16_t m_ticks_additional_impulse
 The time the additional impulse should be applied. More...
 
float m_additional_rotation
 Additional rotation in y-axis that is applied over a certain amount of time. More...
 
uint16_t m_ticks_additional_rotation
 Duration over which the additional rotation is applied. More...
 
btRigidBody * m_chassisBody
 The rigid body that is the chassis of the kart. More...
 
int m_num_wheels_on_ground
 Number of wheels that touch the ground. More...
 
int m_indexRightAxis
 Index of the right axis. More...
 
int m_indexUpAxis
 Index of the up axis. More...
 
int m_indexForwardAxis
 Index of the forward axis. More...
 
Kartm_kart
 The STK kart object which uses this vehicle. More...
 
btScalar m_min_speed
 Minimum speed for the kart. More...
 
btScalar m_max_speed
 Maximum speed for the kart. More...
 
bool m_visual_wheels_touch_ground
 True if the visual wheels touch the ground. More...
 
btAlignedObjectArray< btWheelInfo > m_wheelInfo
 

Detailed Description

rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.

Constructor & Destructor Documentation

◆ btKart()

btKart::btKart ( btRigidBody *  chassis,
btVehicleRaycaster *  raycaster,
Kart kart 
)

Constructor to create a car from an existing rigidbody.

Parameters
chassisThe rigid body to use as chassis.
raycasterThe raycast object to use. \paran kart The STK kart object that uses this vehicle (this is used to get access to the kart properties).

Member Function Documentation

◆ adjustSpeed()

void btKart::adjustSpeed ( btScalar  min_speed,
btScalar  max_speed 
)

Adjusts the velocity of this kart to be at least the specified minimum, and less than or equal to the maximum.

If necessary the kart will instantaneously change its speed.

Parameters
min_speedMinimum speed, 0 means no effect.
max_speedMaximum speed the kart is allowed to have.

◆ getCentralImpulseTicks()

uint16_t btKart::getCentralImpulseTicks ( ) const
inline

Returns the time an additional impulse is activated.

◆ getForwardAxis()

int btKart::getForwardAxis ( ) const
inline

Returns the index of the forward axis.

◆ getMinSpeed()

btScalar btKart::getMinSpeed ( ) const
inline

Returns the minimum speed for this kart.

◆ getNumWheels()

int btKart::getNumWheels ( ) const
inline

Returns the number of wheels of this vehicle.

◆ getNumWheelsOnGround()

unsigned int btKart::getNumWheelsOnGround ( ) const
inline

Returns the number of wheels on the ground.

◆ getRightAxis()

int btKart::getRightAxis ( ) const
inline

Returns the index of the right axis.

◆ getRigidBody() [1/2]

btRigidBody* btKart::getRigidBody ( )
inline

Returns the chassis (rigid) body.

◆ getRigidBody() [2/2]

const btRigidBody* btKart::getRigidBody ( ) const
inline

Returns the chassis (rigid) body.

◆ getUpAxis()

int btKart::getUpAxis ( ) const
inline

Returns the index of the up axis.

◆ getUserConstraintType()

int btKart::getUserConstraintType ( ) const
inline

Backwards compatibility.

◆ getVisualContactPoint()

void btKart::getVisualContactPoint ( const btTransform &  chassis_trans,
btVector3 *  left,
btVector3 *  right 
)

Returns the contact point of a visual wheel.

Parameters
nIndex of the wheel, must be 2 or 3 since only the two rear wheels define the visual position

◆ rayCast()

btScalar btKart::rayCast ( unsigned int  index,
float  fraction = 1.0f 
)
Todo:
for driving on dynamic/movable objects!;

◆ reset()

void btKart::reset ( )

Resets the kart before a (re)start, to make sure all physics variable are properly defined.

This is especially important for physics replay.

◆ resetMaxSpeed()

virtual void btKart::resetMaxSpeed ( )
inlinevirtual

Resets the maximum so any new maximum value from the application will be accepted.

◆ setMaxSpeed()

void btKart::setMaxSpeed ( float  new_max_speed)
inline

Sets the maximum speed for this kart.

◆ setMinSpeed()

void btKart::setMinSpeed ( float  s)
inline

Sets the minimum speed for this kart.

◆ setSliding()

void btKart::setSliding ( bool  active)

Enables or disables sliding.

Parameters
activeEnable (true) or disable sliding.

◆ setTimedCentralImpulse()

void btKart::setTimedCentralImpulse ( uint16_t  t,
const btVector3 &  imp,
bool  rewind = false 
)
inline

Sets an impulse that is applied for a certain amount of time.

Parameters
tTicks for the impulse to be active.
impThe impulse to apply.

◆ setTimedRotation()

void btKart::setTimedRotation ( uint16_t  t,
float  rot_in_y_axis 
)
inline

Sets a rotation that is applied over a certain amount of time (to avoid a too rapid changes in the kart).

Parameters
tTicks for the rotation to be applied.
rot_in_y_axisThe rotation in y-axis to apply.

◆ updateAction()

virtual void btKart::updateAction ( btCollisionWorld *  collisionWorld,
btScalar  step 
)
inlinevirtual

btActionInterface interface.

◆ updateAllWheelTransformsWS()

void btKart::updateAllWheelTransformsWS ( )

Updates all wheel transform informations.

This is used just after a rewind to update all m_hardPointWS (which is used by stk to determine the terrain under the kart).

◆ visualWheelsTouchGround()

bool btKart::visualWheelsTouchGround ( ) const
inline

Returns true if both rear visual wheels touch the ground.

Member Data Documentation

◆ m_additional_impulse

btVector3 btKart::m_additional_impulse
private

An additional impulse that is applied for a certain amount of time.

◆ m_additional_rotation

float btKart::m_additional_rotation
private

Additional rotation in y-axis that is applied over a certain amount of time.

◆ m_allow_sliding

bool btKart::m_allow_sliding
private

Sliding (skidding) will only be permited when this is true.

Also check the friction parameter in the wheels since friction directly affects skidding.

◆ m_chassisBody

btRigidBody* btKart::m_chassisBody
private

The rigid body that is the chassis of the kart.

◆ m_indexForwardAxis

int btKart::m_indexForwardAxis
private

Index of the forward axis.

◆ m_indexRightAxis

int btKart::m_indexRightAxis
private

Index of the right axis.

◆ m_indexUpAxis

int btKart::m_indexUpAxis
private

Index of the up axis.

◆ m_kart

Kart* btKart::m_kart
private

The STK kart object which uses this vehicle.

This is mostly used to get access to the kart properties, which also define physics properties.

◆ m_max_speed

btScalar btKart::m_max_speed
private

Maximum speed for the kart.

It is reset to -1 at the end of each physics steps, so need to be set again by the application.

◆ m_min_speed

btScalar btKart::m_min_speed
private

Minimum speed for the kart.

Used e.g. for zippers. Setting this value will potentially instantaneously accelerate the kart to the minimum speed requested (in the next physics step).

◆ m_num_wheels_on_ground

int btKart::m_num_wheels_on_ground
private

Number of wheels that touch the ground.

◆ m_ticks_additional_impulse

uint16_t btKart::m_ticks_additional_impulse
private

The time the additional impulse should be applied.

◆ m_ticks_additional_rotation

uint16_t btKart::m_ticks_additional_rotation
private

Duration over which the additional rotation is applied.

◆ m_visual_wheels_touch_ground

bool btKart::m_visual_wheels_touch_ground
private

True if the visual wheels touch the ground.


The documentation for this class was generated from the following files: