source: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp @ 106

Revision 106, 21.9 KB checked in by mattausch, 19 years ago (diff)
Line 
1/**
2    \file
3        TestCullingTerrainApplication.cpp
4    \brief
5        Tests the visibility culling algorithm
6*/
7
8#include <OgreNoMemoryMacros.h>
9#include <CEGUI/CEGUI.h>
10#include <../CEGUIRenderer/include/OgreCEGUIRenderer.h>
11#include <../CEGUIRenderer/include/OgreCEGUIResourceProvider.h>
12#include <../CEGUIRenderer/include/OgreCEGUITexture.h>
13#include <OgreMemoryMacros.h>
14
15#include <Ogre.h>
16#include "OgreReferenceAppLayer.h"
17//#include "OgreRefAppWorld.h"
18#include "TestCullingTerrainApplication.h"
19
20#define WIN32_LEAN_AND_MEAN
21#include <windows.h>
22
23#define VIZ_VIEWPORT_Z_ORDER 10
24
25/*******************************************************/
26/*     TestCullingTerrainApplication implementation    */
27/*******************************************************/
28
29//-----------------------------------------------------------------------
30TestCullingTerrainApplication::~TestCullingTerrainApplication()
31{
32        if(mTerrainContentGenerator)
33                delete mTerrainContentGenerator;
34        //if(mRenderTargetListener)     delete mRenderTargetListener;
35}
36//-----------------------------------------------------------------------
37void TestCullingTerrainApplication::createCamera()
38{
39        // create the camera
40        mCamera = mSceneMgr->createCamera("PlayerCam");
41       
42        /** set a nice viewpoint
43        *       we use a camera node here and apply all transformations on it instead
44        *       of applying all transformations directly to the camera
45        *       because then the camera is displayed correctly in the visualization
46        */
47       
48        mCamNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(
49                "CamNode1", Vector3(707, 5000, 528));
50        //mCamera->setPosition(707, 5000, 528);
51        mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
52       
53        mCamNode->attachObject(mCamera);
54
55        //-- create visualization camera
56        mVizCamera = mSceneMgr->createCamera("VizCam");
57        mVizCamera->setPosition(mCamNode->getPosition());
58
59        mVizCamera->setNearClipDistance(1);
60        mCamera->setNearClipDistance(1);
61
62        // infinite far plane?
63        if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
64        {
65                mVizCamera->setFarClipDistance(0);
66                mCamera->setFarClipDistance(0);
67        }
68        else
69        {
70                 mVizCamera->setFarClipDistance(20000);
71                 mCamera->setFarClipDistance(20000);
72        }       
73}
74
75//-----------------------------------------------------------------------
76bool TestCullingTerrainApplication::setup()
77{
78        bool result = ExampleApplication::setup();
79
80        createRenderTargetListener();
81
82        return result;
83}
84//-----------------------------------------------------------------------
85void TestCullingTerrainApplication::createRenderTargetListener()
86{
87        mWindow->addListener(new VisualizationRenderTargetListener(mSceneMgr));
88}
89//-----------------------------------------------------------------------
90void TestCullingTerrainApplication::createScene()
91{
92        // Set ambient light
93        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
94       
95        // Create a light
96        Light* l = mSceneMgr->createLight("MainLight");
97        // Accept default settings: point light, white diffuse, just set position
98        // NB I could attach the light to a SceneNode if I wanted it to move automatically with
99        // other objects, but I don't
100        l->setPosition(20,80,50);
101
102        // --Fog
103        // NB it's VERY important to set this before calling setWorldGeometry
104        // because the vertex program picked will be different
105        ColourValue fadeColour(0.93, 0.86, 0.76);
106        mWindow->getViewport(0)->setBackgroundColour(fadeColour);
107        //mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000);
108       
109        // Create a skybox
110        mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 5000, false);
111       
112        std::string terrain_cfg("terrain.cfg");
113#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
114        terrain_cfg = mResourcePath + terrain_cfg;
115#endif
116        mSceneMgr->setWorldGeometry(terrain_cfg);
117       
118        //-- CEGUI setup
119        setupGui();
120
121        //-- terrain content setup
122
123        // HACK: necessary to call once before the content creation for
124        // terrain initialisation
125        mSceneMgr->_renderScene(mCamera, mWindow->getViewport(0), true);
126
127        mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr);
128        mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 5000.0f, 3000.0f));
129
130        mTerrainContentGenerator->GenerateScene(1500, "robot.mesh");
131//      mTerrainContentGenerator->GenerateScene(500, "ninja.mesh");
132
133        // no limitations needed anymore: the user can set
134        // objects also on peaks of terrain
135        mTerrainContentGenerator->SetMaxHeight(5000);
136}
137//-----------------------------------------------------------------------
138void TestCullingTerrainApplication::setupGui()
139{
140         mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY,
141                 false, 3000, ST_EXTERIOR_CLOSE);
142     mGUISystem = new CEGUI::System(mGUIRenderer);
143
144         // Mouse
145     CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
146     CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
147         mGUISystem->setDefaultMouseCursor(
148                (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
149
150         CEGUI::MouseCursor::getSingleton().show();
151}
152//-----------------------------------------------------------------------
153void TestCullingTerrainApplication::createFrameListener()
154{
155        mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr,
156                mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode);
157        mFrameListener->showDebugOverlay(true);
158        mRoot->addFrameListener(mFrameListener);
159}
160//-----------------------------------------------------------------------
161void TestCullingTerrainApplication::chooseSceneManager()
162{
163        mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
164}
165/***********************************************/
166/*      MouseQueryListener implementation      */
167/***********************************************/
168//-----------------------------------------------------------------------
169MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam,
170                                                                           SceneManager *sceneManager,
171                                                                           CEGUI::Renderer *renderer,
172                                                                           TerrainContentGenerator *sceneGenerator,
173                                                                           Camera *vizCamera,
174                                                                           SceneNode *camNode):
175ExampleFrameListener(win, cam, false, true),
176mGUIRenderer(renderer),
177mShutdownRequested(false),
178mLMouseDown(false),
179mRMouseDown(false),
180mSceneMgr(sceneManager),
181mCurrentObject(NULL),
182mTerrainContentGenerator(sceneGenerator),
183mVisibilityThreshold(0),
184mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING),
185mShowOctree(false),
186mUseVisibilityCulling(true),
187mUseOptimization(true),
188mVizCamera(vizCamera),
189mShowVisualization(false),
190mRenderNodesForViz(false),
191mVizCameraHeight(Real(2500.0)),
192mCamNode(camNode),
193mCullCamera(false),
194mState(WALKTHROUGH),
195mCurrentFrame(1)
196{
197        // Reduce move speed
198        mMoveSpeed = 50;
199        mRotateSpeed *= 2;
200   
201        // Register this so that we get mouse events.
202        mEventProcessor->addMouseListener(this);
203        mEventProcessor->addMouseMotionListener(this);
204        mEventProcessor->addKeyListener(this);
205
206        mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);
207       
208        // show overlay
209        Overlay* pOver = OverlayManager::getSingleton().getByName("Example/VisibilityDemoOverlay");
210
211        mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo");
212        mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo");
213       
214        mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/FrustumCulledNodesInfo");
215        mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueryCulledNodesInfo");
216    mTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TraversedNodesInfo");
217        mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo");
218        mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo");
219        mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");
220        mUseOptimizationInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseOptimizationInfo");
221        mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo");
222       
223        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);
224        mThresholdInfo->setCaption(": 0");
225        mFrustumCulledNodesInfo->setCaption(": 0");
226        mQueryCulledNodesInfo->setCaption(": 0");
227        mTraversedNodesInfo->setCaption(": 0");
228        mHierarchyNodesInfo->setCaption(": 0");
229        mRenderedNodesInfo->setCaption(": 0");
230        mObjectsInfo->setCaption(": 0");
231        mUseOptimizationInfo->setCaption(": true");
232        mQueriesIssuedInfo->setCaption(": 0");
233
234        setAlgorithm(mCurrentAlgorithm);
235
236        mSceneMgr->setOption("UseOptimization", &mUseOptimization);
237        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling);
238        mSceneMgr->setOption("ShowOctree", &mShowOctree);
239        mSceneMgr->setOption("CullCamera", &mCullCamera);
240        mSceneMgr->setOption("ShowVisualization", &mShowVisualization);
241        mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
242
243        pOver->show();
244}
245//-----------------------------------------------------------------------
246MouseQueryListener::~MouseQueryListener()
247{
248        delete mRayQueryExecutor;
249}
250//-----------------------------------------------------------------------
251void MouseQueryListener::mouseMoved(MouseEvent *e)
252{
253        // Update CEGUI with the mouse motion
254    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() *
255                mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight());
256}
257//-----------------------------------------------------------------------
258void MouseQueryListener::mousePressed(MouseEvent* e)
259{
260     // Left mouse button down
261     if (e->getButtonID() & InputEvent::BUTTON0_MASK)
262     {
263                 CEGUI::MouseCursor::getSingleton().hide();
264
265                 // Setup the ray scene query
266         Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY());
267   
268                 Vector3 queryResult;
269                 
270                 // Get results, create a node/entity on the position
271                 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject(
272                         mouseRay.getOrigin(), mouseRay.getDirection(), "robot.mesh");
273               
274         mLMouseDown = true;
275     }
276     // Right mouse button down
277     else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
278     {
279         CEGUI::MouseCursor::getSingleton().hide();
280         mRMouseDown = true;
281     }
282} // mousePressed
283//-----------------------------------------------------------------------
284void MouseQueryListener::mouseReleased(MouseEvent* e)
285{
286    // Left mouse button up
287    if (e->getButtonID() & InputEvent::BUTTON0_MASK)
288    {
289                CEGUI::MouseCursor::getSingleton().show();
290        mLMouseDown = false;
291    }
292    // Right mouse button up
293    else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
294    {
295        CEGUI::MouseCursor::getSingleton().show();
296        mRMouseDown = false;
297    }
298}
299//-----------------------------------------------------------------------
300void MouseQueryListener::mouseDragged(MouseEvent *e)
301 {
302         // If we are dragging the left mouse button.           
303         if (mLMouseDown)
304     {
305                 Vector3 queryResult;
306                 Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(), e->getY());
307
308                 if (mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay))
309                 {
310                         if (mCurrentObject)
311                         {
312                                 mCurrentObject->setPosition(queryResult);
313                         }
314                 }
315     }
316         // If we are dragging the right mouse button.
317         if (mRMouseDown)
318         {
319                 //mCamera->yaw(-e->getRelX() * mRotateSpeed);
320                 //mCamera->pitch(-e->getRelY() * mRotateSpeed);
321                 mCamNode->yaw(-e->getRelX() * mRotateSpeed);
322                 mCamNode->pitch(-e->getRelY() * mRotateSpeed);
323         }
324}
325//-----------------------------------------------------------------------
326bool MouseQueryListener::frameStarted(const FrameEvent &evt)
327{
328        switch (mState)
329        {
330        case REPLAY:
331                SetCurrentCameraPath(mCamNode);
332                mCamNode->setPosition(mCameraPath[mCurrentFrame].position);
333                mCamNode->setOrientation(mCameraPath[mCurrentFrame].orientation);
334                (mCurrentFrame++) % mCameraPath.size();
335                break;
336        case WALKTHROUGH:
337                Clamp2Terrain();
338
339        case RECORD:
340                AddCameraPath(mCamNode);
341                break;
342        default:
343                break;
344        };
345       
346        if (mShowVisualization)
347        {
348                // important for visualization => draw octree bounding boxes
349                mSceneMgr->setOption("ShowOctree", &mShowVisualization);
350                // also render geometry?
351                mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
352
353                // -- setup visualization camera
354                mVizCamera->setPosition(0, 0, 0);
355                mVizCamera->setOrientation(Quaternion::IDENTITY);
356
357                Vector3 camPos = mCamNode->getPosition();
358                mVizCamera->setPosition(camPos.x, mVizCameraHeight, camPos.z);
359
360                // Point down -Z axis
361                mVizCamera->pitch(Radian(Degree(270.0)));
362       
363                // Rotation arounnd X axis
364                mVizCamera->yaw(Math::ATan2(-mCamera->getDerivedDirection().x,
365                        -mCamera->getDerivedDirection().z));
366               
367                mVizCamera->moveRelative(Vector3(0, 800, 0));
368        }
369
370        return ExampleFrameListener::frameStarted(evt);
371}
372//-----------------------------------------------------------------------
373void MouseQueryListener::Clamp2Terrain()
374{
375        // clamp to terrain
376        Vector3 camPos = mCamNode->getPosition();
377        Vector3 queryResult;
378
379        if (mRayQueryExecutor->executeRayQuery(&queryResult,
380                        Vector3(camPos.x, 5000.0f, camPos.z), Vector3::NEGATIVE_UNIT_Y))
381        {
382                mCamNode->setPosition(camPos.x, queryResult.y + 10, camPos.z);
383        }
384}
385//-----------------------------------------------------------------------
386bool MouseQueryListener::frameEnded(const FrameEvent& evt)
387{
388        if (mShutdownRequested)
389                return false;
390
391    if (timeDelay >= 0)
392        timeDelay -= evt.timeSinceLastFrame;
393
394    KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm());
395
396        KEY_PRESSED(KC_O, 0.3, toggleUseOptimization());
397        KEY_PRESSED(KC_T, 0.3, toggleShowOctree());
398        KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling());
399        KEY_PRESSED(KC_1, 0.3, toggleShowViz());
400        KEY_PRESSED(KC_2, 0.3, toggleRenderNodesForViz());
401        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10));
402        KEY_PRESSED(KC_ADD, 0, changeThreshold(10));
403        KEY_PRESSED(KC_3, 0, zoomVizCamera(50));
404        KEY_PRESSED(KC_4, 0, zoomVizCamera(-50));
405        KEY_PRESSED(KC_F1, 0, setState(RECORD));
406        KEY_PRESSED(KC_F2, 0, setState(REPLAY));
407        KEY_PRESSED(KC_F3, 0, setState(WALKTHROUGH));
408        updateStats();
409
410        return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt);
411}
412void MouseQueryListener::moveCamera()
413{
414        mCamNode->yaw(mRotX);
415        mCamNode->pitch(mRotY);
416        mCamNode->translate(mCamNode->getLocalAxes(), mTranslateVector);
417}
418//-----------------------------------------------------------------------
419void MouseQueryListener::changeThreshold(int incr)
420{
421        mVisibilityThreshold += incr;
422        if(mVisibilityThreshold < 0) mVisibilityThreshold = 0;
423       
424        char str[100]; sprintf(str,": %d", mVisibilityThreshold);
425
426        mSceneMgr->setOption("Threshold", &mVisibilityThreshold);
427        mThresholdInfo->setCaption(str);
428}
429//-----------------------------------------------------------------------
430bool MouseQueryListener::processUnbufferedKeyInput(const FrameEvent& evt)
431{   
432        if (mInputDevice->isKeyDown(KC_RIGHT))
433        {
434                mCamNode->yaw(-mRotScale);
435                return true;
436        }
437        if (mInputDevice->isKeyDown(KC_LEFT))
438        {
439                mCamNode->yaw(mRotScale);
440                return true;
441        }
442
443        return ExampleFrameListener::processUnbufferedKeyInput(evt);
444}
445//-----------------------------------------------------------------------
446void MouseQueryListener::zoomVizCamera(int zoom)
447{
448        mVizCameraHeight += zoom;
449        if(mVizCameraHeight < 0) mVizCameraHeight = 0;
450}
451//-----------------------------------------------------------------------
452void MouseQueryListener::nextAlgorithm()
453{
454        mCurrentAlgorithm = ++mCurrentAlgorithm %
455                GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS,
456
457        setAlgorithm(mCurrentAlgorithm);
458}
459//-----------------------------------------------------------------------
460void MouseQueryListener::setAlgorithm(int algorithm)
461{
462        mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]);
463        mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm);
464}
465//-----------------------------------------------------------------------
466void MouseQueryListener::updateStats()
467{
468        unsigned int opt = 0;
469        char str[100];
470       
471        mSceneMgr->getOption("NumFrustumCulledNodes", &opt); sprintf(str,": %d", opt);
472        mFrustumCulledNodesInfo->setCaption(str);
473       
474        mSceneMgr->getOption("NumQueriesIssued", &opt); sprintf(str,": %d", opt);
475        mQueriesIssuedInfo->setCaption(str);
476       
477        mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt);
478        mQueryCulledNodesInfo->setCaption(str);
479       
480        mSceneMgr->getOption("NumTraversedNodes", &opt); sprintf(str,": %d", opt);
481        mTraversedNodesInfo->setCaption(str);
482
483        mSceneMgr->getOption("NumHierarchyNodes", &opt); sprintf(str,": %d", opt);
484        mHierarchyNodesInfo->setCaption(str);
485
486        mSceneMgr->getOption("NumRenderedNodes", &opt); sprintf(str,": %d", opt);
487        mRenderedNodesInfo->setCaption(str);
488
489        sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount());
490        mObjectsInfo->setCaption(str);
491}
492//-----------------------------------------------------------------------
493void MouseQueryListener::toggleUseOptimization()
494{
495        mUseOptimization = !mUseOptimization;
496
497        mSceneMgr->setOption("UseOptimization", &mUseOptimization);
498
499        if (mUseOptimization)
500                mUseOptimizationInfo->setCaption(": true");
501        else
502                mUseOptimizationInfo->setCaption(": false");
503}
504//-----------------------------------------------------------------------
505void MouseQueryListener::toggleShowOctree()
506{
507        mShowOctree = !mShowOctree;
508
509        mSceneMgr->setOption("ShowOctree", &mShowOctree);
510}
511//-----------------------------------------------------------------------
512void MouseQueryListener::toggleUseVisibilityCulling()
513{
514        mUseVisibilityCulling = !mUseVisibilityCulling;
515
516        mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling);
517}
518//-----------------------------------------------------------------------
519void MouseQueryListener::toggleShowViz()
520{
521        mShowVisualization = !mShowVisualization;
522
523        // create viewport with priority VIZ_VIEWPORT_Z_ORDER:
524        // will be rendered over standard viewport
525        if (mShowVisualization)
526        {       
527                Viewport *vizvp = mWindow->addViewport(mVizCamera,
528                        VIZ_VIEWPORT_Z_ORDER, 0.6, 0.6, 0.4, 0.4);
529                               
530                vizvp->setBackgroundColour(ColourValue(0.0, 0.3, 0.2, 1));
531
532                vizvp->setOverlaysEnabled(false);
533                // Alter the camera aspect ratio to match the viewport
534        mVizCamera->setAspectRatio(Real(vizvp->getActualWidth()) /
535                        Real(vizvp->getActualHeight()));
536                //vizvp->setClearEveryFrame(false);
537
538                // Create a skyplane (for visualization background)
539                /*
540                Plane plane;
541                plane.d = -1000;
542                plane.normal = Vector3::UNIT_Y;
543                mSceneMgr->setSkyPlane(true, plane, "Examples/TransparentTest", 4000, 75, false);
544                */
545               
546        }
547        else
548        {
549                mWindow->removeViewport(VIZ_VIEWPORT_Z_ORDER);
550                // if octree was enabled for visualization purpose
551                mSceneMgr->setOption("ShowOctree", &mShowOctree);
552        }
553}
554//-----------------------------------------------------------------------
555void MouseQueryListener::toggleRenderNodesForViz()
556{
557        mRenderNodesForViz = !mRenderNodesForViz;
558
559        mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
560}
561//-----------------------------------------------------------------------
562void MouseQueryListener::keyPressed(KeyEvent* e)
563{
564        if(e->getKey() == KC_ESCAPE)
565    {
566                mShutdownRequested = true;
567                e->consume();
568                return;
569        }
570
571        CEGUI::System::getSingleton().injectKeyDown(e->getKey());
572        CEGUI::System::getSingleton().injectChar(e->getKeyChar());
573        e->consume();
574}
575//-----------------------------------------------------------------------
576void MouseQueryListener::keyReleased(KeyEvent* e)
577{
578        CEGUI::System::getSingleton().injectKeyUp(e->getKey());
579        e->consume();
580}
581//-----------------------------------------------------------------------
582void MouseQueryListener::keyClicked(KeyEvent* e)
583{
584        // Do nothing
585        e->consume();
586}
587//-----------------------------------------------------------------------
588void MouseQueryListener::AddCameraPath(SceneNode *camNode)
589{
590        frame_info info;
591        info.orientation = mCamNode->getOrientation();
592        info.position = mCamNode->getPosition();
593        mCameraPath.push_back(info);
594}
595//-----------------------------------------------------------------------
596void MouseQueryListener::SetCurrentCameraPath(SceneNode *camNode)
597{
598        mCamNode->setPosition(mCameraPath[mCurrentFrame].position);
599        mCamNode->setOrientation(mCameraPath[mCurrentFrame].orientation);
600        (mCurrentFrame++) % mCameraPath.size();
601}
602
603/**************************************************************/
604/*      VisualizationRenderTargetListener implementation      */
605/**************************************************************/
606
607VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr)
608:RenderTargetListener(), mSceneMgr(sceneMgr)
609{
610}
611//-----------------------------------------------------------------------
612void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt)
613{
614        const bool showViz = evt.source->getZOrder() == VIZ_VIEWPORT_Z_ORDER; // visualization viewport
615        const bool nShowViz = !showViz;
616
617    mSceneMgr->setOption("ShowVisualization", &showViz);
618        mSceneMgr->setOption("SkyBoxEnabled", &nShowViz);
619        //mSceneMgr->setOption("SkyPlaneEnabled", &showViz);
620       
621        RenderTargetListener::preViewportUpdate(evt);
622}
623//-----------------------------------------------------------------------
624void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt)
625{
626        RenderTargetListener::postRenderTargetUpdate(evt);
627}
628//-----------------------------------------------------------------------
629INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
630{
631    // Create application object
632    TestCullingTerrainApplication app;
633
634        try
635        {
636        app.go();
637    }
638        catch( Ogre::Exception& e )
639        {
640        MessageBox( NULL, e.getFullDescription().c_str(),
641                        "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
642    }   
643
644    return 0;
645}
Note: See TracBrowser for help on using the repository browser.