Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main_marcelfl.cpp @ 70

Last change on this file since 70 was 70, checked in by marcelfl, 17 years ago

tutorialcode von marcelfl

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