bool VehicleRenderable::loadSceneNodes(TinyXml::TiXmlElement* ele) { TinyXml::TiXmlElement* nodeEle = ele->FirstChildElement("node"); while (nodeEle) { Ogre::String name = getAttrib(nodeEle, "name"); Ogre::SceneNode* node = NULL; if (name.empty()) node = mAttachNode->createChildSceneNode(); else node = mAttachNode->createChildSceneNode(name); mSceneNodes.push_back(node); Ogre::LogManager::getSingleton(). logMessage("VehicleRenderable : parsing <" + name + "> node..."); //process position TinyXml::TiXmlElement* pos = nodeEle->FirstChildElement("position"); node->setPosition(parseVector3(pos)); node->setInitialState(); //process scale TinyXml::TiXmlElement* scale = nodeEle->FirstChildElement("scale"); node->setScale(parseVector3(scale)); node->setInitialState(); //process rotate TinyXml::TiXmlElement* rotate = nodeEle->FirstChildElement("rotation"); node->setOrientation(parseQuaternion(rotate)); node->setInitialState(); //process entities TinyXml::TiXmlElement* entity = nodeEle->FirstChildElement("entity"); while (entity) { if (!loadEntity(entity, node)) return false; entity = entity->NextSiblingElement("entity"); } nodeEle = nodeEle->NextSiblingElement("node"); } return true; }
void DotSceneLoader::processNode(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Construct the node's name Ogre::String name = m_sPrependNode + getAttrib(XMLNode, "name"); // Create the scene node Ogre::SceneNode *pNode; if (name.empty()) { // Let Ogre choose the name if (pParent) pNode = pParent->createChildSceneNode(); else pNode = mAttachNode->createChildSceneNode(); } else { // Provide the name if (pParent) pNode = pParent->createChildSceneNode(name); else pNode = mAttachNode->createChildSceneNode(name); } // Process other attributes Ogre::String id = getAttrib(XMLNode, "id"); bool isTarget = getAttribBool(XMLNode, "isTarget"); rapidxml::xml_node<>* pElement; // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) { pNode->setPosition(parseVector3(pElement)); pNode->setInitialState(); } // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) { pNode->setOrientation(parseQuaternion(pElement)); pNode->setInitialState(); } // Process scale (?) pElement = XMLNode->first_node("scale"); if (pElement) { pNode->setScale(parseVector3(pElement)); pNode->setInitialState(); } // Process lookTarget (?) pElement = XMLNode->first_node("lookTarget"); if (pElement) processLookTarget(pElement, pNode); // Process trackTarget (?) pElement = XMLNode->first_node("trackTarget"); if (pElement) processTrackTarget(pElement, pNode); // Process node (*) pElement = XMLNode->first_node("node"); while (pElement) { processNode(pElement, pNode); pElement = pElement->next_sibling("node"); } // Process entity (*) pElement = XMLNode->first_node("entity"); while (pElement) { processEntity(pElement, pNode); pElement = pElement->next_sibling("entity"); } // Process light (*) //pElement = XMLNode->first_node("light"); //while(pElement) //{ // processLight(pElement, pNode); // pElement = pElement->next_sibling("light"); //} // Process camera (*) pElement = XMLNode->first_node("camera"); while (pElement) { processCamera(pElement, pNode); pElement = pElement->next_sibling("camera"); } // Process particleSystem (*) pElement = XMLNode->first_node("particleSystem"); while (pElement) { processParticleSystem(pElement, pNode); pElement = pElement->next_sibling("particleSystem"); } // Process billboardSet (*) pElement = XMLNode->first_node("billboardSet"); while (pElement) { processBillboardSet(pElement, pNode); pElement = pElement->next_sibling("billboardSet"); } // Process plane (*) pElement = XMLNode->first_node("plane"); while (pElement) { processPlane(pElement, pNode); pElement = pElement->next_sibling("plane"); } // Process userDataReference (?) pElement = XMLNode->first_node("userDataReference"); if (pElement) processUserDataReference(pElement, pNode); }
void Level::parseLevelObject(TiXmlElement *XMLNode, Ogre::SceneNode *parent) { Ogre::Vector3 spawnPosition; Ogre::Quaternion spawnRotation; Ogre::SceneNode* node; Ogre::String name = getAttribute(XMLNode, "name"); Ogre::String mesh = name; if(name.empty()) { // Let Ogre choose the name if(parent) node = parent->createChildSceneNode(); else node = mAttachNode->createChildSceneNode(); } else { // Provide the name if(parent) node = parent->createChildSceneNode(name); else node = mAttachNode->createChildSceneNode(name); } Ogre::String id = getAttribute(XMLNode, "id"); TiXmlElement *element; element = XMLNode->FirstChildElement("position"); if(element) { spawnPosition = parseVector3(element); node->setPosition(spawnPosition); node->setInitialState(); } element = XMLNode->FirstChildElement("rotation"); if(element) { node->setOrientation(parseQuaternion(element)); spawnRotation = parseQuaternion(element); } element = XMLNode->FirstChildElement("scale"); if(element) { node->setScale(parseVector3(element)); node->setInitialState(); } element = XMLNode->FirstChildElement("node"); while(element) { parseLevelObject(element, node); element = element->NextSiblingElement("node"); } element = XMLNode->FirstChildElement("entity"); while(element) { processEntity(element, node); element = element->NextSiblingElement("entity"); } }