Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mainloop/src/orxonox.cc @ 77

Last change on this file since 77 was 74, checked in by bknecht, 17 years ago

created orxonox.cc and license file. TODO make files (make it compile) and doxygen support

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