[12] | 1 | /**
|
---|
| 2 | \file
|
---|
| 3 | TestCullingApplication.cpp
|
---|
| 4 | \brief
|
---|
| 5 | Tests the occlusion culling algorithm
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[28] | 8 | #pragma warning (push)
|
---|
| 9 | #pragma warning( disable : 4267 )
|
---|
| 10 |
|
---|
| 11 | #include <OgreNoMemoryMacros.h>
|
---|
| 12 | #include <CEGUI/CEGUI.h>
|
---|
| 13 | #include <../CEGUIRenderer/include/OgreCEGUIRenderer.h>
|
---|
| 14 | #include <../CEGUIRenderer/include/OgreCEGUIResourceProvider.h>
|
---|
| 15 | #include <../CEGUIRenderer/include/OgreCEGUITexture.h>
|
---|
| 16 | #include <OgreMemoryMacros.h>
|
---|
| 17 | #pragma warning (pop)
|
---|
| 18 | /*
|
---|
[18] | 19 | #include <CEGUI/CEGUIImageset.h>
|
---|
| 20 | #include <CEGUI/CEGUISystem.h>
|
---|
| 21 | #include <CEGUI/CEGUISchemeManager.h>
|
---|
| 22 | #include <CEGUI/CEGUIWindowManager.h>
|
---|
| 23 | #include <CEGUI/CEGUIWindow.h>
|
---|
| 24 | #include <CEGUI/CEGUILogger.h>
|
---|
| 25 | #include <CEGUI/elements/CEGUICombobox.h>
|
---|
| 26 | #include <CEGUI/elements/CEGUIListbox.h>
|
---|
| 27 | #include <CEGUI/elements/CEGUIListboxTextItem.h>
|
---|
| 28 | #include <CEGUI/elements/CEGUIPushButton.h>
|
---|
| 29 | #include <CEGUI/elements/CEGUIScrollbar.h>
|
---|
| 30 | #include <CEGUI/elements/CEGUIStaticImage.h>
|
---|
| 31 |
|
---|
| 32 | #include "OgreCEGUIRenderer.h"
|
---|
| 33 | #include "OgreCEGUIResourceProvider.h"
|
---|
[28] | 34 | */
|
---|
[12] | 35 | #include "Ogre.h"
|
---|
| 36 | #include "TestCullingApplication.h"
|
---|
| 37 |
|
---|
| 38 | #define WIN32_LEAN_AND_MEAN
|
---|
| 39 | #include "windows.h"
|
---|
| 40 |
|
---|
| 41 | void TestCullingApplication::createScene(void)
|
---|
| 42 | {
|
---|
| 43 | // Create a skybox
|
---|
| 44 | mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
|
---|
| 45 | mShip = mSceneMgr->createEntity("razor", "razor.mesh");
|
---|
| 46 | mShipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
---|
| 47 | mShipNode->attachObject(mShip);
|
---|
| 48 |
|
---|
| 49 | mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
|
---|
[18] | 50 |
|
---|
| 51 | // CEGUI setup
|
---|
| 52 | mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_GENERIC);
|
---|
| 53 | mGUISystem = new CEGUI::System(mGUIRenderer);
|
---|
| 54 |
|
---|
| 55 | // Mouse
|
---|
| 56 | CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
|
---|
| 57 | CEGUI::MouseCursor::getSingleton().setImage("TaharezLook", "MouseArrow");
|
---|
| 58 | mGUISystem->setDefaultMouseCursor(
|
---|
| 59 | (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
|
---|
| 60 |
|
---|
| 61 | CEGUI::MouseCursor::getSingleton().show( );
|
---|
| 62 |
|
---|
| 63 | /* CEGUI::Window* sheet =
|
---|
| 64 | CEGUI::WindowManager::getSingleton().loadWindowLayout(
|
---|
| 65 | (CEGUI::utf8*)"ogregui.layout");
|
---|
| 66 |
|
---|
| 67 | mGUISystem->setGUISheet(sheet);*/
|
---|
[12] | 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
[18] | 71 | /* MouseMotionListener callbacks */
|
---|
| 72 | void MouseQueryListener::mouseMoved (MouseEvent *e)
|
---|
| 73 | {
|
---|
| 74 | // Update CEGUI with the mouse motion
|
---|
| 75 | CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight());
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | void MouseQueryListener::mousePressed(MouseEvent* e)
|
---|
| 80 | {
|
---|
| 81 | // Left mouse button down
|
---|
| 82 | if (e->getButtonID() & InputEvent::BUTTON0_MASK)
|
---|
| 83 | {
|
---|
| 84 | CEGUI::MouseCursor::getSingleton().hide( );
|
---|
| 85 | mLMouseDown = true;
|
---|
| 86 | } // if
|
---|
| 87 | // Right mouse button down
|
---|
| 88 | else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
|
---|
| 89 | {
|
---|
| 90 | CEGUI::MouseCursor::getSingleton().hide( );
|
---|
| 91 | mRMouseDown = true;
|
---|
| 92 | } // else if
|
---|
| 93 | } // mousePressed
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | void MouseQueryListener::mouseReleased(MouseEvent* e)
|
---|
| 97 | {
|
---|
| 98 | // Left mouse button up
|
---|
| 99 | if (e->getButtonID() & InputEvent::BUTTON0_MASK)
|
---|
| 100 | {
|
---|
| 101 | CEGUI::MouseCursor::getSingleton().show( );
|
---|
| 102 | mLMouseDown = false;
|
---|
| 103 | } // if
|
---|
| 104 | // Right mouse button up
|
---|
| 105 | else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
|
---|
| 106 | {
|
---|
| 107 | CEGUI::MouseCursor::getSingleton().show( );
|
---|
| 108 | mRMouseDown = false;
|
---|
| 109 | } // else if
|
---|
| 110 | } // mouseReleased
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | // This is when the mouse is clicked, held and dragged.
|
---|
| 114 | void MouseQueryListener::mouseDragged (MouseEvent *e)
|
---|
| 115 | {
|
---|
| 116 | // If we are dragging the left mouse button.
|
---|
| 117 | if ( mLMouseDown )
|
---|
| 118 | {
|
---|
| 119 | mShipNode->translate(-e->getRelX() * 200, -e->getRelY() * 200, 0.0);
|
---|
| 120 | } // if
|
---|
| 121 |
|
---|
| 122 | // If we are dragging the right mouse button.
|
---|
| 123 | else if ( mRMouseDown )
|
---|
| 124 | {
|
---|
| 125 | mCamera->yaw( -e->getRelX() * mRotateSpeed );
|
---|
| 126 | mCamera->pitch( -e->getRelY() * mRotateSpeed );
|
---|
| 127 | } // else if
|
---|
| 128 | } // mouseDragged
|
---|
| 129 |
|
---|
| 130 |
|
---|
[12] | 131 | INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
|
---|
| 132 | {
|
---|
| 133 | // Create application object
|
---|
| 134 | TestCullingApplication app;
|
---|
| 135 |
|
---|
[16] | 136 | try {
|
---|
[12] | 137 | app.go();
|
---|
| 138 | } catch( Ogre::Exception& e ) {
|
---|
| 139 | MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
|
---|
[16] | 140 | }
|
---|
[12] | 141 |
|
---|
| 142 | return 0;
|
---|
[18] | 143 | } |
---|