[74] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
| 7 | * This program is free software: you can redistribute it and/or modify |
---|
| 8 | * it under the terms of the GNU General Public License as published by |
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or |
---|
| 10 | * (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This program is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * GNU General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License |
---|
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 19 | * |
---|
| 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Benjamin Knecht <beni_at_orxonox.net>, (C) 2007 |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | */ |
---|
| 27 | |
---|
[79] | 28 | // TODO: Change this to orxonox.h and include all necessary functions there |
---|
[74] | 29 | #include "ExampleApplication.h" |
---|
[112] | 30 | #include <CEGUI/CEGUI.h> |
---|
[74] | 31 | |
---|
[79] | 32 | // TODO: Put creation of SceneNode and implementation of FrameListener into an extern file |
---|
[74] | 33 | SceneNode *lightNode; |
---|
| 34 | |
---|
[107] | 35 | class OrxFrameListener : public ExampleFrameListener |
---|
[74] | 36 | { |
---|
| 37 | public: |
---|
[107] | 38 | OrxFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr) |
---|
[74] | 39 | : ExampleFrameListener(win, cam, false, false) |
---|
| 40 | { |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | bool frameStarted(const FrameEvent &evt) |
---|
| 44 | { |
---|
| 45 | // add tutorial code here: |
---|
| 46 | // ... |
---|
| 47 | lightNode->translate(Vector3(0, -10 * evt.timeSinceLastFrame, 0)); |
---|
| 48 | |
---|
| 49 | return ExampleFrameListener::frameStarted(evt); |
---|
| 50 | } |
---|
| 51 | private: |
---|
| 52 | }; |
---|
| 53 | |
---|
[79] | 54 | // TODO: Make Doxygen tags work and create scene AFTER loading in an extern file |
---|
[74] | 55 | //! This is the application class of Orxonox |
---|
| 56 | /** |
---|
| 57 | Application class. The starting point of Orxonox. |
---|
[79] | 58 | Loading of ressources should start in here. |
---|
[74] | 59 | ... |
---|
| 60 | */ |
---|
| 61 | class Orxonox : public ExampleApplication |
---|
| 62 | { |
---|
| 63 | protected: |
---|
| 64 | public: |
---|
| 65 | Orxonox() |
---|
| 66 | { |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | ~Orxonox() |
---|
| 70 | { |
---|
| 71 | } |
---|
| 72 | protected: |
---|
| 73 | void createCamera(void) |
---|
| 74 | { |
---|
| 75 | // create camera |
---|
| 76 | mCamera = mSceneMgr->createCamera("PlayerCam"); |
---|
| 77 | mCamera->setNearClipDistance(5); |
---|
| 78 | mCamera->setPosition(Vector3(0,10,500)); |
---|
| 79 | mCamera->lookAt(Vector3(0,0,0)); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | void createScene(void) |
---|
| 83 | { |
---|
| 84 | // add tutorial code here: |
---|
| 85 | // ... |
---|
[107] | 86 | //mSceneMgr->setAmbientLight( ColourValue( 0.3, 0.3, 0.3 ) ); |
---|
[78] | 87 | //Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh"); |
---|
[74] | 88 | |
---|
[78] | 89 | //Entity* head2 = mSceneMgr->createEntity("head2", "ogrehead.mesh"); |
---|
[74] | 90 | |
---|
[107] | 91 | //ceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode", Vector3( 0, 0, 0 ) ); |
---|
[78] | 92 | //node->attachObject( head ); |
---|
[74] | 93 | |
---|
[107] | 94 | //SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode2", Vector3( 50, 0, 0 ) ); |
---|
[78] | 95 | //node2->attachObject( head2 ); |
---|
[74] | 96 | |
---|
| 97 | |
---|
[78] | 98 | //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); |
---|
[74] | 99 | |
---|
| 100 | Light *light = mSceneMgr->createLight("Light1"); |
---|
| 101 | light->setType(Light::LT_POINT); |
---|
| 102 | light->setPosition(Vector3(0, 100, 0)); |
---|
| 103 | light->setDiffuseColour(0.5, 0.5, 0.0); |
---|
| 104 | light->setSpecularColour(0.5, 0.5, 0.0); |
---|
| 105 | |
---|
| 106 | BillboardSet *bbs = mSceneMgr->createBillboardSet("bb", 1); |
---|
| 107 | bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 0.0, 0.0)); |
---|
[78] | 108 | //bbs->setMaterialName("Examples/Flare"); |
---|
[74] | 109 | |
---|
| 110 | lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("LightNode", Vector3(0, 100, 0)); |
---|
| 111 | lightNode->attachObject(bbs); |
---|
| 112 | lightNode->attachObject(light); |
---|
| 113 | light->setPosition(0.0, 0.0, 0.0); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | void createFrameListener(void) |
---|
| 117 | { |
---|
| 118 | // create frame listener |
---|
[107] | 119 | mFrameListener = new OrxFrameListener(mWindow, mCamera, mSceneMgr); |
---|
[74] | 120 | mRoot->addFrameListener(mFrameListener); |
---|
| 121 | } |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
| 125 | #define WIN32_LEAN_AND_MEAN |
---|
| 126 | #include "windows.h" |
---|
| 127 | |
---|
| 128 | INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) |
---|
| 129 | #else |
---|
| 130 | |
---|
| 131 | int main(int argc, char **argv) |
---|
| 132 | #endif |
---|
| 133 | { |
---|
| 134 | // Create application object |
---|
| 135 | Orxonox orxonox; |
---|
| 136 | |
---|
| 137 | try { |
---|
| 138 | orxonox.go(); |
---|
| 139 | } catch( Exception& e ) { |
---|
| 140 | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 |
---|
| 141 | MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); |
---|
| 142 | #else |
---|
| 143 | fprintf(stderr, "An exception has occurred: %s\n", |
---|
| 144 | e.getFullDescription().c_str()); |
---|
| 145 | #endif |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | return 0; |
---|
| 149 | } |
---|