コード例 #1
0
//-----------------------------------------------------------------------
void PagingLandScapePageManager::queuePageNeighbors()
{
  // Queue the rest				
  // Loading  must be done one by one to avoid FPS drop, so they are queued.
  // We must load the next visible LandScape pages, 
  // check the LandScape boundaries	

  for (unsigned int i = mCurrentcam->mPreIniX; i <= mCurrentcam->mPreFinX; i++) {
    for (unsigned int j = mCurrentcam->mPreIniZ; j <= mCurrentcam->mPreFinZ; j++) {
      // pages in this zone around camera, must be at
      // least preloading.  that means they can be
      // loaded too.
      PagingLandScapePage* p = getPage(i, j, true);

      if (!(p->isInLoadQueue() || p->isLoaded())) {
        if ((j >= mCurrentcam->mIniZ) && (j <= mCurrentcam->mFinZ) && (i >= mCurrentcam->mIniX) && (i <= mCurrentcam->mFinX)) {
          // pages in this tighter zone
          // around camera must be Loading
          // or Loaded as they may be
          // below camera very soon.
          removeFromQueues(p);
          mPageLoadQueue.push(p);
          p->setInQueue(PagingLandScapePage::QUEUE_LOAD);
        } else {
          // must be at least preloading
          p->preloadInBackground();
        }
      }

      p->touch();
    }
  }
}
        //-----------------------------------------------------------------------
		// Set the current page.  Must be called before Update().
		void SetPage( const PagingLandScapePage* page )
		{
			page_ = page;
			if( page_ && page_->isLoaded() )
			{
				page_->getCoordinates( pageX_, pageZ_ );
				pageData_ = dataMgr_->getData2D( pageX_, pageZ_, false );
			}
        }
        //-----------------------------------------------------------------------
		// Returns true if the vertex is included, or false if it is removed
		// by LOD. Requires local page coordinates.
		bool GetWorldVertex( int localPageX, int localPageZ, Vector3& vertex )
		{
			UpdateWithLocalPage( localPageX, localPageZ );
			bool included = ( renderLevel_.Floor( localPageX ) == localPageX &&
							  renderLevel_.Floor( localPageZ ) == localPageZ );
			if( page_ && page_->isLoaded() && pageData_ )
			{
				// TODO:  Do we really need to include the real data when the vertex
				// has been removed by lod? Or can we just stuff a dummy result in
				// here to fill out the array?
				vertex.y = pageData_->getHeight( localPageX, localPageZ );
				page_->getCoordinates( pageX_, pageZ_ );	
				vertex.x = PageToWorld( pageX_, localPageX, scale_.x, maxUnScaledX_, pageSize_ );
				vertex.z = PageToWorld( pageZ_, localPageZ, scale_.z, maxUnScaledZ_, pageSize_ );
			}
			return included;
        }
コード例 #4
0
//-----------------------------------------------------------------------
void PagingLandScapePageManager::processLoadQueues()
{
  SceneManager::CameraIterator camIt = mSceneManager->getCameraIterator();
  while (camIt.hasMoreElements()) {
    const Camera* currentCamera = camIt.getNext();
    const Vector3& cameraPos = currentCamera->getDerivedPosition();
    if (!cameraPos.isNaN()) {
      const Vector3 pos(cameraPos.x, 127.0f, cameraPos.z);

      if (!mPageLoadQueue.empty()) {
        // We Load nearest page in non-empty queue
        PagingLandScapePage* p = mPageLoadQueue.find_nearest(pos);
        if (p) {
          assert(p && !p->isLoaded ());
          assert(p->isInLoadQueue());
          p->load();
        }

        // rest of processing after eventPageLoaded received
      }
    }
  }
}