SuperTuxKart
Loading...
Searching...
No Matches
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.
 
void reset ()
 Resets the kart before a (re)start, to make sure all physics variable are properly defined.
 
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.
 
void setAllBrakes (btScalar brake)
 
void updateSuspension (btScalar deltaTime)
 
virtual void updateFriction (btScalar timeStep)
 
void setSliding (bool active)
 Enables or disables sliding.
 
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.
 
void updateAllWheelPositions ()
 
void getVisualContactPoint (const btTransform &chassis_trans, btVector3 *left, btVector3 *right)
 Returns the contact point of a visual wheel.
 
bool visualWheelsTouchGround () const
 Returns true if both rear visual wheels touch the ground.
 
virtual void updateAction (btCollisionWorld *collisionWorld, btScalar step)
 btActionInterface interface.
 
int getNumWheels () const
 Returns the number of wheels of this vehicle.
 
btRigidBody * getRigidBody ()
 Returns the chassis (rigid) body.
 
const btRigidBody * getRigidBody () const
 Returns the chassis (rigid) body.
 
int getRightAxis () const
 Returns the index of the right axis.
 
int getUpAxis () const
 Returns the index of the up axis.
 
int getForwardAxis () const
 Returns the index of the forward axis.
 
int getUserConstraintType () const
 Backwards compatibility.
 
void setUserConstraintType (int userConstraintType)
 
void setUserConstraintId (int uid)
 
int getUserConstraintId () const
 
unsigned int getNumWheelsOnGround () const
 Returns the number of wheels on the ground.
 
void setTimedCentralImpulse (uint16_t t, const btVector3 &imp, bool rewind=false)
 Sets an impulse that is applied for a certain amount of time.
 
uint16_t getCentralImpulseTicks () const
 Returns the time an additional impulse is activated.
 
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).
 
float getTimedRotation () const
 
uint16_t getTimedRotationTicks () const
 
void setMaxSpeed (float new_max_speed)
 Sets the maximum speed for this kart.
 
virtual void resetMaxSpeed ()
 Resets the maximum so any new maximum value from the application will be accepted.
 
void setMinSpeed (float s)
 Sets the minimum speed for this kart.
 
btScalar getMinSpeed () const
 Returns the minimum speed for this kart.
 

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.
 
btVector3 m_additional_impulse
 An additional impulse that is applied for a certain amount of time.
 
uint16_t m_ticks_additional_impulse
 The time the additional impulse should be applied.
 
float m_additional_rotation
 Additional rotation in y-axis that is applied over a certain amount of time.
 
uint16_t m_ticks_additional_rotation
 Duration over which the additional rotation is applied.
 
btRigidBody * m_chassisBody
 The rigid body that is the chassis of the kart.
 
btRigidBody m_fixed_body
 Used to replace the ground object.
 
int m_num_wheels_on_ground
 Number of wheels that touch the ground.
 
int m_indexRightAxis
 Index of the right axis.
 
int m_indexUpAxis
 Index of the up axis.
 
int m_indexForwardAxis
 Index of the forward axis.
 
Kartm_kart
 The STK kart object which uses this vehicle.
 
btScalar m_min_speed
 Minimum speed for the kart.
 
btScalar m_max_speed
 Maximum speed for the kart.
 
bool m_visual_wheels_touch_ground
 True if the visual wheels touch the ground.
 
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.

◆ 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.

◆ 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.

◆ 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).

Member Data Documentation

◆ 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_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).


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