Ignore:
Timestamp:
08/08/06 18:25:06 (18 years ago)
Author:
szydlowski
Message:

visualization in test app working, some issues to resolve

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp

    r1165 r1187  
    122122                mTopCam->setPosition(Vector3(1232, 3990, -1477)); 
    123123                // walkthrough view 
    124                 mCamera->setPosition(Vector3(1102.56, 181.845, -350.305)); 
    125                 mCamera->setOrientation(Quaternion(-0.977321, -0.117497, -0.174903, 0.0210273)); 
     124                mCamNode->setPosition(Vector3(1102.56, 181.845, -350.305)); 
     125                //mCamNode->setOrientation(Quaternion(-0.977321, -0.117497, -0.174903, 0.0210273)); 
     126 
     127                mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 
    126128        } 
    127129        else 
    128130        { 
     131                mCamNode->setPosition(Vector3(1280,600,1666)); 
     132                mCamNode->setOrientation(Quaternion(0.936893, -0.124586, 0.323813, 0.04306)); 
     133                //mCamera->lookAt(Vector3(-20,30,10)); 
     134 
    129135                SceneNode *anchor = mSceneMgr->getRootSceneNode()->createChildSceneNode("AnchorNode"); 
    130136                //SceneNode *grndan = anchor->createChildSceneNode("GroundAnchor"); 
     
    244250 
    245251                // Skybox 
    246                 // mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", mPlaneDim * 2); 
    247          
     252                mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", mPlaneDim * 2); 
    248253        } 
    249254 
     
    271276        mFrameListener->showDebugOverlay( true ); 
    272277        mRoot->addFrameListener(mFrameListener); 
     278        mWindow->addListener(new KdTreeAppRenderTargetListener(mSceneMgr)); 
    273279} 
    274280 
     
    283289    // Create the camera 
    284290    mCamera = mSceneMgr->createCamera("PlayerCam"); 
     291        mCamera->setNearClipDistance(1); 
     292 
     293        mCamNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("PlayerCamNode", Vector3(0,0,0)); 
     294        mCamNode->attachObject(mCamera); 
     295         
    285296 
    286297    // Position it at 500 in Z direction 
    287298    //mCamera->setPosition(Vector3(0,50,500)); 
    288299        //mCamera->setPosition(Vector3(500,256,666)); 
    289         mCamera->setPosition(Vector3(1280,600,1666)); 
     300        //mCamera->setPosition(Vector3(1280,600,1666)); 
    290301    // Look back along -Z 
    291302    //mCamera->lookAt(Vector3(0,50,-300)); 
    292         mCamera->lookAt(Vector3(-20,30,10)); 
    293     mCamera->setNearClipDistance(5); 
    294  
    295         mFollowCam = mSceneMgr->createCamera("FollowCam"); 
    296         mFollowCam->setPosition(Vector3(800,150,800)); 
    297         mFollowCam->setNearClipDistance(5); 
    298         mFollowCam->setFOVy(Angle(15)); 
     303        //mCamera->lookAt(Vector3(-20,30,10)); 
     304 
     305        //mFollowCam = mSceneMgr->createCamera("FollowCam"); 
     306        //mFollowCam->setPosition(Vector3(800,150,800)); 
     307        //mFollowCam->setNearClipDistance(5); 
     308        //mFollowCam->setFOVy(Angle(15)); 
    299309 
    300310        mTopCam = mSceneMgr->createCamera("TopCam"); 
     
    303313        mTopCam->pitch(Radian(-Math::HALF_PI)); 
    304314        mTopCam->setCullingFrustum(mCamera); 
    305         //mTopCam->setProjectionType(PT_ORTHOGRAPHIC); 
    306         //mTopCam->lookAt(Vector3(0,0,0)); 
     315        mTopCam->setNearClipDistance(1); 
     316 
     317        // infinite far plane? 
     318        if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 
     319        { 
     320                mTopCam->setFarClipDistance(0); 
     321                mCamera->setFarClipDistance(0); 
     322        } 
     323        else 
     324        { 
     325                mTopCam->setFarClipDistance(20000); 
     326                mCamera->setFarClipDistance(20000); 
     327        }        
    307328} 
    308329 
     
    445466        return false; 
    446467} 
     468 
     469/**********************************************************************/ 
     470/*           VisualizationRenderTargetListener implementation         */ 
     471/**********************************************************************/ 
     472 
     473 
     474//----------------------------------------------------------------------- 
     475KdTreeAppRenderTargetListener::KdTreeAppRenderTargetListener(SceneManager *sceneMgr) 
     476:RenderTargetListener(), mSceneMgr(sceneMgr) 
     477{ 
     478} 
     479//----------------------------------------------------------------------- 
     480void KdTreeAppRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt) 
     481{ 
     482        // visualization viewport 
     483        const bool showViz = evt.source->getZOrder() == VIZ_VIEWPORT_Z_ORDER; 
     484        const bool nShowViz = !showViz; 
     485 
     486        mSavedShadowTechnique = mSceneMgr->getShadowTechnique(); 
     487        mSavedAmbientLight = mSceneMgr->getAmbientLight(); 
     488 
     489        // -- ambient light must be full for visualization, shadows disabled 
     490        if (showViz) 
     491        { 
     492                mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 
     493                mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); 
     494        } 
     495 
     496        mSceneMgr->setOption("PrepareVisualization", &showViz); 
     497        mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 
     498        //mSceneMgr->setOption("SkyPlaneEnabled", &showViz); 
     499 
     500        RenderTargetListener::preViewportUpdate(evt); 
     501} 
     502//----------------------------------------------------------------------- 
     503void KdTreeAppRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt) 
     504{ 
     505        // reset values 
     506        mSceneMgr->setShadowTechnique(mSavedShadowTechnique); 
     507        mSceneMgr->setAmbientLight(mSavedAmbientLight); 
     508 
     509        RenderTargetListener::postRenderTargetUpdate(evt); 
     510} 
Note: See TracChangeset for help on using the changeset viewer.