Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/xml/src/orxonox.cc @ 163

Last change on this file since 163 was 140, checked in by nicolape, 17 years ago

XML-Loader so far…

File size: 4.8 KB
Line 
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
28// TODO: Change this to orxonox.h and include all necessary functions there
29#include "ExampleApplication.h"
30
31#include <string>
32#include <iostream>
33
34#include "xml/xmlParser.h"
35#include "loader/LevelLoader.h"
36
37
38
39using namespace std;
40
41// TODO: Put creation of SceneNode and implementation of FrameListener into an extern file
42SceneNode *lightNode;
43
44class FrameListener : public ExampleFrameListener
45{
46  public:
47    FrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr)
48  : ExampleFrameListener(win, cam, false, false)
49    {
50    }
51
52    bool frameStarted(const FrameEvent &evt)
53    {
54        // add tutorial code here:
55        // ...
56      lightNode->translate(Vector3(0, -10 * evt.timeSinceLastFrame, 0));
57
58      return ExampleFrameListener::frameStarted(evt);
59    }
60  private:
61};
62
63// TODO: Make Doxygen tags work and create scene AFTER loading in an extern file
64//! This is the application class of Orxonox
65/**
66  Application class. The starting point of Orxonox.
67  Loading of ressources should start in here.
68  ...
69*/
70class Orxonox : public ExampleApplication
71{
72  protected:
73  public:
74    Orxonox()
75    {
76    }
77
78    ~Orxonox()
79    {
80    }
81  protected:
82    void createCamera(void)
83    {
84        // create camera
85      mCamera = mSceneMgr->createCamera("PlayerCam");
86      mCamera->setNearClipDistance(5);
87      mCamera->setPosition(Vector3(0,10,500));
88      mCamera->lookAt(Vector3(0,0,0));
89    }
90
91    void createScene(void)
92    {
93
94        string levelFile = "sp_level_moonstation.oxw";
95                        loader::LevelLoader* loader = new loader::LevelLoader(levelFile);
96
97/*                     
98                        LightManager* lightman = new LightManager();
99                        loader->loadLights(lightman);
100                        CameraManager* cameraman = new CameraManager();
101                        loader->loadCameras(cameraman);                     
102                        ScriptManager* scriptman = new ScriptManager();
103                        loader->loadScripts(scriptman);                     
104        */                                         
105   
106   
107        // add tutorial code here:
108        // ...
109       
110        /*
111      mSceneMgr->setAmbientLight( ColourValue( 1, 1, 0.1 ) );
112      Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
113
114      Entity* head2 = mSceneMgr->createEntity("head2", "ogrehead.mesh");
115
116      SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode", Vector3( 0, 0, 0 ) );
117      node->attachObject( head );
118
119      SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode2", Vector3( 50, 0, 0 ) );
120      node2->attachObject( head2 );
121
122
123      //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
124
125      Light *light = mSceneMgr->createLight("Light1");
126      light->setType(Light::LT_POINT);
127      light->setPosition(Vector3(0, 100, 0));
128      light->setDiffuseColour(0.5, 0.5, 0.0);
129      light->setSpecularColour(0.5, 0.5, 0.0);
130
131      BillboardSet *bbs = mSceneMgr->createBillboardSet("bb", 1);
132      bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 0.0, 0.0));
133      //bbs->setMaterialName("Examples/Flare");
134
135      lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("LightNode", Vector3(0, 100, 0));
136      lightNode->attachObject(bbs);
137      lightNode->attachObject(light);
138      light->setPosition(0.0, 0.0, 0.0);
139     
140      */
141    }
142
143    void createFrameListener(void)
144    {
145        // create frame listener
146      mFrameListener = new ExampleFrameListener(mWindow, mCamera, mSceneMgr);
147      mRoot->addFrameListener(mFrameListener);
148    }
149};
150
151#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
152#define WIN32_LEAN_AND_MEAN
153#include "windows.h"
154INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
155#else
156int main(int argc, char **argv)
157#endif
158{
159  // Create application object
160  Orxonox orxonox;
161
162  try 
163  {
164    orxonox.go();
165  } 
166  catch( Exception& e ) 
167  {
168                #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
169        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
170                #else
171        fprintf(stderr, "An exception has occurred: %s\n",e.getFullDescription().c_str());
172                #endif
173  }
174  return 0;
175}
Note: See TracBrowser for help on using the repository browser.