//---------------------------------------------------------------------------- int CDotSceneSerializer::RecurseReadObjects(TiXmlElement *parentelement,CBaseEditor* parentobject) { CBaseEditor *newobj; TiXmlElement* element = 0; Ogre::String eType; element = parentelement->FirstChildElement(); if(!element) return SCF_OK; do { newobj = 0; eType = element->Value(); if(eType == "node") { ReadSceneNode(element, parentobject, &newobj); int ret = RecurseReadObjects(element, newobj); if(ret != SCF_OK) return ret; NameObjectPairList& childlist = newobj->getChildren(); if(childlist.size() == 1) { CBaseEditor *childobj = childlist.begin()->second; childobj->setParent(newobj->getParent()); OgitorsPropertyValueMap vmapn = newobj->getProperties()->getValueMap(); OgitorsPropertyValueMap vmapo; OgitorsPropertyValueMap::iterator vit; vit = vmapn.find("autotracktarget"); vmapo.insert(OgitorsPropertyValueMap::value_type(vit->first, vit->second)); vit = vmapn.find("position"); vmapo.insert(OgitorsPropertyValueMap::value_type(vit->first, vit->second)); vit = vmapn.find("scale"); vmapo.insert(OgitorsPropertyValueMap::value_type(vit->first, vit->second)); vit = vmapn.find("orientation"); vmapo.insert(OgitorsPropertyValueMap::value_type(vit->first, vit->second)); OgitorsRoot::getSingletonPtr()->DestroyEditorObject(newobj); newobj = childobj; childobj->getProperties()->setValueMap(vmapo); } } else if(eType == "entity") ReadEntity(element, parentobject, &newobj); else if(eType == "subentities") ReadSubEntity(element, parentobject, &newobj); else if(eType == "light") ReadLight(element, parentobject, &newobj); else if(eType == "camera") ReadCamera(element, parentobject, &newobj); else if(eType == "particle") ReadParticle(element, parentobject, &newobj); else if(eType == "plane") ReadPlane(element, parentobject, &newobj); else continue; } while(element = element->NextSiblingElement()); return SCF_OK; }
//---------------------------------------------------------------------------------- bool PropertyUndo::apply() { CBaseEditor *object = OgitorsRoot::getSingletonPtr()->FindObject(mObjectID); if(!object) return false; if(mValue.propType == PROP_UNSIGNED_LONG && mPropertyName == "parent") { CBaseEditor *parent = OgitorsRoot::getSingletonPtr()->FindObject(Ogre::any_cast<unsigned long>(mValue.val)); if(!parent) return false; mValue.val = Ogre::Any((unsigned long)parent); } OgitorsPropertyValueMap map; map.insert(OgitorsPropertyValueMap::value_type(mPropertyName, mValue)); if(mSetType == PROPSET_OBJECT) { object->getProperties()->setValueMap(map); return true; } else if(mSetType == PROPSET_CUSTOM) { object->getCustomProperties()->setValueMap(map); return true; } return false; }
//---------------------------------------------------------------------------------- CBaseEditor *OgitorsClipboardManager::instantiateTemplate(const Ogre::String& templatename) { CBaseEditor *retObject = OgitorsRoot::getSingletonPtr()->GetSelection(); CBaseEditor *item = 0; ObjectTemplateMap::const_iterator it; it = mGeneralTemplates.find(templatename); if(it == mGeneralTemplates.end()) { it = mProjectTemplates.find(templatename); if(it == mProjectTemplates.end()) return 0; } ObjectTemplate objTemplate = it->second; OgitorsPropertyValueMap::iterator pit; NameObjectPairList list; NameObjectPairList objlist; std::vector<CBaseEditor*> objlist2; NameObjectPairList::iterator nit; Ogre::String parentname; int numParentObjects = 0; for(unsigned int i = 0;i < objTemplate.size();i++) { OgitorsPropertyValueMap objMap = objTemplate[i].mObjectProperties; if((pit = objMap.find("parentnode")) != objMap.end()) { parentname = Ogre::any_cast<Ogre::String>(pit->second.val); if((nit = list.find(parentname)) != list.end()) { pit->second.val = Ogre::Any(nit->second->getName()); } else { objMap.erase(pit); ++numParentObjects; } } else ++numParentObjects; parentname = Ogre::any_cast<Ogre::String>(objMap["name"].val); objMap["name"].val = Ogre::Any(parentname + OgitorsRoot::getSingletonPtr()->CreateUniqueID(parentname,"",0)); item = OgitorsRoot::getSingletonPtr()->CreateEditorObject(0, objTemplate[i].mTypeName, objMap, true, false); if(item) { item->load(); item->getCustomProperties()->initFromSet(*(objTemplate[i].mCustomProperties)); list.insert(NameObjectPairList::value_type(parentname, item)); objlist.insert(NameObjectPairList::value_type(item->getName(), item)); objlist2.push_back(item); } } Ogre::Vector3 pos(999999, 999999, 999999); if(numParentObjects == 0) return 0; else if(numParentObjects == 1) { retObject = objlist2[0]; OgitorsRoot::getSingletonPtr()->GetSelection()->setSelection(retObject); } else static_cast<CMultiSelEditor*>(retObject)->setSelection(objlist); if(retObject->getProperties()->hasProperty("position")) retObject->getProperties()->setValue("position", pos); return retObject; }