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