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 | |
---|
18 | return ExampleFrameListener::frameStarted(evt); |
---|
19 | } |
---|
20 | private: |
---|
21 | }; |
---|
22 | |
---|
23 | |
---|
24 | class TutorialApplication : public ExampleApplication |
---|
25 | { |
---|
26 | protected: |
---|
27 | public: |
---|
28 | TutorialApplication() |
---|
29 | { |
---|
30 | } |
---|
31 | |
---|
32 | ~TutorialApplication() |
---|
33 | { |
---|
34 | } |
---|
35 | protected: |
---|
36 | void createCamera(void) |
---|
37 | { |
---|
38 | // create camera |
---|
39 | mCamera = mSceneMgr->createCamera("PlayerCam"); |
---|
40 | mCamera->setNearClipDistance(5); |
---|
41 | mCamera->setPosition(Vector3(0,10,500)); |
---|
42 | mCamera->lookAt(Vector3(0,0,0)); |
---|
43 | } |
---|
44 | |
---|
45 | void createScene(void) |
---|
46 | { |
---|
47 | // add tutorial code here: |
---|
48 | // ... |
---|
49 | mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) ); |
---|
50 | Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); |
---|
51 | SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" ); |
---|
52 | node1->attachObject( ent1 ); |
---|
53 | |
---|
54 | Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); |
---|
55 | SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) ); |
---|
56 | node2->attachObject( ent2 ); |
---|
57 | |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | void createFrameListener(void) |
---|
62 | { |
---|
63 | // create frame listener |
---|
64 | mFrameListener = new TutorialFrameListener(mWindow, mCamera, mSceneMgr); |
---|
65 | mRoot->addFrameListener(mFrameListener); |
---|
66 | } |
---|
67 | }; |
---|
68 | |
---|
69 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
70 | #define WIN32_LEAN_AND_MEAN |
---|
71 | #include "windows.h" |
---|
72 | |
---|
73 | INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) |
---|
74 | #else |
---|
75 | int main(int argc, char **argv) |
---|
76 | #endif |
---|
77 | { |
---|
78 | // Create application object |
---|
79 | TutorialApplication app; |
---|
80 | |
---|
81 | try { |
---|
82 | app.go(); |
---|
83 | } catch( Exception& e ) { |
---|
84 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
85 | MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); |
---|
86 | #else |
---|
87 | fprintf(stderr, "An exception has occurred: %s\n", |
---|
88 | e.getFullDescription().c_str()); |
---|
89 | #endif |
---|
90 | } |
---|
91 | |
---|
92 | return 0; |
---|
93 | } |
---|