nargil
02-03-2009 12:44:38
I'm trying to save trees in my editor. The thing is that the last tree is never saved. For example if I place 1 tree, save the scene, reload it, then there is no tree in the scene. If I place 2 trees then after reloading there is only 1. If I place 3 - after reloading i get only 2;
And it's not the loading part broken Trees listed in the xml file are being loaded. There is just 1 missing in the file.
And it's not the loading part broken Trees listed in the xml file are being loaded. There is just 1 missing in the file.
Forests::TreeIterator3D itT = this->drzewaLoader->getTrees();
Ogre::Vector3 pos;
while(itT.hasMoreElements())
{
TreeRef tree = itT.getNext();
TiXmlElement* treeXML = new TiXmlElement("Tree");
treeXML->SetAttribute("entity", tree.getEntity()->getMesh()->getName().c_str());
pos = tree.getPosition();
treeXML->SetDoubleAttribute("posX", pos.x);
treeXML->SetDoubleAttribute("posY", pos.y);
treeXML->SetDoubleAttribute("posZ", pos.z);
treeXML->SetDoubleAttribute("yaw", tree.getYaw().valueRadians());
treeXML->SetDoubleAttribute("scale", tree.getScale());
terenXML->LinkEndChild(treeXML);
}