Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main_sweber.cpp @ 67

Last change on this file since 67 was 61, checked in by sweber, 17 years ago

tutorialcode von sweber

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