[4] | 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 | { |
---|
[10] | 15 | // add tutorial code here: |
---|
| 16 | // ... |
---|
[60] | 17 | lightNode->translate(Vector3(0, -10 * evt.timeSinceLastFrame, 0)); |
---|
| 18 | |
---|
[4] | 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 | { |
---|
[10] | 48 | // add tutorial code here: |
---|
| 49 | // ... |
---|
[60] | 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 ); |
---|
[4] | 54 | |
---|
[60] | 55 | mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); |
---|
| 56 | |
---|
| 57 | Light *light = mSceneMgr->createLight("Light1"); |
---|
| 58 | light->setType(Light::LT_POINT); |
---|
| 59 | light->setPosition(Vector3(0, 100, 0)); |
---|
| 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 | light->setPosition(0.0, 0.0, 0.0); |
---|
[4] | 71 | } |
---|
| 72 | |
---|
| 73 | void createFrameListener(void) |
---|
| 74 | { |
---|
| 75 | // create frame listener |
---|
| 76 | mFrameListener = new TutorialFrameListener(mWindow, mCamera, mSceneMgr); |
---|
| 77 | mRoot->addFrameListener(mFrameListener); |
---|
| 78 | } |
---|
| 79 | }; |
---|
| 80 | |
---|
[35] | 81 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
| 82 | #define WIN32_LEAN_AND_MEAN |
---|
| 83 | #include "windows.h" |
---|
[4] | 84 | |
---|
[35] | 85 | INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) |
---|
| 86 | #else |
---|
[4] | 87 | int main(int argc, char **argv) |
---|
[35] | 88 | #endif |
---|
[4] | 89 | { |
---|
| 90 | // Create application object |
---|
| 91 | TutorialApplication app; |
---|
| 92 | |
---|
| 93 | try { |
---|
| 94 | app.go(); |
---|
| 95 | } catch( Exception& e ) { |
---|
[35] | 96 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
| 97 | MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); |
---|
| 98 | #else |
---|
[4] | 99 | fprintf(stderr, "An exception has occurred: %s\n", |
---|
| 100 | e.getFullDescription().c_str()); |
---|
[35] | 101 | #endif |
---|
[4] | 102 | } |
---|
| 103 | |
---|
| 104 | return 0; |
---|
| 105 | } |
---|