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