Changeset 135 for code/trunk
- Timestamp:
- Oct 31, 2007, 10:23:38 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 3 deleted
- 6 edited
- 19 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/CMakeLists.txt
r114 r135 40 40 FIND_PACKAGE(OGRE) 41 41 FIND_PACKAGE(OIS) 42 FIND_PACKAGE(CEGUI)43 FIND_PACKAGE(CEGUI_OGRE)44 45 42 46 43 #Sets the search paths for the linking 47 LINK_DIRECTORIES(${OGRE_LIB_DIR} ${OIS_LIB_DIR} ${CEGUI_LIB_DIR} ${CEGUI_OGRE_LIB_DIR})44 LINK_DIRECTORIES(${OGRE_LIB_DIR} ${OIS_LIB_DIR}) 48 45 #Sets the search path for include files 49 INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR} ${CEGUI_OGRE_INCLUDE_DIR})46 INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR}) 50 47 51 48 #add main source dir -
code/trunk/INSTALL
r106 r135 1 1 Here our installing directions 2 2 3 requirements: 4 ogre-1.4.5 5 ois-1.0 6 3 ... 7 4 8 5 Further information about installing and running this application can be found on http://www.orxonox.net/wiki/Running -
code/trunk/README
r129 r135 6 6 The game content is licensed under the Creative Commons Attribution-Sharealike 2.5 license. For more information read LICENSE in the same folder you found this file. 7 7 8 For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running or http://www.orxonox.net/wiki/download8 For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running 9 9 10 10 This application uses the Ogre Graphics Engine (http://www.ogre3d.org), if you haven't already downloaded a precompiled version of Ogre with this package. Visit our webpage to get your Orxonox compatible version of the Ogre libraries. -
code/trunk/bin/resources.cfg
r118 r135 6 6 # Resource locations to be added to the default path 7 7 [General] 8 #FileSystem=../Media9 #FileSystem=../Media/fonts8 FileSystem=../Media 9 FileSystem=../Media/fonts 10 10 #FileSystem=../Media/materials/programs 11 11 #FileSystem=../Media/materials/scripts … … 14 14 #FileSystem=../Media/overlays 15 15 #FileSystem=../Media/particle 16 #FileSystem=../Media/gui16 FileSystem=../Media/gui 17 17 #FileSystem=../Media/DeferredShadingMedia 18 18 #Zip=../Media/packs/cubemap.zip … … 21 21 #Zip=../Media/packs/fresneldemo.zip 22 22 #Zip=../Media/packs/ogretestmap.zip 23 #Zip=../Media/packs/skybox.zip23 Zip=../Media/packs/skybox.zip -
code/trunk/src/CMakeLists.txt
r121 r135 3 3 # create a few variables to simplify life 4 4 SET(SRC_FILES orxonox.cc) 5 #SET(INC_FILES ExampleApplication.h ExampleFrameListener.h)5 SET(INC_FILES ExampleApplication.h ExampleFrameListener.h) 6 6 7 7 #Creates an executable 8 8 ADD_EXECUTABLE(../bin/main ${SRC_FILES} ${INC_FILES}) 9 9 #Links the executable against OGRE and OIS 10 TARGET_LINK_LIBRARIES(../bin/main ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_OGRE_LIBRARIES} ${CEGUI_LIBRARIES}) 10 TARGET_LINK_LIBRARIES(../bin/main ${OGRE_LIBRARIES} ${OIS_LIBRARIES}) 11 -
code/trunk/src/orxonox.cc
r125 r135 26 26 */ 27 27 28 #include <Ogre.h> 29 #include <OIS/OIS.h> 30 #include <CEGUI/CEGUI.h> 31 #include <OgreCEGUIRenderer.h> 28 // TODO: Change this to orxonox.h and include all necessary functions there 29 #include "ExampleApplication.h" 32 30 33 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 34 #include <CoreFoundation/CoreFoundation.h> 31 // TODO: Put creation of SceneNode and implementation of FrameListener into an extern file 32 SceneNode *lightNode; 35 33 36 // This function will locate the path to our application on OS X, 37 // unlike windows you can not rely on the curent working directory 38 // for locating your configuration files and resources. 39 std::string macBundlePath() 40 { 41 char path[1024]; 42 CFBundleRef mainBundle = CFBundleGetMainBundle(); 43 assert(mainBundle); 44 45 CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle); 46 assert(mainBundleURL); 47 48 CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle); 49 assert(cfStringRef); 50 51 CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII); 52 53 CFRelease(mainBundleURL); 54 CFRelease(cfStringRef); 55 56 return std::string(path); 57 } 58 #endif 59 60 using namespace Ogre; 61 62 class OrxExitListener : public FrameListener 34 class FrameListener : public ExampleFrameListener 63 35 { 64 36 public: 65 OrxExitListener(OIS::Keyboard *keyboard)66 : mKeyboard(keyboard)37 FrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneMgr) 38 : ExampleFrameListener(win, cam, false, false) 67 39 { 68 40 } 69 41 70 bool frameStarted(const FrameEvent &evt)42 bool frameStarted(const FrameEvent &evt) 71 43 { 72 mKeyboard->capture(); 73 return !mKeyboard->isKeyDown(OIS::KC_ESCAPE); 44 // add tutorial code here: 45 // ... 46 lightNode->translate(Vector3(0, -10 * evt.timeSinceLastFrame, 0)); 47 48 return ExampleFrameListener::frameStarted(evt); 49 } 50 private: 51 }; 52 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 */ 60 class Orxonox : public ExampleApplication 61 { 62 protected: 63 public: 64 Orxonox() 65 { 74 66 } 75 67 76 private: 77 OIS::Keyboard *mKeyboard; 78 }; 79 80 class OrxApplication 81 { 82 public: 83 void go() 68 ~Orxonox() 84 69 { 85 createRoot(); 86 defineResources(); 87 setupRenderSystem(); 88 createRenderWindow(); 89 initializeResourceGroups(); 90 setupScene(); 91 setupInputSystem(); 92 setupCEGUI(); 93 createFrameListener(); 94 startRenderLoop(); 70 } 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)); 95 79 } 96 80 97 ~OrxApplication()81 void createScene(void) 98 82 { 99 mInputManager->destroyInputObject(mKeyboard); 100 OIS::InputManager::destroyInputSystem(mInputManager); 83 // add tutorial code here: 84 // ... 85 mSceneMgr->setAmbientLight( ColourValue( 0.3, 0.3, 0.3 ) ); 86 //Entity* head = mSceneMgr->createEntity("head", "ogrehead.mesh"); 101 87 102 delete mRenderer; 103 delete mSystem; 88 //Entity* head2 = mSceneMgr->createEntity("head2", "ogrehead.mesh"); 104 89 105 delete mListener; 106 delete mRoot; 90 SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode( "OgreHeadNode", Vector3( 0, 0, 0 ) ); 91 //node->attachObject( head ); 92 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); 107 113 } 108 114 109 private: 110 Root *mRoot; 111 OIS::Keyboard *mKeyboard; 112 OIS::Mouse *mMouse; 113 OIS::InputManager *mInputManager; 114 CEGUI::OgreCEGUIRenderer *mRenderer; 115 CEGUI::System *mSystem; 116 OrxExitListener *mListener; 117 118 void createRoot() 115 void createFrameListener(void) 119 116 { 120 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 121 mRoot = new Root(macBundlePath() + "/Contents/Resources/plugins.cfg"); 122 #else 123 mRoot = new Root(); 124 #endif 125 } 126 127 void defineResources() 128 { 129 String secName, typeName, archName; 130 ConfigFile cf; 131 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 132 cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); 133 #else 134 cf.load("resources.cfg"); 135 #endif 136 137 ConfigFile::SectionIterator seci = cf.getSectionIterator(); 138 while (seci.hasMoreElements()) 139 { 140 secName = seci.peekNextKey(); 141 ConfigFile::SettingsMultiMap *settings = seci.getNext(); 142 ConfigFile::SettingsMultiMap::iterator i; 143 for (i = settings->begin(); i != settings->end(); ++i) 144 { 145 typeName = i->first; 146 archName = i->second; 147 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 148 ResourceGroupManager::getSingleton().addResourceLocation( String(macBundlePath() + "/" + archName), typeName, secName); 149 #else 150 ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); 151 #endif 152 } 153 } 154 } 155 156 void setupRenderSystem() 157 { 158 if (!mRoot->restoreConfig() && !mRoot->showConfigDialog()) 159 throw Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); 160 } 161 162 void createRenderWindow() 163 { 164 mRoot->initialise(true, "Ogre Render Window"); 165 } 166 167 void initializeResourceGroups() 168 { 169 TextureManager::getSingleton().setDefaultNumMipmaps(5); 170 ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 171 } 172 173 void setupScene() 174 { 175 SceneManager *mgr = mRoot->createSceneManager(ST_GENERIC, "Default SceneManager"); 176 Camera *cam = mgr->createCamera("Camera"); 177 Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam); 178 } 179 180 void setupInputSystem() 181 { 182 size_t windowHnd = 0; 183 std::ostringstream windowHndStr; 184 OIS::ParamList pl; 185 RenderWindow *win = mRoot->getAutoCreatedWindow(); 186 187 win->getCustomAttribute("WINDOW", &windowHnd); 188 windowHndStr << windowHnd; 189 pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 190 mInputManager = OIS::InputManager::createInputSystem(pl); 191 192 try 193 { 194 mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); 195 mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false)); 196 } 197 catch (const OIS::Exception &e) 198 { 199 throw new Exception(42, e.eText, "OrxApplication::setupInputSystem"); 200 } 201 } 202 203 void setupCEGUI() 204 { 205 SceneManager *mgr = mRoot->getSceneManager("Default SceneManager"); 206 RenderWindow *win = mRoot->getAutoCreatedWindow(); 207 208 // CEGUI setup 209 // mRenderer = new CEGUI::OgreCEGUIRenderer(win, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mgr); 210 // mSystem = new CEGUI::System(mRenderer); 211 212 // Other CEGUI setup here. 213 } 214 215 void createFrameListener() 216 { 217 mListener = new OrxExitListener(mKeyboard); 218 mRoot->addFrameListener(mListener); 219 } 220 221 void startRenderLoop() 222 { 223 mRoot->startRendering(); 117 // create frame listener 118 mFrameListener = new ExampleFrameListener(mWindow, mCamera, mSceneMgr); 119 mRoot->addFrameListener(mFrameListener); 224 120 } 225 121 }; 226 122 227 #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM ==OGRE_PLATFORM_WIN32123 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 228 124 #define WIN32_LEAN_AND_MEAN 229 125 #include "windows.h" 230 126 231 INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT)127 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) 232 128 #else 233 int main(int argc, char **argv) 129 130 int main(int argc, char **argv) 234 131 #endif 235 132 { 236 try 237 { 238 OrxApplication orxonox; 133 // Create application object 134 Orxonox orxonox; 135 136 try { 239 137 orxonox.go(); 240 } 241 catch(Exception& e) 242 { 243 #if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32 244 MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); 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); 245 141 #else 246 142 fprintf(stderr, "An exception has occurred: %s\n", … … 251 147 return 0; 252 148 } 253
Note: See TracChangeset
for help on using the changeset viewer.