//----------------------------------------------------------------------- void PagingLandScapePageManager::updateLoadedPages() { // Make any pending updates to the calculated frustum mCurrentcam->updateView(); const Vector3 pos(mCurrentcam->getDerivedPosition().x, 127.0f, mCurrentcam->getDerivedPosition().z); for (PagingLandScapePageList::iterator it = mLoadedPages.begin(); it != mLoadedPages.end(); ++it) { PagingLandScapePage* p = (*it); unsigned int x, z; p->getCoordinates(x, z); if ((z >= mCurrentcam->mIniZ) && (z <= mCurrentcam->mFinZ) && (x >= mCurrentcam->mIniX) && (x <= mCurrentcam->mFinX)) { // inform pages that they are near Camera on next render. if (p->notify(pos, mCurrentcam)) { // get pages that need modification and are visible.. PagingLandScapeTexture* tex = mTexture->getTexture(x, z); assert(tex); } } else { // hide page not visible by this Camera p->show(false); } } // reset state variable mOptions->lightmoved = false; }
//----------------------------------------------------------------------- // 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; }