History: Using MountNode Xml
Source of version: 4 (current)
Copy to clipboard
the following code has some dependancies:
* you have available the ((ManualObject AxisObject|AxisObject)) or one like it.
* tinyxml is available.
* the bones referenced in the xml file do indeed exist on the entity.
* the format of your xml file match's the data from ((Tools: 3DSMax|#MountNodeSet MaxScript|MountNodeSet MaxScript))
{CODE(wrap="1", colors="c++")}
bool loadMountXML()
{
Ogre::DataStreamPtr file = Ogre::ResourceGroupManager::getSingleton().openResource(filename);
TiXmlDocument *doc = new TiXmlDocument(filename.c_str());
if(!doc || !doc->RootElement())
return false;
TiXmlElement *rootXml = doc->RootElement();
Ogre::String rootName = rootXml->Value();
if(rootName != "MountNodes")
{
return false;
}
mMountParent = rootXml->Attribute("parent");
TiXmlElement *n = rootXml->FirstChildElement("Node");
while(n && n->Type() == TiXmlNode::ELEMENT)
{
Ogre::String name = n->Attribute("name");
Ogre::String parent = n->Attribute("parent");
Ogre::String spos = n->Attribute("pos");
Ogre::String srot = n->Attribute("rot");
Ogre::Vector3 pos = Ogre::StringConverter::parseVector3(spos);
Ogre::Quaternion rot = Ogre::StringConverter::parseQuaternion(srot);
n = rootXml->NextSiblingElement();
}
delete doc;
return true;
}{CODE}