Пример #1
0
	//-----------------------------------------------------------------------
	void InstanceBatch::_updateBounds(void)
	{
		mFullBoundingBox.setNull();

		InstancedEntityVec::const_iterator itor = mInstancedEntities.begin();
		InstancedEntityVec::const_iterator end  = mInstancedEntities.end();

		Real maxScale = 0;
		while( itor != end )
		{
			InstancedEntity* ent = (*itor);
			//Only increase the bounding box for those objects we know are in the scene
			if( ent->isInScene() )
			{
				maxScale = std::max(maxScale, ent->getMaxScaleCoef());
				mFullBoundingBox.merge( ent->_getDerivedPosition() );
			}

			++itor;
		}

		Real addToBound = maxScale * _getMeshReference()->getBoundingSphereRadius();
		mFullBoundingBox.setMaximum(mFullBoundingBox.getMaximum() + addToBound);
		mFullBoundingBox.setMinimum(mFullBoundingBox.getMinimum() - addToBound);


		mBoundingRadius = Math::boundingRadiusFromAABB( mFullBoundingBox );

		//Tell the SceneManager our bounds have changed
		getParentSceneNode()->needUpdate(true);

		mBoundsDirty	= false;
		mBoundsUpdated	= true;
	}
Пример #2
0
	// 更新包围盒
	void TerrainImpl::updateBounds()
	{
		m_aabb.setNull();
		for (size_t i = 0; i < mTiles.size(); ++i)
		{
			for (size_t j = 0; j < mTiles[i].size(); ++j)
			{
				// update this tile
				m_aabb.merge(mTiles[i][j]->getBoundingBox());
			}
		}
		if(getParentSceneNode())
		{
			getParentSceneNode()->needUpdate();
		}
	}
Пример #3
0
    //-----------------------------------------------------------------------------------
    void WireAabb::track( const MovableObject *movableObject )
    {
        assert( this != movableObject );

        if( mTrackedObject )
            mManager->_removeWireAabb( this );

        mTrackedObject = movableObject;

        if( mTrackedObject )
            mManager->_addWireAabb( this );

        if( !mTrackedObject && mParentNode )
        {
            //Not tracking anymore, need to get rid of our SceneNode
            SceneNode *sceneNode = getParentSceneNode();
            sceneNode->getParentSceneNode()->removeAndDestroyChild( sceneNode );
            mParentNode = 0;
        }
        else if( mTrackedObject && !mParentNode )
        {
            //Started tracking, we need a node of our own.
            SceneNode *newNode = mManager->getRootSceneNode()->createChildSceneNode();
            newNode->attachObject( this );
        }
    }
Пример #4
0
Ogre::Real DeferredLight::getSquaredViewDepth(const Ogre::Camera* camera) const {
    if (ignoreWorld) {
        return 0.0;
    } else {
        Ogre::Vector3 dist = camera->getDerivedPosition() - getParentSceneNode()->_getDerivedPosition();
        return dist.squaredLength();
    }
}
Пример #5
0
  void NavigationInputGeometry::calculateExtents( const OgreItemVector& entities )
  {
    auto entity = entities[0];
    auto bbox = entity->getLocalAabb();

    Matrix4 transform = mReferenceNode->_getFullTransformUpdated().inverse() * entity->getParentSceneNode()->_getFullTransformUpdated();
    assert( transform.isAffine() );
    bbox.transformAffine( transform );

    Vector3 bbmin = bbox.getMinimum();
    Vector3 bbmax = bbox.getMaximum();

    for ( auto iterator : entities )
    {
      entity = iterator;
      bbox = entity->getLocalAabb();
      transform = mReferenceNode->_getFullTransformUpdated().inverse() * entity->getParentSceneNode()->_getFullTransformUpdated();
      assert( transform.isAffine() );
      bbox.transformAffine( transform );

      Vector3 min2 = bbox.getMinimum();
      if ( min2.x < bbmin.x )
        bbmin.x = min2.x;
      if ( min2.y < bbmin.y )
        bbmin.y = min2.y;
      if ( min2.z < bbmin.z )
        bbmin.z = min2.z;

      Vector3 max2 = bbox.getMaximum();
      if ( max2.x > bbmax.x )
        bbmax.x = max2.x;
      if ( max2.y > bbmax.y )
        bbmax.y = max2.y;
      if ( max2.z > bbmax.z )
        bbmax.z = max2.z;
    }

    Math::ogreVec3ToFloatArray( bbmin, mBBoxMin );
    Math::ogreVec3ToFloatArray( bbmax, mBBoxMax );
  }
    InstanceBatch::~InstanceBatch()
    {
        deleteAllInstancedEntities();

        //Remove the parent scene node automatically
        SceneNode *sceneNode = getParentSceneNode();
        if( sceneNode )
        {
            sceneNode->detachAllObjects();
            sceneNode->getParentSceneNode()->removeAndDestroyChild( sceneNode->getName() );
        }

        if( mRemoveOwnVertexData )
            OGRE_DELETE mRenderOperation.vertexData;
        if( mRemoveOwnIndexData )
            OGRE_DELETE mRenderOperation.indexData;

    }
void PlanetMovable::_updateRenderQueue(RenderQueue* queue) {
    if (mCube) {
        mCube->updateRenderQueue(queue, getParentSceneNode()->_getFullTransform());
    }
}