SuperTuxKart
|
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. | |
TrackObject * | getParentLibrary () |
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 PhysicalObject * | getPhysicalObject () const |
PhysicalObject * | getPhysicalObject () |
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. | |
TrackObjectPresentationParticles * | getParticleEmitter () |
Should only be used on particle emitter track objects. | |
TrackObjectPresentationSound * | getSoundEmitter () |
Should only be used on sound emitter track objects. | |
TrackObjectPresentationLight * | getLight () |
Should only be used on sound emitter track objects. | |
ThreeDAnimation * | getIPOAnimator () |
Should only be used on TrackObjects that use curve-based animation. | |
PhysicalObject * | getPhysics () |
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 () |
ThreeDAnimation * | getAnimator () |
const ThreeDAnimation * | getAnimator () 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 () |
TrackObject * | cloneToChild () |
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< PhysicalObject > | m_physical_object |
ThreeDAnimation * | m_animator |
TrackObject * | m_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. | |
TrackObjectPresentation * | m_presentation |
std::string | m_name |
std::string | m_id |
std::shared_ptr< GE::GERenderInfo > | m_render_info |
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.
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.
xml_node | The 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_node | Lod node (defaults to NULL). |
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 | ||
) |
is_dynamic | Only if interaction == 'movable', i.e. the object is affected by physics |
physics_settings | If interaction != 'ghost' |
|
virtual |
Destructor.
Removes the node from the scene graph, and also drops the textures of the mesh. Sound buffers are also freed.
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.
from/to | The from and to position for the raycast. |
xyz | The position in world where the ray hit. |
material | The material of the mesh that was hit. |
normal | The intrapolated normal at that position. |
interpolate_normal | If 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). |
|
inlinevirtual |
Called when an explosion happens.
As a default does nothing, will e.g. be overwritten by physical objects etc.
|
protected |
Initialises the track object based on the specified XML data.
xml_node | The XML data. |
parent | The parent scene node. |
model_def_loader | Used to load level-of-detail nodes. |
|
virtual |
To finish object constructions.
Called after the track model is ready.
|
virtual |
This updates once per physics time step.
float dt Time since last rame.
|
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.
|
protected |
True if a kart can drive on this object.
This will