Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox.cc @ 112

Last change on this file since 112 was 112, checked in by anonymous, 17 years ago

nicolasc: added CEGUI find files

File size: 4.2 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#include <CEGUI/CEGUI.h>
31
32// TODO: Put creation of SceneNode and implementation of FrameListener into an extern file
33SceneNode *lightNode;
34
35class OrxFrameListener : public ExampleFrameListener
36{
37  public:
38    OrxFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr)
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
54// TODO: Make Doxygen tags work and create scene AFTER loading in an extern file
55//! This is the application class of Orxonox
56/**
57  Application class. The starting point of Orxonox.
58  Loading of ressources should start in here.
59  ...
60*/
61class 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        // ...
86      //mSceneMgr->setAmbientLight( ColourValue( 0.3, 0.3, 0.3 ) );
87      //Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh");
88
89      //Entity* head2 = mSceneMgr->createEntity("head2", "ogrehead.mesh");
90
91      //ceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode", Vector3( 0, 0, 0 ) );
92      //node->attachObject( head );
93
94      //SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode2", Vector3( 50, 0, 0 ) );
95      //node2->attachObject( head2 );
96
97
98      //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
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));
108      //bbs->setMaterialName("Examples/Flare");
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
119      mFrameListener = new OrxFrameListener(mWindow, mCamera, mSceneMgr);
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
128INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
129#else
130
131int 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}
Note: See TracBrowser for help on using the repository browser.