SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Attributes | List of all members
TrackObjectManager Class Reference

Public Member Functions

void reset ()
 Initialises all track objects.
 
void init ()
 Initialises all track objects.
 
void add (const XMLNode &xml_node, scene::ISceneNode *parent, ModelDefinitionLoader &model_def_loader, TrackObject *parent_library)
 Adds an object to the track object manager.
 
void updateGraphics (float dt)
 Updates all track objects.
 
void update (float dt)
 Updates all track objects.
 
void resetAfterRewind ()
 
void handleExplosion (const Vec3 &pos, const PhysicalObject *mp, bool secondary_hits=true)
 Handles an explosion, i.e.
 
bool castRay (const btVector3 &from, const btVector3 &to, btVector3 *hit_point, const Material **material, btVector3 *normal=NULL, bool interpolate_normal=false) const
 Does a raycast against all driveable objects.
 
void insertObject (TrackObject *object)
 
void insertDriveableObject (TrackObject *object)
 
void removeObject (TrackObject *who)
 Removes the object from the scene graph, bullet, and the list of track objects, and then frees the object.
 
void removeDriveableObject (TrackObject *obj)
 
TrackObjectgetTrackObject (const std::string &libraryInstance, const std::string &name)
 returns a reference to the track object with a particular ID
 
PtrVector< TrackObject > & getObjects ()
 
const PtrVector< TrackObject > & getObjects () const
 

Protected Types

enum  TrackObjectType { TO_PHYSICAL , TO_GRAPHICAL }
 The different type of track objects: physical objects, graphical objects (without a physical representation) - the latter might be eye candy (to reduce work for physics), ...
 

Protected Attributes

PtrVector< TrackObjectm_all_objects
 The list of all track objects.
 
PtrVector< TrackObject, REF > m_driveable_objects
 A second list which holds all objects that karts can drive on.
 

Member Function Documentation

◆ add()

void TrackObjectManager::add ( const XMLNode xml_node,
scene::ISceneNode *  parent,
ModelDefinitionLoader model_def_loader,
TrackObject parent_library 
)

Adds an object to the track object manager.

The type to add is specified in the xml_node.

◆ castRay()

bool TrackObjectManager::castRay ( const btVector3 &  from,
const btVector3 &  to,
btVector3 *  hit_point,
const Material **  material,
btVector3 *  normal = NULL,
bool  interpolate_normal = false 
) const

Does a raycast against all driveable objects.

This way part of the track can be a physical object, and can e.g. be animated. A separate list of all driveable objects is maintained (in one case there were over 2000 bodies, but only one is driveable). The result of the raycast against the track mesh are the input parameter. It is then tested if the raycast against a track object gives a 'closer' result. If so, the parameters hit_point, normal, and material will be updated.

Parameters
from/toThe from and to position for the raycast.
xyzThe position in world where the ray hit.
materialThe material of the mesh that was hit.
normalThe intrapolated normal at that position.
interpolate_normalIf true, the returned normal is the interpolated based on the three normals of the triangle and the location of the hit point (which is more compute intensive, but results in much smoother results).
Returns
True if a triangle was hit, false otherwise (and no output variable will be set.

◆ getTrackObject()

TrackObject * TrackObjectManager::getTrackObject ( const std::string &  libraryInstance,
const std::string &  name 
)

returns a reference to the track object with a particular ID

Parameters
nameName or ID of track object

◆ handleExplosion()

void TrackObjectManager::handleExplosion ( const Vec3 pos,
const PhysicalObject mp,
bool  secondary_hits = true 
)

Handles an explosion, i.e.

it makes sure that all physical objects are affected accordingly.

Parameters
posPosition of the explosion.
objIf the hit was a physical object, this object will be affected more. Otherwise this is NULL.
secondary_hitsTrue if items that are not directly hit should also be affected.

◆ removeObject()

void TrackObjectManager::removeObject ( TrackObject obj)

Removes the object from the scene graph, bullet, and the list of track objects, and then frees the object.

Parameters
objThe physical object to remove.

◆ update()

void TrackObjectManager::update ( float  dt)

Updates all track objects.

Parameters
dtTime step size.

◆ updateGraphics()

void TrackObjectManager::updateGraphics ( float  dt)

Updates all track objects.

Parameters
dtTime step size.

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