[1568] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | You may use this sample code for anything you like, it is not covered by the
|
---|
| 11 | LGPL like the rest of the engine.
|
---|
| 12 | -----------------------------------------------------------------------------
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | /**
|
---|
| 16 | \file
|
---|
| 17 | Lighting.h
|
---|
| 18 | \brief
|
---|
| 19 | Shows lighting support in OGRE. Also demonstrates the use of billboards
|
---|
| 20 | and controllers for automatic time-relative behaviour.
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | #include "ExampleApplication.h"
|
---|
| 25 | #include "OgreIlluminationManager.h"
|
---|
| 26 | #include "SpriteParticleRenderer.h"
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | // Listener class for frame updates
|
---|
| 30 | class ParticleDemoFrameListener : public ExampleFrameListener
|
---|
| 31 | {
|
---|
| 32 | protected:
|
---|
| 33 |
|
---|
| 34 | unsigned long framecount;
|
---|
| 35 |
|
---|
| 36 | public:
|
---|
| 37 | ParticleDemoFrameListener(RenderWindow* window, Camera* maincam)
|
---|
| 38 | :ExampleFrameListener(window, maincam)
|
---|
| 39 |
|
---|
| 40 | {
|
---|
| 41 | framecount = 0;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | bool frameStarted(const FrameEvent& evt)
|
---|
| 45 | {
|
---|
| 46 | bool result = ExampleFrameListener::frameStarted(evt);
|
---|
| 47 | framecount++;
|
---|
| 48 | return result;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | /** Application class */
|
---|
| 56 | class ParticleDemoApplication : public ExampleApplication
|
---|
| 57 | {
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
| 60 |
|
---|
| 61 | protected:
|
---|
| 62 | SceneNode* kupolaNode;
|
---|
| 63 | SceneNode* mainLightNode;
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | void createPostproc()
|
---|
| 67 | {
|
---|
[1683] | 68 |
|
---|
| 69 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
[1568] | 70 | "GameTools/Glow");
|
---|
| 71 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
[1683] | 72 | "GameTools/Glow", true);
|
---|
| 73 |
|
---|
[1568] | 74 | CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
|
---|
| 75 | "GameTools/ToneMap");
|
---|
| 76 | CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
|
---|
[1683] | 77 | "GameTools/ToneMap", true);
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 |
|
---|
[1568] | 81 | }
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | void createScene(void)
|
---|
| 85 | {
|
---|
| 86 | createPostproc();
|
---|
| 87 |
|
---|
| 88 | OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
|
---|
| 89 | OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
|
---|
| 90 |
|
---|
| 91 | Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
|
---|
| 92 | mCamera->setPosition(0,100,240);
|
---|
| 93 | mCamera->setFOVy(Radian(Degree(80)));
|
---|
| 94 | //mCamera->setFarClipDistance(1000);
|
---|
| 95 | // Set ambient light
|
---|
| 96 | mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));
|
---|
| 97 |
|
---|
| 98 | // Skybox
|
---|
| 99 | mSceneMgr->setSkyBox(true, "Examples/MorningSkyBox");
|
---|
| 100 | SceneNode* rootNode = mSceneMgr->getRootSceneNode();
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | //init objects
|
---|
| 104 | Entity* kupola = mSceneMgr->createEntity("kupola", "kupola.mesh");
|
---|
| 105 | kupola->getSubEntity(0)->setMaterialName("kupolafal_low");
|
---|
| 106 | kupola->getSubEntity(1)->setMaterialName("kupolatalaj_low");
|
---|
| 107 | Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
|
---|
| 108 |
|
---|
| 109 | //init nodes
|
---|
| 110 | kupolaNode = rootNode->createChildSceneNode( "kupola" );
|
---|
| 111 | kupolaNode->rotate(Vector3(0,1,0),Radian(Degree(90)));
|
---|
| 112 | kupolaNode->attachObject( kupola );
|
---|
| 113 | kupolaNode->scale(25,21,25);
|
---|
| 114 | kupolaNode->_updateBounds();
|
---|
| 115 | MeshPtr kmesh = kupola->getMesh();
|
---|
| 116 | kmesh->buildTangentVectors(0,1);
|
---|
| 117 |
|
---|
| 118 | SceneNode* headNode = rootNode->createChildSceneNode("head");
|
---|
| 119 | headNode->attachObject(head);
|
---|
| 120 | headNode->setScale(2,2,2);
|
---|
| 121 | AxisAlignedBox bbox = head->getBoundingBox();
|
---|
| 122 | headNode->setPosition(0, 100,0);
|
---|
| 123 | headNode->_updateBounds();
|
---|
[1683] | 124 |
|
---|
[1568] | 125 |
|
---|
| 126 |
|
---|
| 127 | //Init lights
|
---|
| 128 | /* Light* mainLight = mSceneMgr->createLight("MainLight");
|
---|
| 129 | mainLight->setType(Light::LT_POINT);
|
---|
| 130 | mainLight->setDiffuseColour(ColourValue(0.9,0.9,0.9,1));
|
---|
| 131 | mainLight->setSpecularColour(ColourValue(0.9, 0.9,0.9,1));
|
---|
| 132 | mainLight->setAttenuation(400, 1.0, 1, 1);
|
---|
| 133 | mainLightNode = rootNode->createChildSceneNode();
|
---|
| 134 | mainLightNode->setPosition(0,150,0);
|
---|
| 135 | mainLight->setPosition(mainLightNode->getWorldPosition());
|
---|
| 136 | mainLightNode->attachObject(mainLight); */
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | void createFrameListener(void)
|
---|
| 142 | {
|
---|
| 143 | // This is where we instantiate our own frame listener
|
---|
| 144 | mFrameListener= new ParticleDemoFrameListener(mWindow,
|
---|
| 145 | mCamera );
|
---|
| 146 | mRoot->addFrameListener(mFrameListener);
|
---|
| 147 | mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | };
|
---|
| 151 |
|
---|