void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled) { bool skeletal_animation = true; // for backwards compatibility, if unspecified assume there is if(xml_node) xml_node->get("skeletal-animation", &skeletal_animation); bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects || World::getWorld()->getIdent() == IDENT_CUTSCENE); bool displacing = false; if(xml_node) xml_node->get("displacing", &displacing); animated &= !displacing; m_mesh->grab(); irr_driver->grabAllTextures(m_mesh); if (m_is_in_skybox) { // Tell the driver that this mesh is a part of the background scene::IMeshSceneNode * const node = irr_driver->getSceneManager()->addMeshSceneNode(m_mesh); node->grab(); node->setParent(NULL); irr_driver->addBackgroundNode(node); m_node = node; } else if (animated) { scene::IAnimatedMeshSceneNode *node = irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh, parent); m_node = node; m_frame_start = node->getStartFrame(); if (xml_node) xml_node->get("frame-start", &m_frame_start); m_frame_end = node->getEndFrame(); if (xml_node) xml_node->get("frame-end", &m_frame_end); } else { bool displacing = false; if (xml_node) xml_node->get("displacing", &displacing); m_node = irr_driver->addMesh(m_mesh, parent); STKMeshSceneNode* stkmesh = dynamic_cast<STKMeshSceneNode*>(m_node); if (displacing && stkmesh != NULL) stkmesh->setIsDisplacement(displacing); m_frame_start = 0; m_frame_end = 0; if (World::getWorld() != NULL && World::getWorld()->getTrack() != NULL && xml_node != NULL) 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) m_node->setVisible(false); m_node->setPosition(m_init_xyz); m_node->setRotation(m_init_hpr); m_node->setScale(m_init_scale); }
// ---------------------------------------------------------------------------- void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled) { // for backwards compatibility, if unspecified assume there is bool skeletal_animation = true; if(xml_node) xml_node->get("skeletal-animation", &skeletal_animation); bool animated = skeletal_animation && (UserConfigParams::m_graphical_effects || World::getWorld()->getIdent() == IDENT_CUTSCENE); bool displacing = false; std::string interaction; if (xml_node) { xml_node->get("displacing", &displacing); xml_node->get("interaction", &interaction); } animated &= !displacing; m_mesh->grab(); irr_driver->grabAllTextures(m_mesh); if (interaction == "physicsonly") { std::string type; xml_node->get("type", &type); if (type == "animation" || xml_node->hasChildNamed("curve")) { // Animated //m_node = irr_driver->getSceneManager()->addEmptySceneNode(); m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info); enabled = false; m_force_always_hidden = true; m_frame_start = 0; m_frame_end = 0; } else { // Static m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info); enabled = false; m_force_always_hidden = true; m_frame_start = 0; m_frame_end = 0; if (World::getWorld() && World::getWorld()->getTrack() && xml_node) World::getWorld()->getTrack()->addPhysicsOnlyNode(m_node); } } else if (m_is_in_skybox) { // Tell the driver that this mesh is a part of the background scene::IMeshSceneNode * const node = irr_driver->getSceneManager()->addMeshSceneNode(m_mesh); node->grab(); node->setParent(NULL); irr_driver->addBackgroundNode(node); m_node = node; } else if (animated) { scene::IAnimatedMeshSceneNode *node = irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh, m_model_file, parent, m_render_info); m_node = node; m_frame_start = node->getStartFrame(); if (xml_node) xml_node->get("frame-start", &m_frame_start); m_frame_end = node->getEndFrame(); if (xml_node) xml_node->get("frame-end", &m_frame_end); if (World::getWorld() && World::getWorld()->getTrack() && xml_node) World::getWorld()->getTrack() ->handleAnimatedTextures(m_node, *xml_node); } else { bool displacing = false; if (xml_node) xml_node->get("displacing", &displacing); m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info); STKMeshSceneNode* stkmesh = dynamic_cast<STKMeshSceneNode*>(m_node); if (displacing && stkmesh != NULL) stkmesh->setIsDisplacement(displacing); m_frame_start = 0; m_frame_end = 0; if (World::getWorld() && World::getWorld()->getTrack() && xml_node) World::getWorld()->getTrack() ->handleAnimatedTextures(m_node, *xml_node); } if(!enabled) m_node->setVisible(false); m_node->setPosition(m_init_xyz); m_node->setRotation(m_init_hpr); m_node->setScale(m_init_scale); } // init