source: GTP/trunk/App/Demos/Illum/Ogre/src/GameToolsToneMapDemo/include/GameToolsToneMapDemo.h @ 2025

Revision 2025, 4.6 KB checked in by szirmay, 17 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10You may use this sample code for anything you like, it is not covered by the
11LGPL 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
30class ParticleDemoFrameListener : public ExampleFrameListener
31{
32protected:
33       
34        unsigned long framecount;
35       
36public:
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 */
56class ParticleDemoApplication : public ExampleApplication
57{
58
59public:
60
61protected:
62        SceneNode* kupolaNode;
63        SceneNode* mainLightNode;
64
65        void loadResources(void)
66        {
67                // Initialise, parse scripts etc
68                ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
69                ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
70                ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
71        }
72
73        void createPostproc()
74        {               
75                CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
76                                                                                                                "GTP/PostProc/Glow");
77                CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
78                                                                                                                "GTP/PostProc/Glow", true);
79
80                CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
81                                                                                                                "GTP/PostProc/ToneMap");
82                CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
83                                                                                                                "GTP/PostProc/ToneMap", true);         
84        }
85   
86        void createScene(void)
87    {
88                createPostproc();
89
90                OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
91                OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
92                               
93                Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
94                mCamera->setPosition(0,100,240);
95                mCamera->setFOVy(Radian(Degree(80)));
96                //mCamera->setFarClipDistance(1000);
97                // Set ambient light
98        mSceneMgr->setAmbientLight(ColourValue(0.2, 0.2, 0.2));
99
100                // Skybox
101        mSceneMgr->setSkyBox(true, "Examples/MorningSkyBox");
102                SceneNode* rootNode = mSceneMgr->getRootSceneNode();
103
104                //init objects
105                Entity* kupola = mSceneMgr->createEntity("kupola", "kupola.mesh");
106                kupola->getSubEntity(0)->setMaterialName("kupolafal_low");
107                kupola->getSubEntity(1)->setMaterialName("kupolatalaj_low");
108                Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
109                               
110                //init nodes
111                kupolaNode = rootNode->createChildSceneNode( "kupola" );
112                kupolaNode->rotate(Vector3(0,1,0),Radian(Degree(90)));
113                kupolaNode->attachObject( kupola );
114                kupolaNode->scale(25,21,25);           
115                kupolaNode->_updateBounds();
116                MeshPtr kmesh = kupola->getMesh();
117                kmesh->buildTangentVectors(0,1);
118               
119                SceneNode* headNode = rootNode->createChildSceneNode("head");
120                headNode->attachObject(head);
121                headNode->setScale(2,2,2);
122                AxisAlignedBox bbox = head->getBoundingBox();
123                headNode->setPosition(0, 100,0);               
124                headNode->_updateBounds();
125
126               
127
128                //Init lights
129        /*      Light* mainLight = mSceneMgr->createLight("MainLight");
130                mainLight->setType(Light::LT_POINT);
131                mainLight->setDiffuseColour(ColourValue(0.9,0.9,0.9,1));
132                mainLight->setSpecularColour(ColourValue(0.9, 0.9,0.9,1));
133                mainLight->setAttenuation(400, 1.0, 1, 1);
134                mainLightNode = rootNode->createChildSceneNode();
135                mainLightNode->setPosition(0,150,0);
136                mainLight->setPosition(mainLightNode->getWorldPosition());
137                mainLightNode->attachObject(mainLight);         */
138       
139               
140   }
141
142        void createFrameListener(void)
143    {
144                // This is where we instantiate our own frame listener
145                mFrameListener= new ParticleDemoFrameListener(mWindow,
146                                                                                        mCamera );
147                mFrameListener->setPriority(1);
148        mRoot->addFrameListener(mFrameListener);
149        OgreIlluminationManager::getSingleton().setPriority(2);
150        mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
151   }
152
153};
154
Note: See TracBrowser for help on using the repository browser.