Ignore:
Timestamp:
05/19/05 17:30:36 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/work/TestCullingTerrain
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp

    r97 r104  
    8282} 
    8383//----------------------------------------------------------------------- 
     84RayQueryExecutor *TerrainContentGenerator::GetRayQueryExecutor() 
     85{ 
     86        return mRayQueryExecutor; 
     87} 
     88//----------------------------------------------------------------------- 
    8489void TerrainContentGenerator::SetMaxHeight(Real maxHeight) 
    8590{ 
  • trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h

    r85 r104  
    3535        void SetMaxHeight(Real maxHeight); 
    3636         
     37        RayQueryExecutor *GetRayQueryExecutor(); 
     38 
    3739protected: 
    3840        RayQueryExecutor *mRayQueryExecutor; 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrain.vcproj

    r100 r104  
    122122                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 
    123123                        <File 
     124                                RelativePath=".\IoManager.cpp"> 
     125                        </File> 
     126                        <File 
    124127                                RelativePath="..\TestCulling\SceneContentGenerator.cpp"> 
    125128                        </File> 
     
    136139                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 
    137140                        <File 
     141                                RelativePath=".\IoManager.h"> 
     142                        </File> 
     143                        <File 
    138144                                RelativePath="..\TestCulling\SceneContentGenerator.h"> 
    139145                        </File> 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r103 r104  
    6868        else 
    6969        { 
    70                  mVizCamera->setFarClipDistance(1000); 
    71                  mCamera->setFarClipDistance(1000); 
     70                 mVizCamera->setFarClipDistance(20000); 
     71                 mCamera->setFarClipDistance(20000); 
    7272        }        
    7373} 
     
    191191mVizCameraHeight(Real(2500.0)), 
    192192mCamNode(camNode), 
    193 mCullCamera(false) 
     193mCullCamera(false), 
     194mDirection(Vector3::ZERO), 
     195mDistance(0) 
    194196{ 
    195197        // Reduce move speed 
     
    238240        mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 
    239241        mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
     242 
     243        // Create the walking list 
     244        Vector3 queryResult; 
     245 
     246        mWalkList.push_back(Vector3(1550.0f, 5000.0f, 250.0f)); 
     247        mWalkList.push_back(Vector3(100.0f, 5000.0f, 750.0f)); 
     248 
     249        mTerrainContentGenerator->GenerateSceneObject(mCamera->getPosition(), Vector3::ZERO, "knot.mesh"); 
     250        mTerrainContentGenerator->GenerateSceneObject(Vector3(1550.0f, 5000.0f, 250.0f), Vector3::ZERO, "knot.mesh"); 
     251        mTerrainContentGenerator->GenerateSceneObject(Vector3(100.0f, 5000.0f, 750.0f), Vector3::ZERO, "knot.mesh"); 
    240252 
    241253        pOver->show(); 
     
    322334} 
    323335//----------------------------------------------------------------------- 
     336bool MouseQueryListener::NextLocation() 
     337{ 
     338        if (mWalkList.empty()) 
     339        { 
     340                return false; 
     341        } 
     342 
     343        mDestination = mWalkList.front();  // this gets the front of the deque 
     344        mWalkList.pop_front();             // this removes the front of the deque 
     345  
     346        mDirection = mDestination - mCamNode->getPosition(); 
     347        mDistance = mDirection.normalise(); 
     348  
     349        // change facing 
     350        Vector3 src = mCamNode->getOrientation() * Vector3::UNIT_X; 
     351 
     352        if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) 
     353        { 
     354                mCamNode->yaw(Degree(180)); 
     355        } 
     356        else 
     357        { 
     358                Ogre::Quaternion quat = src.getRotationTo(mDirection); 
     359                mCamNode->rotate(quat); 
     360        } 
     361 
     362        return true; 
     363} 
     364//----------------------------------------------------------------------- 
    324365bool MouseQueryListener::frameStarted(const FrameEvent &evt) 
    325366{ 
    326         clamp2Terrain(); 
     367        if (mDirection != Vector3::ZERO) 
     368        { 
     369                Real move = mWalkSpeed * evt.timeSinceLastFrame; 
     370                mDistance -= move; 
     371  
     372                // If we are very close, just jump to the point 
     373                if (mDistance <= 0.0f) 
     374                { 
     375                        mCamNode->setPosition(mDestination); 
     376                        mDirection = Vector3::ZERO; 
     377                }  
     378                // Otherwise, move some some 
     379                else 
     380                { 
     381                        mCamNode->translate(mDirection * move); 
     382                } 
     383        }  
     384 
     385        Clamp2Terrain(); 
    327386 
    328387        if (mShowVisualization) 
     
    346405                mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x,  
    347406                        -mCamera->getDerivedDirection().z)); 
     407                 
     408                mVizCamera->moveRelative(Vector3(0, 800, 0)); 
    348409        } 
    349410 
     
    351412} 
    352413//----------------------------------------------------------------------- 
    353 void MouseQueryListener::clamp2Terrain() 
     414void MouseQueryListener::Clamp2Terrain() 
    354415{ 
    355416        // clamp to terrain 
     
    379440        KEY_PRESSED(KC_1, 0.3, toggleShowViz()); 
    380441        KEY_PRESSED(KC_2, 0.3, toggleRenderNodesForViz()); 
    381  
    382         if (!mShowVisualization) 
    383         { 
    384                 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
    385                 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
    386         } 
    387         else 
    388         { 
    389                 KEY_PRESSED(KC_SUBTRACT, 0, zoomVizCamera(50)); 
    390                 KEY_PRESSED(KC_ADD, 0, zoomVizCamera(-50)); 
    391         } 
    392  
     442        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
     443        KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
     444        KEY_PRESSED(KC_3, 0, zoomVizCamera(50)); 
     445        KEY_PRESSED(KC_4, 0, zoomVizCamera(-50)); 
     446         
    393447        updateStats(); 
    394448 
     
    521575                //vizvp->setClearEveryFrame(false); 
    522576 
    523                 // Create a skyplane (for visualization) 
    524                 /*Plane plane; 
    525                 plane.d = 1000; 
     577                // Create a skyplane (for visualization background) 
     578                /* 
     579                Plane plane; 
     580                plane.d = -1000; 
    526581                plane.normal = Vector3::UNIT_Y; 
    527                 mSceneMgr->setSkyPlane( true, plane, "Examples/Rockwall", 4000, 75, false); 
     582                mSceneMgr->setSkyPlane(true, plane, "Examples/TransparentTest", 4000, 75, false); 
    528583                */ 
     584                 
    529585        } 
    530586        else 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r103 r104  
    8888        void moveCamera(); 
    8989 
     90 
    9091protected: 
    91         void clamp2Terrain(); 
     92        void Clamp2Terrain(); 
     93 
     94        bool NextLocation(); 
    9295 
    9396    bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down 
     
    128131        Camera *mVizCamera; 
    129132        SceneNode *mCamNode; 
     133        Real mWalkSpeed; 
     134        Real mDistance; 
     135        Vector3 mDestination; 
     136        Vector3 mDirection; 
    130137 
     138        std::deque<Vector3> mWalkList;   // The list of points we are walking to 
    131139}; 
    132140 
Note: See TracChangeset for help on using the changeset viewer.