Example #1
0
void ExteriorCellRender::destroyAllAttachedMovableObjects(Ogre::SceneNode* i_pSceneNode)
{
   if ( !i_pSceneNode )
   {
      assert( false );
      return;
   }

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

   while ( itObject.hasMoreElements() )
   {
      MovableObject* pObject = static_cast<MovableObject*>(itObject.getNext());
      i_pSceneNode->getCreator()->destroyMovableObject( pObject );
   }

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

   while ( itChild.hasMoreElements() )
   {
      SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
      destroyAllAttachedMovableObjects( pChildNode );
   }
}
//---------------------------------------------------------------------
void PagingLandScapeOctreePlaneBoundedVolumeListSceneQuery::execute( SceneQueryListener* listener )
{
    PlaneBoundedVolumeList::iterator pi, piend;
    piend = mVolumes.end( );
    for ( pi = mVolumes.begin( ); pi != piend; ++pi )
    {
        std::list < SceneNode* > list;
        //find the nodes that intersect the AAB
        static_cast< PagingLandScapeOctreeSceneManager* >( mParentSceneMgr )->findNodesIn( *pi, list, 0 );

        //grab all moveables from the node that intersect...
        std::list < SceneNode* >::iterator it = list.begin( );
        while ( it != list.end( ) )
        {
            SceneNode::ObjectIterator oit = ( *it )->getAttachedObjectIterator( );
            while ( oit.hasMoreElements( ) )
            {
                MovableObject* m = oit.getNext( );
                if ( ( m->getQueryFlags( ) & mQueryMask ) && m->isInScene( ) &&	( *pi ).intersects( m->getWorldBoundingBox( ) ) )
                {
                    listener->queryResult( m );
                }
            }
            ++it;
        }
    }
}
//---------------------------------------------------------------------
void PagingLandScapeOctreeRaySceneQuery::execute( RaySceneQueryListener* listener )
{
    std::list < SceneNode* > list;
    //find the nodes that intersect the AAB
    static_cast< PagingLandScapeOctreeSceneManager* >( mParentSceneMgr )->findNodesIn( mRay, list, 0 );

    //grab all movables from the node that intersect...
    std::list < SceneNode* >::iterator it = list.begin( );
    while ( it != list.end( ) )
    {
        SceneNode::ObjectIterator oit = ( *it )->getAttachedObjectIterator( );
        while ( oit.hasMoreElements( ) )
        {
            MovableObject* m = oit.getNext( );
            if ( ( m->getQueryFlags( ) & mQueryMask ) && m->isInScene( ) )
            {
                std::pair< bool, Real > result = mRay.intersects( m->getWorldBoundingBox( ) );

                if ( result.first )
                {
                    listener->queryResult( m, result.second );
                }
            }
        }
        ++it;
    }
}
Example #4
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();
  }
Example #5
0
void Debugging::destroyAttachedObjects(SceneNode *node)
{
    SceneNode::ObjectIterator objIt = node->getAttachedObjectIterator();
    while (objIt.hasMoreElements())
    {
        MovableObject *mesh = static_cast<MovableObject *>(objIt.getNext());
        mSceneMgr->destroyMovableObject(mesh);
    }
}
Example #6
0
    //---------------------------------------------------------------------
    void PCZPlaneBoundedVolumeListSceneQuery::execute(SceneQueryListener* listener)
    {
        std::set<SceneNode*> checkedSceneNodes;

        PlaneBoundedVolumeList::iterator pi, piend;
        piend = mVolumes.end();
        for (pi = mVolumes.begin(); pi != piend; ++pi)
        {
            PCZSceneNodeList list;
            //find the nodes that intersect the Plane bounded Volume
            static_cast<PCZSceneManager*>( mParentSceneMgr ) -> findNodesIn( *pi, list, mStartZone, (PCZSceneNode*)mExcludeNode );

            //grab all moveables from the node that intersect...
            PCZSceneNodeList::iterator it, itend;
            itend = list.end();
            for (it = list.begin(); it != itend; ++it)
            {
                // avoid double-check same scene node
                if (!checkedSceneNodes.insert(*it).second)
                    continue;
                SceneNode::ObjectIterator oit = (*it) -> getAttachedObjectIterator();
                while( oit.hasMoreElements() )
                {
                    MovableObject * m = oit.getNext();
                    if( (m->getQueryFlags() & mQueryMask) && 
                        (m->getTypeFlags() & mQueryTypeMask) && 
                        m->isInScene() &&
                        (*pi).intersects( m->getWorldBoundingBox() ) )
                    {
                        listener -> queryResult( m );
                        // deal with attached objects, since they are not directly attached to nodes
                        if (m->getMovableType() == "Entity")
                        {
                            Entity* e = static_cast<Entity*>(m);
                            Entity::ChildObjectListIterator childIt = e->getAttachedObjectIterator();
                            while(childIt.hasMoreElements())
                            {
                                MovableObject* c = childIt.getNext();
                                if (c->getQueryFlags() & mQueryMask &&
                                    (*pi).intersects( c->getWorldBoundingBox()))
                                {
                                    listener->queryResult(c);
                                }
                            }
                        }
                    }
                }
            }
        }//for
        // reset startzone and exclude node
        mStartZone = 0;
        mExcludeNode = 0;
    }
Example #7
0
    //---------------------------------------------------------------------
    void PCZRaySceneQuery::execute(RaySceneQueryListener* listener)
    {
        PCZSceneNodeList list;
        //find the nodes that intersect the Ray
        static_cast<PCZSceneManager*>( mParentSceneMgr ) -> findNodesIn( mRay, list, mStartZone, (PCZSceneNode*)mExcludeNode );

        //grab all moveables from the node that intersect...
        PCZSceneNodeList::iterator it = list.begin();
        while( it != list.end() )
        {
            SceneNode::ObjectIterator oit = (*it) -> getAttachedObjectIterator();
            while( oit.hasMoreElements() )
            {
                MovableObject * m = oit.getNext();
                if( (m->getQueryFlags() & mQueryMask) && 
                    (m->getTypeFlags() & mQueryTypeMask) && m->isInScene() )
                {
                    std::pair<bool, Real> result = mRay.intersects(m->getWorldBoundingBox());

                    if( result.first )
                    {
                        listener -> queryResult( m, result.second );
                        // deal with attached objects, since they are not directly attached to nodes
                        if (m->getMovableType() == "Entity")
                        {
                            Entity* e = static_cast<Entity*>(m);
                            Entity::ChildObjectListIterator childIt = e->getAttachedObjectIterator();
                            while(childIt.hasMoreElements())
                            {
                                MovableObject* c = childIt.getNext();
                                if (c->getQueryFlags() & mQueryMask)
                                {
                                    result = mRay.intersects(c->getWorldBoundingBox());
                                    if (result.first)
                                    {
                                        listener->queryResult(c, result.second);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ++it;
        }
        // reset startzone and exclude node
        mStartZone = 0;
        mExcludeNode = 0;
    }
Example #8
0
	//---------------------------------------------------------------------
	Page::~Page()
	{
		WorkQueue* wq = Root::getSingleton().getWorkQueue();
		wq->removeRequestHandler(mWorkQueueChannel, this);
		wq->removeResponseHandler(mWorkQueueChannel, this);

		destroyAllContentCollections();
		if (mDebugNode)
		{
			// destroy while we have the chance
			SceneNode::ObjectIterator it = mDebugNode->getAttachedObjectIterator();
			while(it.hasMoreElements())
				mParent->getSceneManager()->destroyMovableObject(it.getNext());
			mDebugNode->removeAndDestroyAllChildren();
			mParent->getSceneManager()->destroySceneNode(mDebugNode);

			mDebugNode = 0;
		}
	}
Example #9
0
/** Finds any entities that intersect the AAB for the query. */
void OctreeAxisAlignedBoxSceneQuery::execute(SceneQueryListener* listener)
{
    std::list< SceneNode * > _list;
    //find the nodes that intersect the AAB
    static_cast<OctreeSceneManager*>( mParentSceneMgr ) -> findNodesIn( mAABB, _list, 0 );

    //grab all moveables from the node that intersect...
    std::list< SceneNode * >::iterator it = _list.begin();
    while( it != _list.end() )
    {
        SceneNode::ObjectIterator oit = (*it) -> getAttachedObjectIterator();
        while( oit.hasMoreElements() )
        {
            MovableObject * m = oit.getNext();
            if( (m->getQueryFlags() & mQueryMask) && 
                (m->getTypeFlags() & mQueryTypeMask) && 
                m->isInScene() &&
                mAABB.intersects( m->getWorldBoundingBox() ) )
            {
                listener -> queryResult( m );
                // deal with attached objects, since they are not directly attached to nodes
                if (m->getMovableType() == "Entity")
                {
                    Entity* e = static_cast<Entity*>(m);
                    Entity::ChildObjectListIterator childIt = e->getAttachedObjectIterator();
                    while(childIt.hasMoreElements())
                    {
                        MovableObject* c = childIt.getNext();
                        if (c->getQueryFlags() & mQueryMask)
                        {
                            listener->queryResult(c);
                        }
                    }
                }
            }

        }

        ++it;
    }

}
Example #10
0
  void RendererSystemComponent::LinkSkeletons(Ogre::SceneNode* sceneNode, RendererSystemComponent::SkeletonList* skeletons)
  {
    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());

        if (entity->hasSkeleton())
        {
          Ogre::Skeleton::BoneIterator boneIterator = entity->getSkeleton()->getBoneIterator();

          while(boneIterator.hasMoreElements())
          {
            Ogre::Bone* oBone = boneIterator.getNext();
            oBone->setManuallyControlled(true);

            /*Entity *axis = m_scene->GetSceneManager()->createEntity(oBone->getName() + "_axis", "/data/entities/meshes/axes.mesh");
            TagPoint* tagPoint = entity->attachObjectToBone(oBone->getName(), axis);
            tagPoint->setScale(0.005f, 0.005f, 0.005f);*/
          }

          skeletons->push_back(entity->getSkeleton());
        }
      }
    }

    Node::ChildNodeIterator children = sceneNode->getChildIterator();

    while(children.hasMoreElements())
    {
      SceneNode* child = static_cast<SceneNode*>(children.getNext());
      this->LinkSkeletons(child, skeletons);
    }
  }
Example #11
0
//---------------------------------------------------------------------
void OctreeIntersectionSceneQuery::execute(IntersectionSceneQueryListener* listener)
{
    typedef std::pair<MovableObject *, MovableObject *> MovablePair;
    typedef std::set
        < std::pair<MovableObject *, MovableObject *> > MovableSet;

    MovableSet set;

    // Iterate over all movable types
    Root::MovableObjectFactoryIterator factIt = 
        Root::getSingleton().getMovableObjectFactoryIterator();
    while(factIt.hasMoreElements())
    {
        SceneManager::MovableObjectIterator it = 
            mParentSceneMgr->getMovableObjectIterator(
            factIt.getNext()->getType());
        while( it.hasMoreElements() )
        {

            MovableObject * e = it.getNext();

            std::list< SceneNode * > list;
            //find the nodes that intersect the AAB
            static_cast<OctreeSceneManager*>( mParentSceneMgr ) -> findNodesIn( e->getWorldBoundingBox(), list, 0 );
            //grab all moveables from the node that intersect...
            std::list< SceneNode * >::iterator nit = list.begin();
            while( nit != list.end() )
            {
                SceneNode::ObjectIterator oit = (*nit) -> getAttachedObjectIterator();
                while( oit.hasMoreElements() )
                {
                    MovableObject * m = oit.getNext();

                    if( m != e &&
                            set.find( MovablePair(e,m)) == set.end() &&
                            set.find( MovablePair(m,e)) == set.end() &&
                            (m->getQueryFlags() & mQueryMask) &&
                            (m->getTypeFlags() & mQueryTypeMask) &&
                            m->isInScene() && 
                            e->getWorldBoundingBox().intersects( m->getWorldBoundingBox() ) )
                    {
                        listener -> queryResult( e, m );
                        // deal with attached objects, since they are not directly attached to nodes
                        if (m->getMovableType() == "Entity")
                        {
                            Entity* e2 = static_cast<Entity*>(m);
                            Entity::ChildObjectListIterator childIt = e2->getAttachedObjectIterator();
                            while(childIt.hasMoreElements())
                            {
                                MovableObject* c = childIt.getNext();
                                if (c->getQueryFlags() & mQueryMask && 
                                    e->getWorldBoundingBox().intersects( c->getWorldBoundingBox() ))
                                {
                                    listener->queryResult(e, c);
                                }
                            }
                        }
                    }
                    set.insert( MovablePair(e,m) );

                }
                ++nit;
            }

        }
    }
}
Example #12
0
bool KingMovementAnimation::animate(const Real& timeSinceLastFrame)
{
    Real distanceMoved = MOVEMENT_SPEED * timeSinceLastFrame;
    Vector3 path = mDestination - mAnimatedNode->getPosition();
    path.y = 0;
    Real verticalVelocity = (path.length() - mHalfTotalDistance) * mFlyingAltitude;

    if (path.length() > distanceMoved || mParticleNode)
    {
        switch (mPhase)
        {
            case 1:
                if (verticalVelocity <= 0)
                {
                    mPhase = 2;
                }
                break;
            case 2:
                if (mAttackDuration >= 0)
                {
                    if (!mParticleNode)
                    {
                        createBlasts();
                        mAnimationManager->addAnimation(
                            AnimationFactory::createDyingAnimation(
                            mTargetPiece, mSceneMgr, 2, 3));
                        mAnimationManager->addAnimation(
                            AnimationFactory::createBleedingAnimation(
                            mTargetPiece, mSceneMgr, 0.2, 2.5));
                        mAnimationManager->addAnimation(
                            AnimationFactory::createBleedingAnimation(
                            mTargetPiece, mSceneMgr, 0.2, 2, "Effects/Smoke"));
                    }

                    distanceMoved = 0;
                    mAttackDuration -= timeSinceLastFrame;
                }
                else
                {
                    mPhase = 3;
                    if (mParticleNode)
                    {
                        SceneNode::ObjectIterator itr = mParticleNode->getAttachedObjectIterator();
                        while (itr.hasMoreElements())
                        {
                            MovableObject* object = itr.getNext();
                            mSceneMgr->destroyMovableObject(object);
                        }
                        mAnimatedNode->removeAndDestroyChild(mParticleNode->getName());
                        mParticleNode = 0;
                    }
                }
                break;
        }


        if (distanceMoved > 0)
        {
            mAnimatedNode->translate(Vector3(0, verticalVelocity * timeSinceLastFrame, 0)); 

            Vector3 realPath = path;

            // Normalising the vector so the speed remains constant.
            path.normalise();
            mAnimatedNode->translate(path * distanceMoved);

            mAnimatedNode->resetOrientation();
            Vector3 src = Vector3::UNIT_Z;
            mAnimatedNode->rotate(src.getRotationTo(path));
            
            if (mTargetPiece)
            {
                Real pitch = realPath.length() * 45 / mHalfTotalDistance;
                if (mPhase == 1)
                {
                    pitch = 90 - pitch;
                }
                mAnimatedNode->pitch(Degree(pitch));
            }

            mAnimatedNode->yaw(Degree(realPath.length() * 360 / mHalfTotalDistance));

        }
        return true; // Animation still running.
    }

    mAnimatedNode->setPosition(mDestination);
    mAnimatedNode->setOrientation(mAnimatedNode->getInitialOrientation());
    return false; // Animation finished.
}