//----------------------------------------------------------------------------------------- void CEntityEditor::createProperties(OgitorsPropertyValueMap ¶ms) { PROPERTY_PTR(mMeshFile , "meshfile" , Ogre::String,"" ,0, SETTER(Ogre::String, CEntityEditor, _setMeshFile)); PROPERTY_PTR(mCastShadows , "castshadows" , bool ,false,0, SETTER(bool, CEntityEditor, _setCastShadows)); PROPERTY_PTR(mSubEntityCount, "subentitycount", int , -1 ,0, 0); PROPERTY_PTR(mRenderingDistance, "renderingdistance",Ogre::Real ,5000,0, SETTER(Ogre::Real, CEntityEditor, _setRenderingDistance)); int count = 0; OgitorsPropertyValueMap::const_iterator it = params.find("subentitycount"); if(it != params.end()) count = Ogre::any_cast<int>(it->second.val); OgitorsPropertyDef *definition; for(int ix = 0; ix < count; ix++) { Ogre::String sCount1 = "SubEntities::SubEntity" + Ogre::StringConverter::toString(ix); Ogre::String sCount2 = "subentity" + Ogre::StringConverter::toString(ix); definition = mFactory->AddPropertyDefinition(sCount2 + "::material", sCount1 + "::Material", "Sub Entity's Material Name", PROP_STRING, true, true); definition->setOptions(OgitorsRoot::GetMaterialNames()); mFactory->AddPropertyDefinition(sCount2 + "::visible", sCount1 + "::Visible", "Sub Entity's Visibility", PROP_BOOL, true, true); PROPERTY(sCount2 + "::material", Ogre::String, "", ix, SETTER(Ogre::String, CEntityEditor, _setSubMaterial)); PROPERTY(sCount2 + "::visible", bool, true, ix, SETTER(bool, CEntityEditor, _setSubVisible)); } mProperties.initValueMap(params); Ogre::String addstr = mMeshFile->get(); int ret = addstr.find(".mesh"); if(ret != -1) { addstr.erase(ret, 5); mMeshFile->init(addstr); } }
//---------------------------------------------------------------------------------- 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; }