SuperTuxKart
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. More...
 
void updateGraphics (float dt)
 Updates all track objects. More...
 
void update (float dt)
 Updates all track objects. More...
 
void resetAfterRewind ()
 
void handleExplosion (const Vec3 &pos, const PhysicalObject *mp, bool secondary_hits=true)
 Handles an explosion, i.e. More...
 
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. More...
 
void insertObject (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. More...
 
void removeDriveableObject (TrackObject *obj)
 
TrackObjectgetTrackObject (const std::string &libraryInstance, const std::string &name)
 returns a reference to the track object with a particular ID More...
 
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. More...
 
PtrVector< TrackObject, REF > m_driveable_objects
 A second list which holds all objects that karts can drive on. More...
 

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.

Member Data Documentation

◆ m_all_objects

PtrVector<TrackObject> TrackObjectManager::m_all_objects
protected

The list of all track objects.

◆ m_driveable_objects

PtrVector<TrackObject, REF> TrackObjectManager::m_driveable_objects
protected

A second list which holds all objects that karts can drive on.


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