Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main_scheusso.cpp @ 134

Last change on this file since 134 was 58, checked in by scheusso, 17 years ago

tutorialcode von scheusso

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