Пример #1
0
void Objects::clearSceneNode (Ogre::SceneNode *node)
{
    for (int i=node->numAttachedObjects()-1; i>=0; --i)
    {
        Ogre::MovableObject *object = node->getAttachedObject (i);

        // for entities, destroy any objects attached to bones
        if (object->getTypeFlags () == Ogre::SceneManager::ENTITY_TYPE_MASK)
        {
            Ogre::Entity* ent = static_cast<Ogre::Entity*>(object);
            Ogre::Entity::ChildObjectListIterator children = ent->getAttachedObjectIterator ();
            while (children.hasMoreElements())
            {
                mRenderer.getScene ()->destroyMovableObject (children.getNext ());
            }
        }

        node->detachObject (object);
        mRenderer.getScene()->destroyMovableObject (object);
    }

    Ogre::Node::ChildNodeIterator it = node->getChildIterator ();
    while (it.hasMoreElements ())
    {
        clearSceneNode(static_cast<Ogre::SceneNode*>(it.getNext ()));
    }
}
Пример #2
0
  void RendererSystemComponent::DestroySceneNode(Ogre::SceneNode* sceneNode)
  {
    Ogre::Node::ChildNodeIterator children = sceneNode->getChildIterator();

    while(children.hasMoreElements())
    {
      SceneNode* childSceneNode = static_cast<SceneNode*>(children.getNext());
      this->DestroySceneNode(childSceneNode);
    }

    SceneNode::ObjectIterator objects = sceneNode->getAttachedObjectIterator();

    while(objects.hasMoreElements())
    {
      MovableObject* object = objects.getNext();

      if(object->getMovableType() == EntityFactory::FACTORY_TYPE_NAME)
      {
        Entity* entity = m_scene->GetSceneManager()->getEntity(object->getName());
        
        Ogre::Entity::ChildObjectListIterator childObjects = entity->getAttachedObjectIterator();

        while(childObjects.hasMoreElements())
        {
          m_scene->GetSceneManager()->destroyMovableObject(childObjects.getNext());
        }
      }

      m_scene->GetSceneManager()->destroyMovableObject(object);
    }

    sceneNode->removeAndDestroyAllChildren();
  }
Пример #3
0
	Model::~Model()
	{
		Ogre::Node* parent = mEntity->getParentNode();
		bool isTagPoint = mEntity->isParentTagPoint();
		
		mEntity->detachFromParent();
		
		if(isTagPoint)
		{
			// std::cout << "TAG POINT" << std::endl;
			// If the current mesh is bound to a tag point, should alert Entity which controls the skeleton that the tag point must be freed
			
			// remember to delete tag point if mesh is bound to skeleton
			// mEntity->getSkeleton()->freeTagPoint();
		}
		else
		{
			// std::cout << "NOT tag point" << std::endl;
			// Destroy parent node if it is a scene node
			// may be poor reasoning.  might there be multiple Model objects per node?
			// perhaps destroy parent if it is a scene node such that numChildren == 0 ?
			mSceneMgr->destroySceneNode(static_cast<Ogre::SceneNode*>(parent));
		}
		
		// Detach all objects attached to this one, so they don't freak out when this is gone.
		// Iterate over all objects attached to bones
			// detach them from bones, and re-attach them to scene nodes
			// make those scene nodes direct children of the root node
		Ogre::Entity::ChildObjectListIterator iter = mEntity->getAttachedObjectIterator();
		while(iter.hasMoreElements())
		{
			Ogre::MovableObject* child = iter.getNext();
			
			mEntity->detachObjectFromBone(child);
			
			Ogre::SceneNode* node;
			node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
			node->attachObject(child);
		}
		
		// std::cout << "destroy entity" << std::endl;
		mSceneMgr->destroyEntity(mEntity);
	}
Пример #4
0
void SkeletonDebug::ShowSkeletonDebug(Ogre::Entity *entity)
{
    Ogre::Entity::ChildObjectListIterator it =
        entity->getAttachedObjectIterator();

    while (it.hasMoreElements())
    {
        Ogre::Entity* const entity =
            static_cast<Ogre::Entity*>(it.getNext());

        const Ogre::String meshName = entity->getMesh()->getName();

        if (meshName == axesMeshName)
        {
            entity->setVisible(true);
        }
        else if (meshName == boneName)
        {
            entity->setVisible(true);
        }
    }
}
Пример #5
0
bool SkeletonDebug::HasSkeletonDebug(Ogre::Entity *entity)
{
    Ogre::Entity::ChildObjectListIterator it =
        entity->getAttachedObjectIterator();

    while (it.hasMoreElements())
    {
        Ogre::Entity* const entity =
            static_cast<Ogre::Entity*>(it.getNext());

        const Ogre::String meshName = entity->getMesh()->getName();

        if (meshName == axesMeshName)
        {
            return true;
        }
        else if (meshName == boneName)
        {
            return true;
        }
    }

    return false;
}