//----------------------------------------------------------------------- void EntityRenderer::_destroyAll(void) { if (!mParentTechnique) return; // Delete the visual data vector<EntityRendererVisualData*>::const_iterator it; vector<EntityRendererVisualData*>::const_iterator itEnd = mAllVisualData.end(); for (it = mAllVisualData.begin(); it != itEnd; ++it) { PU_DELETE_T(*it, EntityRendererVisualData, MEMCATEGORY_SCENE_OBJECTS); } mAllVisualData.clear(); mVisualData.clear(); // V1.5: Destroy the created ChildSceneNodes (which leads to detaching the Entities) if (mParentTechnique->getParentSystem()) { Ogre::SceneNode* parentNode = mParentTechnique->getParentSystem()->getParentSceneNode(); if (parentNode) { String sceneNodeName; std::stringstream ss; unsigned short numChilds = parentNode->numChildren(); for (unsigned short i = 0; i < numChilds; ++i) { Ogre::Node* node = parentNode->getChild(i); if (node) { Ogre::String name = node->getName(); if (name.find("ParticleUniverse") != Ogre::String::npos) { parentNode->removeAndDestroyChild(i); } } } } } // V1.5 // Destroy the Entities. Do it like this, because it must be assured that the entity still exists // and has not already been destroyed. Ogre::SceneManager* sceneManager = mParentTechnique->getParentSystem()->getSceneManager(); for (size_t i = 0; i < mQuota; i++) { if (sceneManager->hasEntity(mEntityName + StringConverter::toString(i))) { sceneManager->destroyEntity(mEntityName + StringConverter::toString(i)); } } mEntities.clear(); // Reset the visual data in the pool mParentTechnique->initVisualDataInPool(); }
void EditorFrameHandler::Init() { Ogre::SceneManager *scene_manager = CommonDeclarations::GetSceneManager(); EditorCamera = scene_manager->createCamera("EditorCamera"); EditorCamera->setNearClipDistance(5); EditorCamera->setFarClipDistance(0); EditorCamera->setPosition(CommonDeclarations::GetCamera()->GetOgreCamera()->getWorldPosition()); CommonDeclarations::GetApplication()->SetCurrentCamera(EditorCamera); /*CommonDeclarations::ObjectsPool *objects = CommonDeclarations::GetEditableObjects(); for (CommonDeclarations::ObjectsPool::ListNode *pos = objects->GetBegin();pos!=NULL;pos=pos->Next) { SEditableObject obj; obj.Object = pos->Value; IScenable *scen = pos->Value->GetScenable(); if (scen) { obj.EditNode = NULL; obj.EditEntity = NULL; ICollidable *collid = pos->Value->GetCollidable(); if (collid) { obj.CollisionModel = collid->GetCollisionModel(); } else { const char *modelname = scen->GetModelName(); if (NULL == modelname) modelname = AAUtilities::StringCopy("cube.mesh"); obj.CollisionModel = GetCollisionModel(modelname); } } else { obj.EditNode = scene_manager->getRootSceneNode()->createChildSceneNode(); char *buffer = CommonDeclarations::GenGUID(); obj.EditEntity = scene_manager->createEntity(buffer, "cube.mesh"); delete [] buffer; obj.EditNode->attachObject(obj.EditEntity); obj.CollisionModel = GetCollisionModel("cube.mesh"); } EditableObjects.PushBack(obj); } delete objects;*/ // CommonDeclarations::ObjectsPool *objects = CommonDeclarations::GetEditableObjects(); const char *str; TiXmlElement *node = 0, *nodes, *env; env = SceneRootElement->FirstChildElement("environment"); if (env) { node = env->FirstChildElement("skyBox"); if (node) { SEditableDescription descr; descr.EditNode = NULL; descr.EditElement = node; EditorNodes.insert(std::make_pair("SkyBox", descr)); } } nodes = SceneRootElement->FirstChildElement("nodes"); if (nodes) { node = nodes->FirstChildElement("node"); Ogre::Node::ChildNodeIterator iFirst = scene_manager->getRootSceneNode()->getChildIterator(), iPos = iFirst; while (node) { str = node->Attribute("name"); SEditableDescription descr; Ogre::Node *t = NULL; iPos = iFirst; while (iPos.hasMoreElements()) { t = iPos.getNext(); if (t->getName()==str) { descr.EditNode = t; break; } } descr.EditElement = node; EditorNodes.insert(std::make_pair(str, descr)); node = node->NextSiblingElement("node"); } } delete objects; // MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui(); OIS::Mouse *mouse = EditorFrameListener::GetInstance()->GetMouse(); InitGUI(); const OIS::MouseState &ms = mouse->getMouseState(); int x=ms.width/2, y=ms.height/2; mouse->setMousePosition(x,y); gui->setPointerPosition(x, y); gui->showPointer(); }