Cosmetic change for coding style (removed 2 unnecessary constructors).

This commit is contained in:
hiker 2015-03-01 22:46:03 +11:00
parent b7fb159de4
commit cab6149193
4 changed files with 351 additions and 307 deletions

View File

@ -199,9 +199,11 @@ void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
core::vector3df kart_rot(0, 90.0f, 0); core::vector3df kart_rot(0, 90.0f, 0);
core::vector3df kart_scale(KART_SCALE, KART_SCALE, KART_SCALE); core::vector3df kart_scale(KART_SCALE, KART_SCALE, KART_SCALE);
//FIXME: it's not ideal that both the track object and the presentation know the initial coordinates of the object //FIXME: it's not ideal that both the track object and the
TrackObjectPresentationSceneNode* presentation = new TrackObjectPresentationSceneNode( // presentation know the initial coordinates of the object
kart_main_node, kart_pos, kart_rot, kart_scale); TrackObjectPresentationSceneNode* presentation =
new TrackObjectPresentationSceneNode(kart_pos, kart_rot,
kart_scale, kart_main_node);
TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale, TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
"ghost", presentation, false /* isDynamic */, NULL /* physics settings */); "ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
tobjman->insertObject(tobj); tobjman->insertObject(tobj);

View File

@ -313,9 +313,11 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
core::vector3df kart_rot(0, 0, 0); core::vector3df kart_rot(0, 0, 0);
core::vector3df kart_scale(1.0f, 1.0f, 1.0f); core::vector3df kart_scale(1.0f, 1.0f, 1.0f);
//FIXME: it's not ideal that both the track object and the presentation know the initial coordinates of the object //FIXME: it's not ideal that both the track object and the presentation
TrackObjectPresentationSceneNode* presentation = new TrackObjectPresentationSceneNode( // know the initial coordinates of the object
kart_main_node, kart_pos, kart_rot, kart_scale); TrackObjectPresentationSceneNode* presentation =
new TrackObjectPresentationSceneNode(kart_pos, kart_rot, kart_scale,
kart_main_node);
TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale, TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
"ghost", presentation, false /* isDynamic */, NULL /* physics settings */); "ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
tobjman->insertObject(tobj); tobjman->insertObject(tobj);

View File

@ -35,29 +35,28 @@
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "items/item_manager.hpp" #include "items/item_manager.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "scriptengine/script_engine.hpp"
#include "states_screens/dialogs/race_paused_dialog.hpp" #include "states_screens/dialogs/race_paused_dialog.hpp"
#include "states_screens/dialogs/tutorial_message_dialog.hpp" #include "states_screens/dialogs/tutorial_message_dialog.hpp"
#include "tracks/model_definition_loader.hpp" #include "tracks/model_definition_loader.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "tracks/track_object_manager.hpp" #include "tracks/track_object_manager.hpp"
#include "scriptengine/script_engine.hpp"
#include <ISceneManager.h>
#include <IMeshSceneNode.h>
#include <ICameraSceneNode.h>
#include <IBillboardSceneNode.h> #include <IBillboardSceneNode.h>
#include <IParticleSystemSceneNode.h> #include <ICameraSceneNode.h>
#include <ILightSceneNode.h> #include <ILightSceneNode.h>
#include <IMeshManipulator.h> #include <IMeshManipulator.h>
#include <IMeshSceneNode.h>
#include <IParticleSystemSceneNode.h>
#include <ISceneManager.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentation::TrackObjectPresentation(const XMLNode& xml_node) TrackObjectPresentation::TrackObjectPresentation(const XMLNode& xml_node)
{ {
m_init_xyz = core::vector3df(0,0,0); m_init_xyz = core::vector3df(0,0,0);
m_init_hpr = core::vector3df(0,0,0); m_init_hpr = core::vector3df(0,0,0);
m_init_scale = core::vector3df(1,1,1); m_init_scale = core::vector3df(1,1,1);
if (!xml_node.get("xyz", &m_init_xyz )) if (!xml_node.get("xyz", &m_init_xyz ))
{ {
// support for old deprecated syntax // support for old deprecated syntax
@ -66,39 +65,40 @@ TrackObjectPresentation::TrackObjectPresentation(const XMLNode& xml_node)
xml_node.get("hpr", &m_init_hpr ); xml_node.get("hpr", &m_init_hpr );
xml_node.get("scale", &m_init_scale); xml_node.get("scale", &m_init_scale);
} } // TrackObjectPresentation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const core::vector3df& TrackObjectPresentationSceneNode::getPosition() const const core::vector3df& TrackObjectPresentationSceneNode::getPosition() const
{ {
if (m_node == NULL) return m_init_xyz; if (m_node == NULL) return m_init_xyz;
return m_node->getPosition(); return m_node->getPosition();
} } // getPosition
// ----------------------------------------------------------------------------
const core::vector3df TrackObjectPresentationSceneNode::getAbsolutePosition() const const core::vector3df TrackObjectPresentationSceneNode::getAbsolutePosition() const
{ {
if (m_node == NULL) return m_init_xyz; if (m_node == NULL) return m_init_xyz;
m_node->updateAbsolutePosition(); m_node->updateAbsolutePosition();
return m_node->getAbsolutePosition(); return m_node->getAbsolutePosition();
} } // getAbsolutePosition
// ----------------------------------------------------------------------------
const core::vector3df& TrackObjectPresentationSceneNode::getRotation() const const core::vector3df& TrackObjectPresentationSceneNode::getRotation() const
{ {
if (m_node == NULL) return m_init_hpr; if (m_node == NULL) return m_init_hpr;
return m_node->getRotation(); return m_node->getRotation();
} } // getRotation
// ----------------------------------------------------------------------------
const core::vector3df& TrackObjectPresentationSceneNode::getScale() const const core::vector3df& TrackObjectPresentationSceneNode::getScale() const
{ {
if (m_node == NULL) return m_init_scale; if (m_node == NULL) return m_init_scale;
return m_node->getScale(); return m_node->getScale();
} } // getScale
// ----------------------------------------------------------------------------
void TrackObjectPresentationSceneNode::move(const core::vector3df& xyz, const core::vector3df& hpr, void TrackObjectPresentationSceneNode::move(const core::vector3df& xyz,
const core::vector3df& hpr,
const core::vector3df& scale) const core::vector3df& scale)
{ {
if (m_node == NULL) return; if (m_node == NULL) return;
@ -106,7 +106,8 @@ void TrackObjectPresentationSceneNode::move(const core::vector3df& xyz, const co
if (m_node->getParent() != NULL) if (m_node->getParent() != NULL)
{ {
scene::ISceneNode* parent = m_node->getParent(); scene::ISceneNode* parent = m_node->getParent();
m_node->setPosition((xyz - parent->getAbsolutePosition()) / parent->getScale()); m_node->setPosition((xyz - parent->getAbsolutePosition())
/ parent->getScale());
} }
else else
{ {
@ -115,14 +116,16 @@ void TrackObjectPresentationSceneNode::move(const core::vector3df& xyz, const co
m_node->setRotation(hpr); m_node->setRotation(hpr);
m_node->setScale(scale); m_node->setScale(scale);
m_node->updateAbsolutePosition(); m_node->updateAbsolutePosition();
} } // move
// ----------------------------------------------------------------------------
void TrackObjectPresentationSceneNode::setEnable(bool enabled) void TrackObjectPresentationSceneNode::setEnable(bool enabled)
{ {
if (m_node != NULL) if (m_node != NULL)
m_node->setVisible(enabled); m_node->setVisible(enabled);
} } // setEnable
// ----------------------------------------------------------------------------
void TrackObjectPresentationSceneNode::reset() void TrackObjectPresentationSceneNode::reset()
{ {
if (m_node == NULL) return; if (m_node == NULL) return;
@ -130,30 +133,29 @@ void TrackObjectPresentationSceneNode::reset()
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
m_node->setRotation(m_init_hpr); m_node->setRotation(m_init_hpr);
m_node->setScale(m_init_scale); m_node->setScale(m_init_scale);
} } // reset
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationEmpty::TrackObjectPresentationEmpty(const XMLNode& xml_node)
TrackObjectPresentationEmpty::TrackObjectPresentationEmpty(const XMLNode& xml_node) : : TrackObjectPresentationSceneNode(xml_node)
TrackObjectPresentationSceneNode(xml_node)
{ {
m_node = irr_driver->getSceneManager()->addEmptySceneNode(); m_node = irr_driver->getSceneManager()->addEmptySceneNode();
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
m_node->setRotation(m_init_hpr); m_node->setRotation(m_init_hpr);
m_node->setScale(m_init_scale); m_node->setScale(m_init_scale);
} } // TrackObjectPresentationEmpty
// ----------------------------------------------------------------------------
TrackObjectPresentationEmpty::~TrackObjectPresentationEmpty() TrackObjectPresentationEmpty::~TrackObjectPresentationEmpty()
{ {
irr_driver->removeNode(m_node); irr_driver->removeNode(m_node);
} } // ~TrackObjectPresentationEmpty
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode( TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
const XMLNode& xml_node, const XMLNode& xml_node,
ModelDefinitionLoader& model_def_loader) : ModelDefinitionLoader& model_def_loader)
TrackObjectPresentationSceneNode(xml_node) : TrackObjectPresentationSceneNode(xml_node)
{ {
std::string name; std::string name;
xml_node.get("name", &name); xml_node.get("name", &name);
@ -174,7 +176,8 @@ TrackObjectPresentationSceneNode(xml_node)
libroot = file_manager->createXMLTree(lib_node_path); libroot = file_manager->createXMLTree(lib_node_path);
if (libroot == NULL) if (libroot == NULL)
{ {
Log::error("TrackObjectPresentationLibraryNode", "Cannot find library '%s'", lib_node_path.c_str()); Log::error("TrackObjectPresentationLibraryNode",
"Cannot find library '%s'", lib_node_path.c_str());
return; return;
} }
@ -201,7 +204,8 @@ TrackObjectPresentationSceneNode(xml_node)
{ {
libroot = model_def_loader.getLibraryNodes()[name]; libroot = model_def_loader.getLibraryNodes()[name];
assert(libroot != NULL); assert(libroot != NULL);
create_lod_definitions = false; // LOD definitions are already created, don't create them again // LOD definitions are already created, don't create them again
create_lod_definitions = false;
} }
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
@ -212,37 +216,40 @@ TrackObjectPresentationSceneNode(xml_node)
assert(libroot != NULL); assert(libroot != NULL);
World::getWorld()->getTrack()->loadObjects(libroot, lib_path, model_def_loader, World::getWorld()->getTrack()->loadObjects(libroot, lib_path, model_def_loader,
create_lod_definitions, m_node); create_lod_definitions, m_node);
} } // TrackObjectPresentationLibraryNode
// ----------------------------------------------------------------------------
TrackObjectPresentationLibraryNode::~TrackObjectPresentationLibraryNode() TrackObjectPresentationLibraryNode::~TrackObjectPresentationLibraryNode()
{ {
irr_driver->removeNode(m_node); irr_driver->removeNode(m_node);
} } // TrackObjectPresentationLibraryNode
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationLOD::TrackObjectPresentationLOD(const XMLNode& xml_node, TrackObjectPresentationLOD::TrackObjectPresentationLOD(const XMLNode& xml_node,
scene::ISceneNode* parent, ModelDefinitionLoader& model_def_loader) : scene::ISceneNode* parent,
TrackObjectPresentationSceneNode(xml_node) ModelDefinitionLoader& model_def_loader)
: TrackObjectPresentationSceneNode(xml_node)
{ {
m_node = model_def_loader.instanciateAsLOD(&xml_node, parent); m_node = model_def_loader.instanciateAsLOD(&xml_node, parent);
if (m_node == NULL) throw std::runtime_error("Cannot load LOD node"); if (m_node == NULL) throw std::runtime_error("Cannot load LOD node");
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
m_node->setRotation(m_init_hpr); m_node->setRotation(m_init_hpr);
m_node->setScale(m_init_scale); m_node->setScale(m_init_scale);
} } // TrackObjectPresentationLOD
// ----------------------------------------------------------------------------
TrackObjectPresentationLOD::~TrackObjectPresentationLOD() TrackObjectPresentationLOD::~TrackObjectPresentationLOD()
{ {
if (m_node) if (m_node)
irr_driver->removeNode(m_node); irr_driver->removeNode(m_node);
} } // TrackObjectPresentationLOD
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationMesh::TrackObjectPresentationMesh(
TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node, const XMLNode& xml_node,
bool enabled, scene::ISceneNode* parent) : bool enabled,
TrackObjectPresentationSceneNode(xml_node) scene::ISceneNode* parent)
: TrackObjectPresentationSceneNode(xml_node)
{ {
m_is_looped = false; m_is_looped = false;
m_mesh = NULL; m_mesh = NULL;
@ -257,7 +264,8 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
std::string render_pass; std::string render_pass;
xml_node.get("renderpass", &render_pass); xml_node.get("renderpass", &render_pass);
bool skeletal_animation = true; // for backwards compatibility, if unspecified assume there is // for backwards compatibility, if unspecified assume there is
bool skeletal_animation = true;
xml_node.get("skeletal-animation", &skeletal_animation); xml_node.get("skeletal-animation", &skeletal_animation);
if (render_pass == "skybox") if (render_pass == "skybox")
@ -265,9 +273,6 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
m_is_in_skybox = true; m_is_in_skybox = true;
} }
//std::string full_path =
// World::getWorld()->getTrack()->getTrackFile(model_name);
bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects || bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects ||
World::getWorld()->getIdent() == IDENT_CUTSCENE); World::getWorld()->getIdent() == IDENT_CUTSCENE);
bool displacing = false; bool displacing = false;
@ -275,13 +280,9 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
animated &= !displacing; animated &= !displacing;
if (animated) if (animated)
{
m_mesh = irr_driver->getAnimatedMesh(model_name); m_mesh = irr_driver->getAnimatedMesh(model_name);
}
else else
{
m_mesh = irr_driver->getMesh(model_name); m_mesh = irr_driver->getMesh(model_name);
}
if (!m_mesh) if (!m_mesh)
{ {
@ -289,35 +290,41 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(const XMLNode& xml_node
} }
if (!animated) if (!animated)
m_mesh = MeshTools::createMeshWithTangents(m_mesh, &MeshTools::isNormalMap); {
m_mesh = MeshTools::createMeshWithTangents(m_mesh,
init(&xml_node, parent, enabled); &MeshTools::isNormalMap);
} }
init(&xml_node, parent, enabled);
} // TrackObjectPresentationMesh
// ----------------------------------------------------------------------------
TrackObjectPresentationMesh::TrackObjectPresentationMesh( TrackObjectPresentationMesh::TrackObjectPresentationMesh(
scene::IAnimatedMesh* model, const core::vector3df& xyz, scene::IAnimatedMesh* model,
const core::vector3df& hpr, const core::vector3df& scale) : const core::vector3df& xyz,
TrackObjectPresentationSceneNode(xyz, hpr, scale) const core::vector3df& hpr,
const core::vector3df& scale)
: TrackObjectPresentationSceneNode(xyz, hpr, scale)
{ {
m_is_looped = false; m_is_looped = false;
m_is_in_skybox = false; m_is_in_skybox = false;
m_mesh = NULL; m_mesh = NULL;
m_node = NULL; m_node = NULL;
m_mesh = model; m_mesh = model;
init(NULL, NULL, true); init(NULL, NULL, true);
} } // TrackObjectPresentationMesh
// ----------------------------------------------------------------------------
TrackObjectPresentationMesh::TrackObjectPresentationMesh( TrackObjectPresentationMesh::TrackObjectPresentationMesh(
const std::string& model_file, const core::vector3df& xyz, const std::string& model_file,
const core::vector3df& hpr, const core::vector3df& scale) : const core::vector3df& xyz,
TrackObjectPresentationSceneNode(xyz, hpr, scale) const core::vector3df& hpr,
const core::vector3df& scale)
: TrackObjectPresentationSceneNode(xyz, hpr, scale)
{ {
m_is_looped = false; m_is_looped = false;
m_mesh = NULL; m_mesh = NULL;
m_node = NULL; m_node = NULL;
m_is_in_skybox = false; m_is_in_skybox = false;
bool animated = (UserConfigParams::m_graphical_effects || bool animated = (UserConfigParams::m_graphical_effects ||
World::getWorld()->getIdent() == IDENT_CUTSCENE); World::getWorld()->getIdent() == IDENT_CUTSCENE);
@ -326,14 +333,10 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
if (file_manager->fileExists(model_file)) if (file_manager->fileExists(model_file))
{ {
if (animated) if (animated)
{
m_mesh = irr_driver->getAnimatedMesh(model_file); m_mesh = irr_driver->getAnimatedMesh(model_file);
}
else else
{
m_mesh = irr_driver->getMesh(model_file); m_mesh = irr_driver->getMesh(model_file);
} }
}
if (!m_mesh) if (!m_mesh)
{ {
@ -341,11 +344,14 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
} }
init(NULL, NULL, true); init(NULL, NULL, true);
} } // TrackObjectPresentationMesh
void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled) // ----------------------------------------------------------------------------
void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
scene::ISceneNode* parent, bool enabled)
{ {
bool skeletal_animation = true; // for backwards compatibility, if unspecified assume there is // for backwards compatibility, if unspecified assume there is
bool skeletal_animation = true;
if(xml_node) if(xml_node)
xml_node->get("skeletal-animation", &skeletal_animation); xml_node->get("skeletal-animation", &skeletal_animation);
@ -374,7 +380,8 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
else if (animated) else if (animated)
{ {
scene::IAnimatedMeshSceneNode *node = scene::IAnimatedMeshSceneNode *node =
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh, m_model_file, parent); irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh,
m_model_file, parent);
m_node = node; m_node = node;
m_frame_start = node->getStartFrame(); m_frame_start = node->getStartFrame();
@ -400,13 +407,10 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
m_frame_start = 0; m_frame_start = 0;
m_frame_end = 0; m_frame_end = 0;
if (World::getWorld() != NULL && World::getWorld()->getTrack() != NULL && xml_node != NULL) if (World::getWorld() && World::getWorld()->getTrack() && xml_node)
World::getWorld()->getTrack()->handleAnimatedTextures(m_node, *xml_node); World::getWorld()->getTrack()
->handleAnimatedTextures(m_node, *xml_node);
} }
//#ifdef DEBUG
// std::string debug_name = model_name+" (track-object)";
// m_node->setName(debug_name.c_str());
//#endif
if(!enabled) if(!enabled)
m_node->setVisible(false); m_node->setVisible(false);
@ -414,8 +418,9 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
m_node->setRotation(m_init_hpr); m_node->setRotation(m_init_hpr);
m_node->setScale(m_init_scale); m_node->setScale(m_init_scale);
} } // init
// ----------------------------------------------------------------------------
TrackObjectPresentationMesh::~TrackObjectPresentationMesh() TrackObjectPresentationMesh::~TrackObjectPresentationMesh()
{ {
if (m_node) if (m_node)
@ -428,8 +433,9 @@ TrackObjectPresentationMesh::~TrackObjectPresentationMesh()
if(m_mesh->getReferenceCount()==1) if(m_mesh->getReferenceCount()==1)
irr_driver->removeMeshFromCache(m_mesh); irr_driver->removeMeshFromCache(m_mesh);
} }
} } // ~TrackObjectPresentationMesh
// ----------------------------------------------------------------------------
void TrackObjectPresentationMesh::reset() void TrackObjectPresentationMesh::reset()
{ {
if (m_node->getType()==scene::ESNT_ANIMATED_MESH) if (m_node->getType()==scene::ESNT_ANIMATED_MESH)
@ -451,8 +457,9 @@ void TrackObjectPresentationMesh::reset()
// last frame, even if looping is disabled // last frame, even if looping is disabled
a_node->setFrameLoop(m_frame_start, m_frame_end); a_node->setFrameLoop(m_frame_start, m_frame_end);
} }
} } // reset
// ----------------------------------------------------------------------------
int TrackObjectPresentationMesh::getCurrentFrame() int TrackObjectPresentationMesh::getCurrentFrame()
{ {
if (m_node->getType() == scene::ESNT_ANIMATED_MESH) if (m_node->getType() == scene::ESNT_ANIMATED_MESH)
@ -463,8 +470,9 @@ int TrackObjectPresentationMesh::getCurrentFrame()
return (int)a_node->getFrameNr(); return (int)a_node->getFrameNr();
} }
return -1; //Not a skeletal animation return -1; //Not a skeletal animation
} } // getCurrentFrame
// ----------------------------------------------------------------------------
void TrackObjectPresentationMesh::setCurrentFrame(int frame) void TrackObjectPresentationMesh::setCurrentFrame(int frame)
{ {
if (m_node->getType() == scene::ESNT_ANIMATED_MESH) if (m_node->getType() == scene::ESNT_ANIMATED_MESH)
@ -474,8 +482,13 @@ void TrackObjectPresentationMesh::setCurrentFrame(int frame)
a_node->setCurrentFrame((f32)frame); a_node->setCurrentFrame((f32)frame);
} }
} } // setCurrentFrame
// ----------------------------------------------------------------------------
/** Set custom loops, as well as pause by scripts.
* \param start Start frame.
* \param end End frame.
*/
void TrackObjectPresentationMesh::setLoop(int start, int end) void TrackObjectPresentationMesh::setLoop(int start, int end)
{ {
if (m_node->getType() == scene::ESNT_ANIMATED_MESH) if (m_node->getType() == scene::ESNT_ANIMATED_MESH)
@ -487,11 +500,11 @@ void TrackObjectPresentationMesh::setLoop(int start, int end)
// last frame, even if looping is disabled // last frame, even if looping is disabled
a_node->setFrameLoop(start, end); a_node->setFrameLoop(start, end);
} }
} } // setLoop
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationSound::TrackObjectPresentationSound(
const XMLNode& xml_node,
TrackObjectPresentationSound::TrackObjectPresentationSound(const XMLNode& xml_node,
scene::ISceneNode* parent) scene::ISceneNode* parent)
: TrackObjectPresentation(xml_node) : TrackObjectPresentation(xml_node)
{ {
@ -558,9 +571,9 @@ void TrackObjectPresentationSound::update(float dt)
{ {
if (m_sound != NULL) if (m_sound != NULL)
{ {
// muting when too far is implemented manually since not supported by OpenAL // muting when too far is implemented manually since not supported by
// so need to call this every frame to update the muting state if listener // OpenAL so need to call this every frame to update the muting state
// moved // if listener moved
m_sound->setPosition(m_xyz); m_sound->setPosition(m_xyz);
} }
} // update } // update
@ -609,8 +622,8 @@ void TrackObjectPresentationSound::move(const core::vector3df& xyz,
} // move } // move
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationBillboard::TrackObjectPresentationBillboard(
TrackObjectPresentationBillboard::TrackObjectPresentationBillboard(const XMLNode& xml_node, const XMLNode& xml_node,
scene::ISceneNode* parent) scene::ISceneNode* parent)
: TrackObjectPresentationSceneNode(xml_node) : TrackObjectPresentationSceneNode(xml_node)
{ {
@ -637,22 +650,26 @@ TrackObjectPresentationBillboard::TrackObjectPresentationBillboard(const XMLNode
irr_driver->getTexture(file_manager->searchTexture(texture_name)); irr_driver->getTexture(file_manager->searchTexture(texture_name));
if (texture == NULL) if (texture == NULL)
{ {
Log::warn("TrackObjectPresentation", "Billboard texture '%s' not found", texture_name.c_str()); Log::warn("TrackObjectPresentation", "Billboard texture '%s' not found",
texture_name.c_str());
} }
m_node = irr_driver->addBillboard(core::dimension2df(width, height), texture, parent); m_node = irr_driver->addBillboard(core::dimension2df(width, height),
texture, parent);
Material *stk_material = material_manager->getMaterial(texture_name); Material *stk_material = material_manager->getMaterial(texture_name);
stk_material->setMaterialProperties(&(m_node->getMaterial(0)), NULL); stk_material->setMaterialProperties(&(m_node->getMaterial(0)), NULL);
m_node->setPosition(m_init_xyz); m_node->setPosition(m_init_xyz);
} } // TrackObjectPresentationBillboard
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObjectPresentationBillboard::update(float dt) void TrackObjectPresentationBillboard::update(float dt)
{ {
if (m_fade_out_when_close) if (m_fade_out_when_close)
{ {
scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera(); scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()
const float dist = m_node->getAbsolutePosition().getDistanceFrom( curr_cam->getPosition() ); ->getActiveCamera();
const float dist = m_node->getAbsolutePosition()
.getDistanceFrom( curr_cam->getPosition() );
scene::IBillboardSceneNode* node = (scene::IBillboardSceneNode*)m_node; scene::IBillboardSceneNode* node = (scene::IBillboardSceneNode*)m_node;
@ -666,23 +683,25 @@ void TrackObjectPresentationBillboard::update(float dt)
} }
else else
{ {
int a = (int)(255*(dist - m_fade_out_start) / (m_fade_out_end - m_fade_out_start)); int a = (int)(255*(dist - m_fade_out_start)
/ (m_fade_out_end - m_fade_out_start));
node->setColor(video::SColor(a, 255, 255, 255)); node->setColor(video::SColor(a, 255, 255, 255));
} }
} } // m_fade_out_when_close
} } // update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationBillboard::~TrackObjectPresentationBillboard() TrackObjectPresentationBillboard::~TrackObjectPresentationBillboard()
{ {
if (m_node) if (m_node)
irr_driver->removeNode(m_node); irr_driver->removeNode(m_node);
} } // ~TrackObjectPresentationBillboard
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationParticles::TrackObjectPresentationParticles(
TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode& xml_node, scene::ISceneNode* parent) : const XMLNode& xml_node,
TrackObjectPresentationSceneNode(xml_node) scene::ISceneNode* parent)
: TrackObjectPresentationSceneNode(xml_node)
{ {
m_emitter = NULL; m_emitter = NULL;
m_lod_emitter_node = NULL; m_lod_emitter_node = NULL;
@ -692,12 +711,11 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode
int clip_distance = -1; int clip_distance = -1;
xml_node.get("clip_distance", &clip_distance); xml_node.get("clip_distance", &clip_distance);
xml_node.get("conditions", &m_trigger_condition); xml_node.get("conditions", &m_trigger_condition);
try try
{ {
ParticleKind* kind = ParticleKindManager::get()->getParticles( path.c_str() ); ParticleKind* kind = ParticleKindManager::get()->getParticles(path);
if (kind == NULL) if (kind == NULL)
{ {
throw std::runtime_error(path + " could not be loaded"); throw std::runtime_error(path + " could not be loaded");
@ -709,7 +727,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode
{ {
scene::ISceneManager* sm = irr_driver->getSceneManager(); scene::ISceneManager* sm = irr_driver->getSceneManager();
scene::ISceneNode* sroot = sm->getRootSceneNode(); scene::ISceneNode* sroot = sm->getRootSceneNode();
LODNode* lod = new LODNode("particles", parent == NULL ? sroot : parent, sm); LODNode* lod = new LODNode("particles", !parent ? sroot : parent, sm);
lod->add(clip_distance, (scene::ISceneNode*)emitter->getNode(), true); lod->add(clip_distance, (scene::ISceneNode*)emitter->getNode(), true);
m_node = lod; m_node = lod;
m_lod_emitter_node = lod; m_lod_emitter_node = lod;
@ -728,9 +746,10 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
Log::warn ("Track", "Could not load particles '%s'; cause :\n %s", path.c_str(), e.what()); Log::warn ("Track", "Could not load particles '%s'; cause :\n %s",
} path.c_str(), e.what());
} }
} // TrackObjectPresentationParticles
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationParticles::~TrackObjectPresentationParticles() TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
@ -744,7 +763,7 @@ TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
} }
delete m_emitter; // this will also delete m_node delete m_emitter; // this will also delete m_node
} }
} } // ~TrackObjectPresentationParticles
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObjectPresentationParticles::update(float dt) void TrackObjectPresentationParticles::update(float dt)
@ -753,7 +772,7 @@ void TrackObjectPresentationParticles::update(float dt)
{ {
m_emitter->update(dt); m_emitter->update(dt);
} }
} } // update
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObjectPresentationParticles::triggerParticles() void TrackObjectPresentationParticles::triggerParticles()
@ -763,12 +782,13 @@ void TrackObjectPresentationParticles::triggerParticles()
m_emitter->setCreationRateAbsolute(1.0f); m_emitter->setCreationRateAbsolute(1.0f);
m_emitter->setParticleType(m_emitter->getParticlesInfo()); m_emitter->setParticleType(m_emitter->getParticlesInfo());
} }
} } // triggerParticles
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationLight::TrackObjectPresentationLight(
TrackObjectPresentationLight::TrackObjectPresentationLight(const XMLNode& xml_node, scene::ISceneNode* parent) : const XMLNode& xml_node,
TrackObjectPresentationSceneNode(xml_node) scene::ISceneNode* parent)
: TrackObjectPresentationSceneNode(xml_node)
{ {
xml_node.get("color", &m_color); xml_node.get("color", &m_color);
const video::SColorf colorf(m_color); const video::SColorf colorf(m_color);
@ -781,31 +801,28 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(const XMLNode& xml_no
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
m_node = irr_driver->addLight(m_init_xyz, m_energy, m_distance, colorf.r, colorf.g, colorf.b, false, parent); m_node = irr_driver->addLight(m_init_xyz, m_energy, m_distance,
colorf.r, colorf.g, colorf.b, false,
parent);
} }
else else
{ {
m_node = NULL; // lights require shaders to work m_node = NULL; // lights require shaders to work
//scene::ILightSceneNode* node = irr_driver->getSceneManager()->addLightSceneNode(NULL, m_init_xyz, m_color, m_distance);
//node->setLightType(video::ELT_POINT);
//node->enableCastShadow(true);
//m_node = node;
}
} }
} // TrackObjectPresentationLight
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationLight::~TrackObjectPresentationLight() TrackObjectPresentationLight::~TrackObjectPresentationLight()
{ {
} } // ~TrackObjectPresentationLight
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(const XMLNode& xml_node) : const XMLNode& xml_node)
TrackObjectPresentation(xml_node) : TrackObjectPresentation(xml_node)
{ {
float trigger_distance = 1.0f; float trigger_distance = 1.0f;
xml_node.get("distance", &trigger_distance); xml_node.get("distance", &trigger_distance);
xml_node.get("action", &m_action ); xml_node.get("action", &m_action );
m_action_active = true; m_action_active = true;
@ -814,12 +831,13 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(const
Log::warn("TrackObject", "Action-trigger has no action defined."); Log::warn("TrackObject", "Action-trigger has no action defined.");
ItemManager::get()->newItem(m_init_xyz, trigger_distance, this); ItemManager::get()->newItem(m_init_xyz, trigger_distance, this);
} } // TrackObjectPresentationActionTrigger
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger const core::vector3df& xyz,
(const core::vector3df& xyz,std::string script_name, float distance) const std::string& script_name,
float distance)
: TrackObjectPresentation(xyz) : TrackObjectPresentation(xyz)
{ {
m_init_xyz = xyz; m_init_xyz = xyz;
@ -828,11 +846,10 @@ TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger
float trigger_distance = distance; float trigger_distance = distance;
m_action = script_name; m_action = script_name;
m_action_active = true; m_action_active = true;
ItemManager::get()->newItem(m_init_xyz, trigger_distance, this); ItemManager::get()->newItem(m_init_xyz, trigger_distance, this);
} } // TrackObjectPresentationActionTrigger
// ----------------------------------------------------------------------------
void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who) void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
{ {
if (!m_action_active) return; if (!m_action_active) return;
@ -846,7 +863,8 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
new RacePausedDialog(0.8f, 0.6f); new RacePausedDialog(0.8f, 0.6f);
//dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart(); //dynamic_cast<OverWorld*>(World::getWorld())->scheduleSelectKart();
} }
//action trigger near big doors in the overword to notify players that they'll open once they finish all the challenges //action trigger near big doors in the overword to notify players that
// they'll open once they finish all the challenges
else if (m_action == "big_door") else if (m_action == "big_door")
{ {
m_action_active = false; m_action_active = false;
@ -858,7 +876,8 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
// allow ONE unsolved challenge : the last one // allow ONE unsolved challenge : the last one
if (unlocked_challenges < m_challenges.size() - 1) if (unlocked_challenges < m_challenges.size() - 1)
{ {
new TutorialMessageDialog(_("Complete all challenges to unlock the big door!"), true); new TutorialMessageDialog(
_("Complete all challenges to unlock the big door!"), true);
} }
} }
else if (m_action == "tutorial_drive") else if (m_action == "tutorial_drive")
@ -868,13 +887,15 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
m_action_active = false; m_action_active = false;
//World::getWorld()->getRaceGUI()->clearAllMessages(); //World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw accel = config->getBindingAsString(PA_ACCEL); irr::core::stringw accel = config->getBindingAsString(PA_ACCEL);
irr::core::stringw left = config->getBindingAsString(PA_STEER_LEFT); irr::core::stringw left = config->getBindingAsString(PA_STEER_LEFT);
irr::core::stringw right = config->getBindingAsString(PA_STEER_RIGHT); irr::core::stringw right = config->getBindingAsString(PA_STEER_RIGHT);
new TutorialMessageDialog(_("Accelerate with <%s> and steer with <%s> and <%s>", accel, left, right), new TutorialMessageDialog(_("Accelerate with <%s> and steer with "
"<%s> and <%s>", accel, left, right),
false); false);
} }
} }
@ -887,17 +908,20 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
else if (m_action == "tutorial_giftboxes") else if (m_action == "tutorial_giftboxes")
{ {
m_action_active = false; m_action_active = false;
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw fire = config->getBindingAsString(PA_FIRE); irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
new TutorialMessageDialog(_("Collect gift boxes, and fire the weapon with <%s> to blow away these boxes!", fire), new TutorialMessageDialog(_("Collect gift boxes, and fire the weapon "
true); "with <%s> to blow away these boxes!",
fire),true);
} }
else if (m_action == "tutorial_backgiftboxes") else if (m_action == "tutorial_backgiftboxes")
{ {
m_action_active = false; m_action_active = false;
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw fire = config->getBindingAsString(PA_FIRE); irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
irr::core::stringw back = config->getBindingAsString(PA_LOOK_BACK); irr::core::stringw back = config->getBindingAsString(PA_LOOK_BACK);
@ -911,27 +935,30 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
{ {
m_action_active = false; m_action_active = false;
new TutorialMessageDialog(_("Collect nitro bottles (we will use them after the curve)"), new TutorialMessageDialog(_("Collect nitro bottles (we will use them "
true); "after the curve)"), true);
} }
else if (m_action == "tutorial_nitro_use") else if (m_action == "tutorial_nitro_use")
{ {
m_action_active = false; m_action_active = false;
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw nitro = config->getBindingAsString(PA_NITRO); irr::core::stringw nitro = config->getBindingAsString(PA_NITRO);
new TutorialMessageDialog(_("Use the nitro you collected by pressing <%s>!", nitro), new TutorialMessageDialog(_("Use the nitro you collected by "
true); "pressing <%s>!", nitro), true);
} }
else if (m_action == "tutorial_rescue") else if (m_action == "tutorial_rescue")
{ {
m_action_active = false; m_action_active = false;
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE); irr::core::stringw rescue = config->getBindingAsString(PA_RESCUE);
new TutorialMessageDialog(_("Oops! When you're in trouble, press <%s> to be rescued", rescue), new TutorialMessageDialog(_("Oops! When you're in trouble, press <%s> "
"to be rescued", rescue),
false); false);
} }
else if (m_action == "tutorial_skidding") else if (m_action == "tutorial_skidding")
@ -939,12 +966,16 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
m_action_active = false; m_action_active = false;
//World::getWorld()->getRaceGUI()->clearAllMessages(); //World::getWorld()->getRaceGUI()->clearAllMessages();
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); InputDevice* device = input_manager->getDeviceManager()
->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration(); DeviceConfig* config = device->getConfiguration();
irr::core::stringw skid = config->getBindingAsString(PA_DRIFT); irr::core::stringw skid = config->getBindingAsString(PA_DRIFT);
new TutorialMessageDialog(_("Accelerate and press the <%s> key while turning to skid. Skidding for a short while can help you turn faster to take sharp turns.", skid), new TutorialMessageDialog(_("Accelerate and press the <%s> key while "
"turning to skid. Skidding for a short "
"while can help you turn faster to take "
"sharp turns.", skid),
true); true);
} }
else if (m_action == "tutorial_skidding2") else if (m_action == "tutorial_skidding2")
@ -952,7 +983,9 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
m_action_active = false; m_action_active = false;
World::getWorld()->getRaceGUI()->clearAllMessages(); World::getWorld()->getRaceGUI()->clearAllMessages();
new TutorialMessageDialog(_("Note that if you manage to skid for several seconds, you will receive a bonus speedup as a reward!"), new TutorialMessageDialog(_("Note that if you manage to skid for "
"several seconds, you will receive a bonus "
"speedup as a reward!"),
true); true);
} }
else if (m_action == "tutorial_endmessage") else if (m_action == "tutorial_endmessage")
@ -971,7 +1004,8 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
else else
{ {
//TODO move all above functions into scripts and remove the ifs //TODO move all above functions into scripts and remove the ifs
Scripting::ScriptEngine* m_script_engine = World::getWorld()->getScriptEngine(); Scripting::ScriptEngine* m_script_engine =
World::getWorld()->getScriptEngine();
m_action_active = false; m_action_active = false;
m_script_engine->runScript(m_action); m_script_engine->runScript(m_action);
@ -982,7 +1016,4 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
*/ */
} }
} } // onTriggerItemApproached

View File

@ -20,32 +20,33 @@
#ifndef HEADER_TRACK_OBJECT_PRESENTATION_HPP #ifndef HEADER_TRACK_OBJECT_PRESENTATION_HPP
#define HEADER_TRACK_OBJECT_PRESENTATION_HPP #define HEADER_TRACK_OBJECT_PRESENTATION_HPP
#include <vector3d.h>
#include <IAnimatedMeshSceneNode.h>
namespace irr
{
namespace scene { class IAnimatedMesh; class IMeshSceneNode; class ISceneNode; }
}
using namespace irr;
#include "graphics/lod_node.hpp" #include "graphics/lod_node.hpp"
#include "items/item.hpp" #include "items/item.hpp"
#include "utils/cpp2011.hpp" #include "utils/cpp2011.hpp"
#include "utils/no_copy.hpp" #include "utils/no_copy.hpp"
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
#include <vector3d.h>
#include <IAnimatedMeshSceneNode.h>
#include <string> #include <string>
class XMLNode;
class SFXBase; class SFXBase;
class ParticleEmitter; class ParticleEmitter;
class PhysicalObject; class PhysicalObject;
class ThreeDAnimation; class ThreeDAnimation;
class ModelDefinitionLoader; class ModelDefinitionLoader;
class STKInstancedSceneNode; class STKInstancedSceneNode;
class XMLNode;
/** namespace irr
* \ingroup tracks {
* Base class for all track object presentation classes namespace scene { class IAnimatedMesh; class IMeshSceneNode; class ISceneNode; }
}
using namespace irr;
/** \ingroup tracks
* Base class for all track object presentation classes.
*/ */
class TrackObjectPresentation class TrackObjectPresentation
{ {
@ -64,21 +65,18 @@ public:
TrackObjectPresentation(const XMLNode& xml_node); TrackObjectPresentation(const XMLNode& xml_node);
TrackObjectPresentation( TrackObjectPresentation(const core::vector3df& xyz,
const core::vector3df& xyz, const core::vector3df& hpr = core::vector3df(0,0,0),
const core::vector3df& hpr, const core::vector3df& scale = core::vector3df(0,0,0))
const core::vector3df& scale)
{ {
m_init_xyz = xyz; m_init_xyz = xyz;
m_init_hpr = hpr; m_init_hpr = hpr;
m_init_scale = scale; m_init_scale = scale;
} } // TrackObjectPresentation
TrackObjectPresentation(const core::vector3df& xyz)
{
m_init_xyz = xyz;
}
// ------------------------------------------------------------------------
virtual ~TrackObjectPresentation() {} virtual ~TrackObjectPresentation() {}
// ------------------------------------------------------------------------
virtual void reset() {} virtual void reset() {}
virtual void setEnable(bool enabled) {} virtual void setEnable(bool enabled) {}
@ -86,50 +84,56 @@ public:
virtual void move(const core::vector3df& xyz, const core::vector3df& hpr, virtual void move(const core::vector3df& xyz, const core::vector3df& hpr,
const core::vector3df& scale) {} const core::vector3df& scale) {}
// ------------------------------------------------------------------------
/** Returns the position of this TrackObjectPresentation. */
virtual const core::vector3df& getPosition() const { return m_init_xyz; } virtual const core::vector3df& getPosition() const { return m_init_xyz; }
virtual const core::vector3df getAbsolutePosition() const { return m_init_xyz; } // ------------------------------------------------------------------------
/** Returns a copy of the initial position. Note this function does not
* return a const reference, since some classes overwrite it this way. */
virtual const core::vector3df getAbsolutePosition() const
{
return m_init_xyz;
} // getAbsolutePosition
// ------------------------------------------------------------------------
/** Returns the initial rotation. */
virtual const core::vector3df& getRotation() const { return m_init_hpr; } virtual const core::vector3df& getRotation() const { return m_init_hpr; }
// ------------------------------------------------------------------------
/** Returns the initial scale. */
virtual const core::vector3df& getScale() const { return m_init_scale; } virtual const core::vector3df& getScale() const { return m_init_scale; }
LEAK_CHECK() LEAK_CHECK()
}; };
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* Base class for all track object presentation classes using a scene node * Base class for all track object presentation classes using a scene node
* as presentation * as presentation
*/ */
class TrackObjectPresentationSceneNode : public TrackObjectPresentation class TrackObjectPresentationSceneNode : public TrackObjectPresentation
{ {
protected: protected:
/** A pointer to the scene node of this object. */
scene::ISceneNode* m_node; scene::ISceneNode* m_node;
public: public:
/** Constructor based on data from xml. */
TrackObjectPresentationSceneNode(const XMLNode& xml_node) : TrackObjectPresentationSceneNode(const XMLNode& xml_node) :
TrackObjectPresentation(xml_node) TrackObjectPresentation(xml_node)
{ {
m_node = NULL; m_node = NULL;
} } // TrackObjectPresentationSceneNode
// ------------------------------------------------------------------------
TrackObjectPresentationSceneNode( /** Constructor based on a transform. */
const core::vector3df& xyz, TrackObjectPresentationSceneNode(const core::vector3df& xyz,
const core::vector3df& hpr, const core::vector3df& hpr,
const core::vector3df& scale) : const core::vector3df& scale,
TrackObjectPresentation(xyz, hpr, scale) scene::ISceneNode* node = NULL) :
{
m_node = NULL;
}
TrackObjectPresentationSceneNode(
scene::ISceneNode* node,
const core::vector3df& xyz,
const core::vector3df& hpr,
const core::vector3df& scale) :
TrackObjectPresentation(xyz, hpr, scale) TrackObjectPresentation(xyz, hpr, scale)
{ {
m_node = node; m_node = node;
} } // TrackObjectPresentationSceneNode
// ------------------------------------------------------------------------
virtual const core::vector3df& getPosition() const OVERRIDE; virtual const core::vector3df& getPosition() const OVERRIDE;
virtual const core::vector3df getAbsolutePosition() const OVERRIDE; virtual const core::vector3df getAbsolutePosition() const OVERRIDE;
virtual const core::vector3df& getRotation() const OVERRIDE; virtual const core::vector3df& getRotation() const OVERRIDE;
@ -139,38 +143,40 @@ public:
virtual void setEnable(bool enabled) OVERRIDE; virtual void setEnable(bool enabled) OVERRIDE;
virtual void reset() OVERRIDE; virtual void reset() OVERRIDE;
// ------------------------------------------------------------------------
/** Returns a pointer to the scene node. */
scene::ISceneNode* getNode() { return m_node; } scene::ISceneNode* getNode() { return m_node; }
// ------------------------------------------------------------------------
/** Returns a pointer to the scene node, const version. */
const scene::ISceneNode* getNode() const { return m_node; } const scene::ISceneNode* getNode() const { return m_node; }
}; }; // class TrackObjectPresentationSceneNode
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that is invisible and only consists of a * A track object representation that is invisible and only consists of a
* location, rotation and scale. * location, rotation and scale.
*/ */
class TrackObjectPresentationEmpty : public TrackObjectPresentationSceneNode class TrackObjectPresentationEmpty : public TrackObjectPresentationSceneNode
{ {
public: public:
TrackObjectPresentationEmpty(const XMLNode& xml_node); TrackObjectPresentationEmpty(const XMLNode& xml_node);
virtual ~TrackObjectPresentationEmpty(); virtual ~TrackObjectPresentationEmpty();
}; }; // class TrackObjectPresentationEmpty
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that is a library node * A track object representation that is a library node
*/ */
class TrackObjectPresentationLibraryNode : public TrackObjectPresentationSceneNode class TrackObjectPresentationLibraryNode : public TrackObjectPresentationSceneNode
{ {
public: public:
TrackObjectPresentationLibraryNode(const XMLNode& xml_node, TrackObjectPresentationLibraryNode(const XMLNode& xml_node,
ModelDefinitionLoader& model_def_loader); ModelDefinitionLoader& model_def_loader);
virtual ~TrackObjectPresentationLibraryNode(); virtual ~TrackObjectPresentationLibraryNode();
}; }; // TrackObjectPresentationLibraryNode
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that consists of a level-of-detail scene node * A track object representation that consists of a level-of-detail scene node
*/ */
class TrackObjectPresentationLOD : public TrackObjectPresentationSceneNode class TrackObjectPresentationLOD : public TrackObjectPresentationSceneNode
@ -183,8 +189,8 @@ public:
virtual ~TrackObjectPresentationLOD(); virtual ~TrackObjectPresentationLOD();
}; };
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that consists of a mesh scene node. * A track object representation that consists of a mesh scene node.
*/ */
class TrackObjectPresentationMesh : public TrackObjectPresentationSceneNode class TrackObjectPresentationMesh : public TrackObjectPresentationSceneNode
@ -211,30 +217,29 @@ private:
void init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled); void init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled);
public: public:
TrackObjectPresentationMesh(const XMLNode& xml_node, bool enabled, scene::ISceneNode* parent); TrackObjectPresentationMesh(const XMLNode& xml_node, bool enabled,
scene::ISceneNode* parent);
TrackObjectPresentationMesh(
const std::string& model_file, const core::vector3df& xyz,
const core::vector3df& hpr, const core::vector3df& scale);
TrackObjectPresentationMesh(
scene::IAnimatedMesh* mesh, const core::vector3df& xyz,
const core::vector3df& hpr, const core::vector3df& scale);
void setLoop(int start, int end); //set custom loops, as well as pause by scripts
void setCurrentFrame(int frame);
int getCurrentFrame();
TrackObjectPresentationMesh(const std::string& model_file,
const core::vector3df& xyz,
const core::vector3df& hpr,
const core::vector3df& scale);
TrackObjectPresentationMesh(scene::IAnimatedMesh* mesh,
const core::vector3df& xyz,
const core::vector3df& hpr,
const core::vector3df& scale);
virtual ~TrackObjectPresentationMesh(); virtual ~TrackObjectPresentationMesh();
void setLoop(int start, int end);
void setCurrentFrame(int frame);
int getCurrentFrame();
virtual void reset() OVERRIDE; virtual void reset() OVERRIDE;
// ------------------------------------------------------------------------
/** Returns the mode file name. */
const std::string& getModelFile() const { return m_model_file; } const std::string& getModelFile() const { return m_model_file; }
}; }; // class TrackObjectPresentationMesh
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that consists of a sound emitter * A track object representation that consists of a sound emitter
*/ */
class TrackObjectPresentationSound : public TrackObjectPresentation, class TrackObjectPresentationSound : public TrackObjectPresentation,
@ -242,7 +247,8 @@ class TrackObjectPresentationSound : public TrackObjectPresentation,
{ {
private: private:
/** If a sound is attached to this object and/or this is a sound emitter object */ /** If a sound is attached to this object and/or this is a sound emitter
* object */
SFXBase* m_sound; SFXBase* m_sound;
/** Currently used for sound effects only, in cutscenes only atm */ /** Currently used for sound effects only, in cutscenes only atm */
@ -252,42 +258,44 @@ private:
public: public:
TrackObjectPresentationSound(const XMLNode& xml_node, scene::ISceneNode* parent); TrackObjectPresentationSound(const XMLNode& xml_node,
scene::ISceneNode* parent);
virtual ~TrackObjectPresentationSound(); virtual ~TrackObjectPresentationSound();
virtual void onTriggerItemApproached(Item* who) OVERRIDE; virtual void onTriggerItemApproached(Item* who) OVERRIDE;
virtual void update(float dt) OVERRIDE; virtual void update(float dt) OVERRIDE;
virtual void move(const core::vector3df& xyz, const core::vector3df& hpr,
const core::vector3df& scale) OVERRIDE;
void triggerSound(bool loop); void triggerSound(bool loop);
void stopSound(); void stopSound();
// ------------------------------------------------------------------------
/** Currently used for sound effects only, in cutscenes only atm */ /** Currently used for sound effects only, in cutscenes only atm */
const std::string& getTriggerCondition() const { return m_trigger_condition; } const std::string& getTriggerCondition() const { return m_trigger_condition; }
}; // TrackObjectPresentationSound
virtual void move(const core::vector3df& xyz, const core::vector3df& hpr, // ============================================================================
const core::vector3df& scale) OVERRIDE; /** \ingroup tracks
};
/**
* \ingroup tracks
* A track object representation that consists of a billboard scene node. * A track object representation that consists of a billboard scene node.
*/ */
class TrackObjectPresentationBillboard : public TrackObjectPresentationSceneNode class TrackObjectPresentationBillboard : public TrackObjectPresentationSceneNode
{ {
/** To make the billboard disappear when close to the camera. Useful for light halos : /** To make the billboard disappear when close to the camera. Useful for
* instead of "colliding" with the camera and suddenly disappearing when clipped by * light halos: instead of "colliding" with the camera and suddenly
* frustum culling, it will gently fade out. * disappearing when clipped by frustum culling, it will gently fade out.
*/ */
bool m_fade_out_when_close; bool m_fade_out_when_close;
float m_fade_out_start; float m_fade_out_start;
float m_fade_out_end; float m_fade_out_end;
public: public:
TrackObjectPresentationBillboard(const XMLNode& xml_node, scene::ISceneNode* parent); TrackObjectPresentationBillboard(const XMLNode& xml_node,
scene::ISceneNode* parent);
virtual ~TrackObjectPresentationBillboard(); virtual ~TrackObjectPresentationBillboard();
virtual void update(float dt) OVERRIDE; virtual void update(float dt) OVERRIDE;
}; }; // TrackObjectPresentationBillboard
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that consists of a particle emitter * A track object representation that consists of a particle emitter
*/ */
class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode
@ -298,18 +306,19 @@ private:
std::string m_trigger_condition; std::string m_trigger_condition;
public: public:
TrackObjectPresentationParticles(const XMLNode& xml_node, scene::ISceneNode* parent); TrackObjectPresentationParticles(const XMLNode& xml_node,
scene::ISceneNode* parent);
virtual ~TrackObjectPresentationParticles(); virtual ~TrackObjectPresentationParticles();
virtual void update(float dt) OVERRIDE; virtual void update(float dt) OVERRIDE;
std::string& getTriggerCondition() { return m_trigger_condition; }
void triggerParticles(); void triggerParticles();
}; // ------------------------------------------------------------------------
/** Returns the trigger condition for this object. */
std::string& getTriggerCondition() { return m_trigger_condition; }
}; // TrackObjectPresentationParticles
/** // ============================================================================
* \ingroup tracks /** \ingroup tracks
* A track object representation that consists of a light emitter * A track object representation that consists of a light emitter
*/ */
class TrackObjectPresentationLight : public TrackObjectPresentationSceneNode class TrackObjectPresentationLight : public TrackObjectPresentationSceneNode
@ -320,40 +329,40 @@ private:
float m_energy; float m_energy;
public: public:
TrackObjectPresentationLight(const XMLNode& xml_node, scene::ISceneNode* parent); TrackObjectPresentationLight(const XMLNode& xml_node,
scene::ISceneNode* parent);
virtual ~TrackObjectPresentationLight(); virtual ~TrackObjectPresentationLight();
}; }; // TrackObjectPresentationLight
// ============================================================================
/** /** \ingroup tracks
* \ingroup tracks
* A track object representation that consists of an action trigger * A track object representation that consists of an action trigger
*/ */
class TrackObjectPresentationActionTrigger : public TrackObjectPresentation, class TrackObjectPresentationActionTrigger : public TrackObjectPresentation,
public TriggerItemListener public TriggerItemListener
{ {
private: private:
/** For action trigger objects */ /** For action trigger objects */
std::string m_action; std::string m_action;
bool m_action_active; bool m_action_active;
public: public:
TrackObjectPresentationActionTrigger(const XMLNode& xml_node); TrackObjectPresentationActionTrigger(const XMLNode& xml_node);
TrackObjectPresentationActionTrigger(const core::vector3df& xyz,std::string scriptname, float distance); TrackObjectPresentationActionTrigger(const core::vector3df& xyz,
const std::string& scriptname,
float distance);
virtual ~TrackObjectPresentationActionTrigger() {} virtual ~TrackObjectPresentationActionTrigger() {}
virtual void onTriggerItemApproached(Item* who) OVERRIDE; virtual void onTriggerItemApproached(Item* who) OVERRIDE;
// ------------------------------------------------------------------------
/** Reset the trigger (i.e. sets it to active again). */
virtual void reset() OVERRIDE { m_action_active = true; } virtual void reset() OVERRIDE { m_action_active = true; }
// ------------------------------------------------------------------------
/** Sets the trigger to be enabled or disabled. */
virtual void setEnable(bool status) OVERRIDE{ m_action_active = status; } virtual void setEnable(bool status) OVERRIDE{ m_action_active = status; }
}; }; // class TrackObjectPresentationActionTrigger
#endif // TRACKOBJECTPRESENTATION_HPP #endif // TRACKOBJECTPRESENTATION_HPP