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

This is a base object for any separate object on the track, which might also have a skeletal animation. More...

#include <track_object.hpp>

Public Member Functions

 TrackObject (const XMLNode &xml_node, scene::ISceneNode *parent, ModelDefinitionLoader &model_def_loader, TrackObject *parent_library)
 A track object: any additional object on the track.
 
 TrackObject (const core::vector3df &xyz, const core::vector3df &hpr, const core::vector3df &scale, const char *interaction, TrackObjectPresentation *presentation, bool is_dynamic, const PhysicalObject::Settings *physicsSettings)
 
virtual ~TrackObject ()
 Destructor.
 
virtual void update (float dt)
 This updates once per physics time step.
 
virtual void updateGraphics (float dt)
 This updates all only graphical elements.
 
virtual void resetAfterRewind ()
 This reset all physical object moved by 3d animation back to current ticks.
 
void move (const core::vector3df &xyz, const core::vector3df &hpr, const core::vector3df &scale, bool updateRigidBody, bool isAbsoluteCoord)
 
virtual void reset ()
 Initialises an object before a race starts.
 
const core::vector3df & getPosition () const
 
const core::vector3df getAbsolutePosition () const
 
const core::vector3df getAbsoluteCenterPosition () const
 
const core::vector3df & getRotation () const
 
const core::vector3df & getScale () const
 
bool castRay (const btVector3 &from, const btVector3 &to, btVector3 *hit_point, const Material **material, btVector3 *normal, bool interpolate_normal) const
 Does a raycast against the track object.
 
TrackObjectgetParentLibrary ()
 
virtual void onWorldReady ()
 To finish object constructions.
 
virtual void handleExplosion (const Vec3 &pos, bool directHit)
 Called when an explosion happens.
 
void setID (std::string obj_id)
 
const std::string & getLodGroup () const
 
const std::string & getType () const
 
const std::string getName () const
 
const std::string getID () const
 
const std::string getInteraction () const
 
bool isEnabled () const
 
bool isSoccerBall () const
 
const PhysicalObjectgetPhysicalObject () const
 
PhysicalObjectgetPhysicalObject ()
 
const core::vector3df getInitXYZ () const
 
const core::vector3df getInitRotation () const
 
const core::vector3df getInitScale () const
 
template<typename T >
T * getPresentation ()
 
template<typename T >
const T * getPresentation () const
 
scene::IAnimatedMeshSceneNode * getMesh ()
 Should only be used on mesh track objects.
 
TrackObjectPresentationParticlesgetParticleEmitter ()
 Should only be used on particle emitter track objects.
 
TrackObjectPresentationSoundgetSoundEmitter ()
 Should only be used on sound emitter track objects.
 
TrackObjectPresentationLightgetLight ()
 Should only be used on sound emitter track objects.
 
ThreeDAnimationgetIPOAnimator ()
 Should only be used on TrackObjects that use curve-based animation.
 
PhysicalObjectgetPhysics ()
 Get the physics representation of an object.
 
void setEnabled (bool mode)
 Hide or show the object.
 
void moveTo (const Scripting::SimpleVec3 *pos, bool isAbsoluteCoord)
 
void resetEnabled ()
 
ThreeDAnimationgetAnimator ()
 
const ThreeDAnimationgetAnimator () const
 
bool hasAnimatorRecursively () const
 
void setPaused (bool mode)
 
void setInitiallyVisible (bool val)
 
bool isDriveable () const
 Returns if a kart can drive on this object.
 
void addMovableChild (TrackObject *child)
 Used along the "extract movable nodes out of library objects" hack, used to still preserve the parent-child relationship.
 
void addChild (TrackObject *child)
 
std::vector< TrackObject * > & getMovableChildren ()
 
std::vector< TrackObject * > & getChildren ()
 
void movePhysicalBodyToGraphicalNode (const core::vector3df &xyz, const core::vector3df &hpr)
 
bool joinToMainTrack ()
 
TrackObjectcloneToChild ()
 

Protected Member Functions

void init (const XMLNode &xml_node, scene::ISceneNode *parent, ModelDefinitionLoader &model_def_loader, TrackObject *parent_library)
 Initialises the track object based on the specified XML data.
 

Protected Attributes

core::vector3df m_init_xyz
 The initial XYZ position of the object.
 
core::vector3df m_init_hpr
 The initial hpr of the object.
 
core::vector3df m_init_scale
 The initial scale of the object.
 
std::string m_lod_group
 LOD group this object is part of, if it is LOD.
 
std::string m_interaction
 
std::string m_type
 
bool m_soccer_ball
 
bool m_is_driveable
 True if a kart can drive on this object.
 
std::shared_ptr< PhysicalObjectm_physical_object
 
ThreeDAnimationm_animator
 
TrackObjectm_parent_library
 
std::vector< TrackObject * > m_movable_children
 
std::vector< TrackObject * > m_children
 
bool m_initially_visible
 
std::string m_visibility_condition
 

Private Attributes

bool m_enabled
 True if the object is currently being displayed.
 
TrackObjectPresentationm_presentation
 
std::string m_name
 
std::string m_id
 
std::shared_ptr< GE::GERenderInfo > m_render_info
 

Detailed Description

This is a base object for any separate object on the track, which might also have a skeletal animation.

This is used by objects that have an IPO animation, as well as physical objects.

Constructor & Destructor Documentation

◆ TrackObject() [1/2]

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

A track object: any additional object on the track.

This object implements a graphics-only representation, i.e. there is no physical representation. Derived classes can implement a physical representation (see physics/physical_object) or animations.

Parameters
xml_nodeThe xml node from which the initial data is taken. This is for now: initial position, initial rotation, name of the model, enable/disable status, timer information.
lod_nodeLod node (defaults to NULL).

◆ TrackObject() [2/2]

TrackObject::TrackObject ( const core::vector3df &  xyz,
const core::vector3df &  hpr,
const core::vector3df &  scale,
const char *  interaction,
TrackObjectPresentation presentation,
bool  is_dynamic,
const PhysicalObject::Settings physics_settings 
)
Parameters
is_dynamicOnly if interaction == 'movable', i.e. the object is affected by physics
physics_settingsIf interaction != 'ghost'

◆ ~TrackObject()

TrackObject::~TrackObject ( )
virtual

Destructor.

Removes the node from the scene graph, and also drops the textures of the mesh. Sound buffers are also freed.

Member Function Documentation

◆ castRay()

bool TrackObject::castRay ( const btVector3 &  from,
const btVector3 &  to,
btVector3 *  hit_point,
const Material **  material,
btVector3 *  normal,
bool  interpolate_normal 
) const

Does a raycast against the track object.

The object must have a physical object.

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.

◆ handleExplosion()

virtual void TrackObject::handleExplosion ( const Vec3 pos,
bool  directHit 
)
inlinevirtual

Called when an explosion happens.

As a default does nothing, will e.g. be overwritten by physical objects etc.

◆ init()

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

Initialises the track object based on the specified XML data.

Parameters
xml_nodeThe XML data.
parentThe parent scene node.
model_def_loaderUsed to load level-of-detail nodes.

◆ onWorldReady()

void TrackObject::onWorldReady ( )
virtual

To finish object constructions.

Called after the track model is ready.

◆ update()

void TrackObject::update ( float  dt)
virtual

This updates once per physics time step.

float dt Time since last rame.

◆ updateGraphics()

void TrackObject::updateGraphics ( float  dt)
virtual

This updates all only graphical elements.

It is only called once per rendered frame, not once per time step. float dt Time since last rame.

Member Data Documentation

◆ m_is_driveable

bool TrackObject::m_is_driveable
protected

True if a kart can drive on this object.

This will


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