Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/orxonox.cc @ 398

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

nicolasc: fixed the problem in all braches
orxonox can be quit by 'q' or '<esc>'

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