Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main.cpp @ 60

Last change on this file since 60 was 60, checked in by landauf, 17 years ago

muloe

File size: 3.0 KB
Line 
1#include "ExampleApplication.h"
2
3SceneNode *lightNode;
4
5class TutorialFrameListener : public ExampleFrameListener
6{
7public:
8    TutorialFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr)
9        : ExampleFrameListener(win, cam, false, false)
10    {
11    }
12
13    bool frameStarted(const FrameEvent &evt)
14    {
15        // add tutorial code here:
16        // ...
17            lightNode->translate(Vector3(0, -10 * evt.timeSinceLastFrame, 0));
18           
19        return ExampleFrameListener::frameStarted(evt);
20    }
21private:
22};
23
24
25class TutorialApplication : public ExampleApplication
26{
27protected:
28public:
29    TutorialApplication()
30    {
31    }
32
33    ~TutorialApplication()
34    {
35    }
36protected:
37    void createCamera(void)
38    {
39        // create camera
40        mCamera = mSceneMgr->createCamera("PlayerCam");
41        mCamera->setNearClipDistance(5);
42        mCamera->setPosition(Vector3(0,10,500));
43        mCamera->lookAt(Vector3(0,0,0));
44    }
45
46    void createScene(void)
47    {
48        // add tutorial code here:
49        // ...
50            mSceneMgr->setAmbientLight( ColourValue( 0.3, 0.3, 0.3 ) );
51            Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
52            SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode", Vector3( 0, 0, 0 ) );
53            node->attachObject( head );
54
55            mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
56
57            Light *light = mSceneMgr->createLight("Light1");
58            light->setType(Light::LT_POINT);
59            light->setPosition(Vector3(0, 100, 0));
60            light->setDiffuseColour(1.0, 0.0, 0.0);
61            light->setSpecularColour(1.0, 0.0, 0.0);
62
63            BillboardSet *bbs = mSceneMgr->createBillboardSet("bb", 1);
64            bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 0.0, 0.0));
65            bbs->setMaterialName("Examples/Flare");
66
67            lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("LightNode", Vector3(0, 100, 0));
68            lightNode->attachObject(bbs);
69            lightNode->attachObject(light);
70            light->setPosition(0.0, 0.0, 0.0);
71    }
72
73    void createFrameListener(void)
74    {
75        // create frame listener
76        mFrameListener = new TutorialFrameListener(mWindow, mCamera, mSceneMgr);
77        mRoot->addFrameListener(mFrameListener);
78    }
79};
80
81#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
82#define WIN32_LEAN_AND_MEAN
83#include "windows.h"
84
85INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
86#else
87int main(int argc, char **argv)
88#endif
89{
90    // Create application object
91    TutorialApplication app;
92
93    try {
94        app.go();
95    } catch( Exception& e ) {
96#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
97        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
98#else
99        fprintf(stderr, "An exception has occurred: %s\n",
100                e.getFullDescription().c_str());
101#endif
102    }
103
104    return 0;
105}
Note: See TracBrowser for help on using the repository browser.