Beispiel #1
0
EC_Placeable::~EC_Placeable()
{
    if (world_.expired())
    {
        if (sceneNode_)
            LogError("EC_Placeable: World has expired, skipping uninitialization!");
        return;
    }
    
    emit AboutToBeDestroyed();
    
    OgreWorldPtr world = world_.lock();
    Ogre::SceneManager* sceneMgr = world->GetSceneManager();
    
    if (sceneNode_)
    {
        DetachNode();
        
        sceneMgr->destroySceneNode(sceneNode_);
        sceneNode_ = 0;
    }
    // Destroy the attachment node if it was created
    if (boneAttachmentNode_)
    {
        sceneMgr->getRootSceneNode()->removeChild(boneAttachmentNode_);
        sceneMgr->destroySceneNode(boneAttachmentNode_);
        boneAttachmentNode_ = 0;
    }
}
Beispiel #2
0
void Obstacle::doDisable()
{
	Ogre::SceneManager* sm = OgreGraphicsManager::getSingleton().getSceneManager();
	_node->detachObject(_entity);
	sm->destroySceneNode(_node);
	sm->destroyEntity(_entity);
}
Beispiel #3
0
NxNode::~NxNode()
{
	LogMsg("Erasing NxNode : " + GetName() );

	LogMsg("Erasing NxActors ... " );
	NxActorListIterator NxActorsIter = GetNxActorIterator();
	while( NxActorsIter.hasMoreElements() ){
		delete NxActorsIter.getNext();
	}
	mNxActors.clear();
	LogMsg("Erasing NxActors : DONE" );

	LogMsg("Erasing NxSounds ... " );
	NxSoundMapIterator SoundIter = GetNxSoundIterator();
	while( SoundIter.hasMoreElements() ){
		delete SoundIter.getNext();
	}
	LogMsg("Erasing NxSounds : DONE" );

	LogMsg("Erasing NxEntities... " );
	NxEntityListIterator EntityIter = GetNxEntityIterator();
	while( EntityIter.hasMoreElements() ){
		delete EntityIter.getNext();
	}
	LogMsg("Erasing NxEntities : DONE" );

	Ogre::SceneManager * mManager = mSceneNode->getCreator(); // detach child first ?
	mManager->destroySceneNode( mSceneNode );

	LogMsg("Erasing NxNode : Done" );	
	LogMsg("-----------------------");
}
Beispiel #4
0
void EC_Terrain::Destroy()
{
    assert(GetFramework());
    if (!GetFramework())
        return;

    boost::shared_ptr<OgreRenderer::Renderer> renderer = GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>().lock();
    if (!renderer) // Oops! Inconvenient dtor order - can't delete our own stuff since we can't get an instance to the owner.
        return;

    Ogre::SceneManager *sceneMgr = renderer->GetSceneManager();
    if (!sceneMgr) // Oops! Same as above.
        return;

    for(int y = 0; y < cNumPatchesPerEdge; ++y)
        for(int x = 0; x < cNumPatchesPerEdge; ++x)
        {
            Ogre::SceneNode *node = GetPatch(x, y).node;
            if (!node)
                continue;

            sceneMgr->getRootSceneNode()->removeChild(node);
//                sceneMgr->destroyManualObject(dynamic_cast<Ogre::ManualObject*>(node->getAttachedObject(0)));
            node->detachAllObjects();
            sceneMgr->destroySceneNode(node);
        }
}
Beispiel #5
0
    AreaEffect::~AreaEffect()
    {
        delete Ghost;
        delete GraphicsSettings;
        delete PhysicsSettings;

        Ogre::SceneManager* OgreManager = Entresol::GetSingletonPtr()->GetSceneManager()->GetGraphicsWorldPointer();
        if(GraphicsObject)
            OgreManager->destroyEntity(GraphicsObject);
        OgreManager->destroySceneNode(GraphicsNode);
    }
//!
//! Remove and destroy this scene.
//!
void Model2SceneNode::destroySceneNode()
{
    if (m_sceneNode) {
        // destroy the scene node through its scene manager
        Ogre::SceneManager *sceneManager =OgreManager::getSceneManager();
        if (sceneManager) {
            sceneManager->destroySceneNode(m_sceneNode);
            m_sceneNode = 0;
            setValue(m_outputGeometryName, m_sceneNode, true);
        }
    }
}
Beispiel #7
0
gkDebugger::~gkDebugger()
{
	if (m_node && m_parent->isInstanced())
	{
		Ogre::SceneManager* mgr = m_parent->getManager();
		mgr->destroySceneNode(m_node);
		m_node = 0;
	}

	delete mRenderOp.vertexData;
	mRenderOp.vertexData = 0;
	m_buffer.setNull();
}
Beispiel #8
0
EC_WaterPlane::~EC_WaterPlane()
{
   if (world_.expired())
    return;
    
   OgreWorldPtr world = world_.lock();
   RemoveWaterPlane();

    if (node_ != 0)
    {
        Ogre::SceneManager* sceneMgr = world->GetSceneManager();
        sceneMgr->destroySceneNode(node_);
        node_ = 0;
    }
}
Beispiel #9
0
	void
	BoxCenterManager::init()
	{
		mBoxCenterObjMap.clear();

		ObjBoxCenterMap::iterator iter;
		for(iter = mObjBoxCenterMap.begin();iter != mObjBoxCenterMap.end();iter++)
		{
			Ogre::MovableObject* mv = iter->second;
			if (mv->getParentSceneNode())
			{
				Ogre::SceneManager* pSceneManager = mv->getParentSceneNode()->getCreator();
				pSceneManager->destroySceneNode(mv->getParentSceneNode());
			}

			delete iter->second;
		}
		mObjBoxCenterMap.clear();
	}
Beispiel #10
0
EC_Mesh::~EC_Mesh()
{
    if (world_.expired())
    {
        // Log error only if there was an Ogre object to be destroyed
        if (entity_)
            LogError("EC_Mesh: World has expired, skipping uninitialization!");
        return;
    }
    OgreWorldPtr world = world_.lock();

    RemoveMesh();

    if (adjustment_node_)
    {
        Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
        sceneMgr->destroySceneNode(adjustment_node_);
        adjustment_node_ = 0;
    }
}
Beispiel #11
0
//!
//! Remove and destroy this scene children.
//! \param The scenenode to be destroyed
//!
void Model2SceneNode::destroyAllChildren( Ogre::SceneNode* i_pSceneNode )
{
	if ( !i_pSceneNode || i_pSceneNode->numChildren() == 0 )
      return;

   // Destroy all the attached objects
   Ogre::SceneNode::ObjectIterator itObject = i_pSceneNode->getAttachedObjectIterator();

   // Recurse to child SceneNodes
   Ogre::SceneNode::ChildNodeIterator itChild = i_pSceneNode->getChildIterator();

   while ( itChild.hasMoreElements() )
   {
      Ogre::SceneNode* pChildNode = static_cast<Ogre::SceneNode*>(itChild.getNext());
      destroyAllAttachedMovableObjects( pChildNode );
	  // obtain the OGRE scene manager
	  Ogre::SceneManager *sceneManager = OgreManager::getSceneManager();
	  if (pChildNode != m_sceneNode)
		  sceneManager->destroySceneNode( pChildNode->getName() );
   }
}
Camera::~Camera()
{
	Ogre::Root& root = Ogre::Root::getSingleton();
	Ogre::SceneManager* sceneMgr = root.getSceneManager(BFG_SCENEMANAGER);
	
	mSubLane.reset();

	if (mRenderTargetCreated)
	{
		Ogre::TextureManager::getSingleton().remove(stringify(mHandle));
		Ogre::MaterialManager::getSingleton().remove(stringify(mHandle));
		mRenderTarget = NULL;
	}

	sceneMgr->destroyCamera(stringify(mHandle));

	if (mNodeCreated)
	{
		sceneMgr->destroySceneNode(mCameraNode);
	}
}
Beispiel #13
0
void EC_Mesh::RemoveAttachmentMesh(uint index)
{
    OgreWorldPtr world = world_.lock();
    
    if (!entity_)
        return;
        
    if (index >= attachment_entities_.size())
        return;
    
    Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
    
    if (attachment_entities_[index] && attachment_nodes_[index])
    {
        // See if attached to a tagpoint or an ordinary node
        Ogre::TagPoint* tag = dynamic_cast<Ogre::TagPoint*>(attachment_nodes_[index]);
        if (tag)
        {
            entity_->detachObjectFromBone(attachment_entities_[index]);
        }
        else
        {
            Ogre::SceneNode* scenenode = dynamic_cast<Ogre::SceneNode*>(attachment_nodes_[index]);
            if (scenenode)
            {
                scenenode->detachObject(attachment_entities_[index]);
                sceneMgr->destroySceneNode(scenenode);
            }
        }
        
        attachment_nodes_[index] = 0;
    }
    if (attachment_entities_[index])
    {
        if (attachment_entities_[index]->sharesSkeletonInstance())
            attachment_entities_[index]->stopSharingSkeletonInstance();
        sceneMgr->destroyEntity(attachment_entities_[index]);
        attachment_entities_[index] = 0;
    }
}
        bool operator()()
        {
            if(!component->ready())
                return false;

            Ogre::SceneManager* sm = GraphicsManager::get().sceneManager();

            sm->destroySceneNode(
                    Ogre::StringConverter::toString(component->localId()));

            sm->destroyEntity(
                    Ogre::StringConverter::toString(component->localId()));

            component->m_sceneNode = 0;
            component->m_particleSystem = 0;

            ThreadPool::get().schedule(boost::bind(
                    &ComponentContainer::componentDetachedCallback,
                    component->parent(), component));

            return true;
        }
Camera::~Camera()
{
	Ogre::Root& root = Ogre::Root::getSingleton();
	Ogre::SceneManager* sceneMgr = root.getSceneManager(BFG_SCENEMANAGER);
	
	Main::eventLoop()->disconnect(ID::VE_UPDATE_POSITION, this);
	Main::eventLoop()->disconnect(ID::VE_UPDATE_ORIENTATION, this);

	if (mRenderTargetCreated)
	{
		Ogre::TextureManager::getSingleton().remove(stringify(mHandle));
		Ogre::MaterialManager::getSingleton().remove(stringify(mHandle));
		mRenderTarget = NULL;
	}

	sceneMgr->destroyCamera(stringify(mHandle));

	if (mNodeCreated)
	{
		sceneMgr->destroySceneNode(mCameraNode);
	}
}
void
GraphicsMeshComponent::detachedCallback()
{
    DEFERRED_CALL_VARS(DestroyGraphicsObjectCall)
        ObjectId id;
        GraphicsMeshComponentPtr component;

    DEFERRED_CALL_CODE()
        if(!component->ready())
            return false;

        Ogre::SceneManager* sm = GraphicsManager::get().sceneManager();

        sm->destroyEntity(
                Ogre::StringConverter::toString(component->localId()));

        component->m_entity = 0;
        
        sm->destroySceneNode(
                Ogre::StringConverter::toString(component->localId()));
                
        component->m_sceneNode = 0;

        ThreadPool::get().schedule(boost::bind(
                &ComponentContainer::componentDetachedCallback,
                component->parent(), component));

        return true;

    DEFERRED_CALL_END()

    DEFERRED_CALL_CREATE(DestroyGraphicsObjectCall)
        call->id = parent()->id();
        call->component = shared_from_this();

    DEFERRED_CALL_ENQUEUE(GraphicsManager)
}
Beispiel #17
0
EC_Clone::~EC_Clone()
{
    // OgreRendering module might be already deleted. If so, the cloned entity and scene node is 
    // also already deleted. In this case, just set pointers to 0.
    if (!renderer_.expired())
    {
        Ogre::SceneManager *sceneMgr = renderer_.lock()->GetSceneManager();
        if (entityClone_)
        {
            sceneMgr->destroyEntity(entityClone_);
            entityClone_ = 0;
        }
        if (sceneNode_)
        {
            sceneMgr->destroySceneNode(sceneNode_);
            sceneNode_ = 0;
        }
    }
    else
    {
        entityClone_ = 0;
        sceneNode_ = 0;
    }
}