19 #ifndef HEADER_TRACK_OBJECT_HPP 20 #define HEADER_TRACK_OBJECT_HPP 24 #include "physics/physical_object.hpp" 25 #include "scriptengine/scriptvec3.hpp" 26 #include "tracks/track_object_presentation.hpp" 27 #include "utils/cpp2011.hpp" 28 #include "utils/vec3.hpp" 30 #include "animations/three_d_animation.hpp" 63 std::shared_ptr<RenderInfo> m_render_info;
79 std::string m_interaction;
88 std::shared_ptr<PhysicalObject> m_physical_object;
94 std::vector<TrackObject*> m_movable_children;
95 std::vector<TrackObject*> m_children;
97 bool m_initially_visible;
99 std::string m_visibility_condition;
101 void init(
const XMLNode &xml_node, scene::ISceneNode* parent,
107 scene::ISceneNode* parent,
112 const core::vector3df& hpr,
113 const core::vector3df& scale,
114 const char* interaction,
119 virtual void update(
float dt);
122 void move(
const core::vector3df& xyz,
const core::vector3df& hpr,
123 const core::vector3df& scale,
bool updateRigidBody,
124 bool isAbsoluteCoord);
126 virtual void reset();
127 const core::vector3df& getPosition()
const;
128 const core::vector3df getAbsolutePosition()
const;
129 const core::vector3df getAbsoluteCenterPosition()
const;
130 const core::vector3df& getRotation()
const;
131 const core::vector3df& getScale()
const;
132 bool castRay(
const btVector3 &from,
133 const btVector3 &to, btVector3 *hit_point,
134 const Material **material, btVector3 *normal,
135 bool interpolate_normal)
const;
139 return m_parent_library;
150 void setID(std::string obj_id) { m_id = obj_id; }
153 const std::string& getLodGroup()
const {
return m_lod_group; }
155 const std::string& getType()
const {
return m_type; }
157 const std::string getName()
const {
return m_name; }
159 const std::string getID()
const {
return m_id; }
161 const std::string getInteraction()
const {
return m_interaction; }
163 bool isEnabled()
const {
return m_enabled; }
165 bool isSoccerBall()
const {
return m_soccer_ball; }
168 {
return m_physical_object.get(); }
170 PhysicalObject* getPhysicalObject() {
return m_physical_object.get(); }
172 const core::vector3df getInitXYZ()
const {
return m_init_xyz; }
174 const core::vector3df getInitRotation()
const {
return m_init_hpr; }
176 const core::vector3df getInitScale()
const {
return m_init_scale; }
179 T* getPresentation() {
return dynamic_cast<T*
>(m_presentation); }
182 const T* getPresentation()
const {
return dynamic_cast<T*
>(m_presentation); }
196 scene::IAnimatedMeshSceneNode*
getMesh();
234 bool hasAnimatorRecursively()
const 238 if (!m_parent_library)
240 return m_parent_library->hasAnimatorRecursively();
243 void setPaused(
bool mode){ m_animator->setPaused(mode); }
245 void setInitiallyVisible(
bool val) { m_initially_visible = val; }
257 std::vector<TrackObject*>& getMovableChildren() {
return m_movable_children; }
259 std::vector<TrackObject*>& getChildren() {
return m_children; }
261 void movePhysicalBodyToGraphicalNode(
const core::vector3df& xyz,
const core::vector3df& hpr);
263 bool joinToMainTrack();
bool isDriveable() const
Returns if a kart can drive on this object.
Definition: track_object.hpp:248
void addMovableChild(TrackObject *child)
Used along the "extract movable nodes out of library objects" hack, used to still preserve the parent...
Definition: track_object.cpp:690
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.
Definition: track_object.cpp:103
virtual void updateGraphics(float dt)
This updates all only graphical elements.
Definition: track_object.cpp:540
virtual ~TrackObject()
Destructor.
Definition: track_object.cpp:464
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
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.
Definition: track_object.cpp:587
ThreeDAnimation * getIPOAnimator()
Should only be used on TrackObjects that use curve-based animation.
Definition: track_object.hpp:213
scene::IAnimatedMeshSceneNode * getMesh()
Should only be used on mesh track objects.
Definition: track_object.cpp:719
virtual void reset()
Initialises an object before a race starts.
Definition: track_object.cpp:473
virtual void onWorldReady()
To finish object constructions.
Definition: track_object.cpp:398
TrackObjectPresentationLight * getLight()
Should only be used on sound emitter track objects.
Definition: track_object.hpp:208
bool m_enabled
True if the object is currently being displayed.
Definition: track_object.hpp:55
A track object representation that consists of a sound emitter.
Definition: track_object_presentation.hpp:276
Definition: script_track.cpp:250
TrackObjectPresentationSound * getSoundEmitter()
Should only be used on sound emitter track objects.
Definition: track_object.hpp:204
bool m_is_driveable
True if a kart can drive on this object.
Definition: track_object.hpp:86
std::string m_lod_group
LOD group this object is part of, if it is LOD.
Definition: track_object.hpp:77
Base class for all track object presentation classes.
Definition: track_object_presentation.hpp:57
virtual void update(float dt)
This updates once per physics time step.
Definition: track_object.cpp:551
TrackObject(const XMLNode &xml_node, scene::ISceneNode *parent, ModelDefinitionLoader &model_def_loader, TrackObject *parent_library)
A track object: any additional object on the track.
Definition: track_object.cpp:54
Definition: physical_object.hpp:38
A track object representation that consists of a particle emitter.
Definition: track_object_presentation.hpp:336
A track object representation that consists of a light emitter.
Definition: track_object_presentation.hpp:364
virtual void handleExplosion(const Vec3 &pos, bool directHit)
Called when an explosion happens.
Definition: track_object.hpp:149
Definition: physical_object.hpp:48
core::vector3df m_init_hpr
The initial hpr of the object.
Definition: track_object.hpp:71
Definition: material.hpp:47
virtual void resetAfterRewind()
This reset all physical object moved by 3d animation back to current ticks.
Definition: track_object.cpp:562
Definition: scriptvec3.hpp:28
utility class used to parse XML files
Definition: xml_node.hpp:47
core::vector3df m_init_scale
The initial scale of the object.
Definition: track_object.hpp:74
Definition: render_info.hpp:27
core::vector3df m_init_xyz
The initial XYZ position of the object.
Definition: track_object.hpp:68
A virtual base class for all animations.
Definition: three_d_animation.hpp:44
void setEnabled(bool mode)
Hide or show the object.
Definition: track_object.cpp:485
TrackObjectPresentationParticles * getParticleEmitter()
Should only be used on particle emitter track objects.
Definition: track_object.hpp:200
Utility class to load level-of-detail nodes and library nodes.
Definition: model_definition_loader.hpp:81
PhysicalObject * getPhysics()
Get the physics representation of an object.
Definition: track_object.hpp:218