Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main_mbiber.cpp @ 63

Last change on this file since 63 was 63, checked in by mbiber, 17 years ago

tutorialcode von mbiber

File size: 2.8 KB
Line 
1#include "ExampleApplication.h"
2
3SceneNode *lightNode;
4float r=0,phi=0;
5
6class TutorialFrameListener : public ExampleFrameListener
7{
8public:
9    TutorialFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr)
10        : ExampleFrameListener(win, cam, false, false)
11    {
12    }
13
14    bool frameStarted(const FrameEvent &evt)
15    {
16        // add tutorial code here:
17        // ...
18        lightNode->translate(Vector3(r*sin(phi),r*cos(phi),0));
19        r+=0.1*evt.timeSinceLastFrame;
20        phi+=1*evt.timeSinceLastFrame;
21
22        return ExampleFrameListener::frameStarted(evt);
23    }
24private:
25};
26
27
28class TutorialApplication : public ExampleApplication
29{
30protected:
31public:
32    TutorialApplication()
33    {
34    }
35
36    ~TutorialApplication()
37    {
38    }
39protected:
40    void createCamera(void)
41    {
42        // create camera
43        mCamera = mSceneMgr->createCamera("PlayerCam");
44        mCamera->setNearClipDistance(5);
45        mCamera->setPosition(Vector3(0,10,500));
46        mCamera->lookAt(Vector3(0,0,0));
47    }
48
49    void createScene(void)
50    {
51        // add tutorial code here:
52        // ...
53        mSceneMgr->setAmbientLight(ColourValue(0.3,0.3,0.3));
54        Entity* head = mSceneMgr->createEntity("head","ogrehead.mesh");
55        SceneNode *node=mSceneMgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode",Vector3(0,0,0));
56        node->attachObject(head);
57        mSceneMgr->setSkyBox(true,"Examples/SpaceSkyBox");
58
59        Light *light=mSceneMgr->createLight("Light1");
60        light->setType(Light::LT_POINT);
61        light->setPosition(Vector3(0,100,0));
62        light->setDiffuseColour(0.0,1.0,1.0);
63        light->setSpecularColour(0.0,1.0,1.0);
64        BillboardSet *bbs = mSceneMgr->createBillboardSet("bb",1);
65        bbs->createBillboard(Vector3::ZERO,ColourValue(0.0,1.0,1.0));
66        bbs->setMaterialName("Examples/Flare");
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.