Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/Tutorial/src/main_janise.cpp @ 233

Last change on this file since 233 was 68, checked in by janise, 17 years ago

tutorialcode von janise

File size: 2.8 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.5 ,0.5 ,0.5));
47        Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
48        SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode",Vector3(0, 0, 0));
49        node->attachObject(head);
50        mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
51        Light *light = mSceneMgr->createLight("Light1");
52        light->setType(Light::LT_POINT);
53        light->setPosition(Vector3(0, 100, 0));
54        light->setDiffuseColour(1.0, 0.0, 0.0);
55        light->setSpecularColour(1.0, 0.0, 0.0);
56        BillboardSet *bbs = mSceneMgr->createBillboardSet("bb", 1);
57        bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 0.0, 0.0));
58        bbs->setMaterialName("Examples/Flare");
59        lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("LightNide", Vector3(0, 100, 0));
60        lightNode->attachObject(bbs);
61        lightNode->attachObject(light);
62        light->setPosition(0.0, 0.0, 0.0);
63    }
64
65    void createFrameListener(void)
66    {
67
68        mFrameListener = new TutorialFrameListener(mWindow, mCamera, mSceneMgr);
69        mRoot->addFrameListener(mFrameListener);
70    }
71};
72
73#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
74#define WIN32_LEAN_AND_MEAN
75#include "windows.h"
76
77INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
78#else
79int main(int argc, char **argv)
80#endif
81{
82    // Create application object
83    TutorialApplication app;
84
85    try {
86        app.go();
87    } catch( Exception& e ) {
88#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
89        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
90#else
91        fprintf(stderr, "An exception has occurred: %s\n",
92                e.getFullDescription().c_str());
93#endif
94    }
95
96    return 0;
97}
Note: See TracBrowser for help on using the repository browser.