00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #ifndef o3d_RenderEngine_hpp 00023 #define o3d_RenderEngine_hpp 00024 00025 #include "O3dPre.hpp" 00026 #include "o3d/event/o3d_event.hpp" 00027 #include "o3d/input/o3d_input.hpp" 00028 #include "sim/SimListener.hpp" 00029 #include "o3d/schema/O3dSchema.hpp" 00030 #include <Ogre.h> 00031 00032 namespace se_ogre { 00033 class _SeOgreExport RenderEngine : public se_core::SimListener { 00034 public: 00035 RenderEngine(se_ogre::ConsoleHandler* consoleHandler = 0); 00036 virtual ~RenderEngine(); 00037 00038 void renderEvent(long when) { renderFrame(); } 00039 void preSimTickEvent(long when) {} 00040 void postSimTickEvent(long when); 00041 00042 00043 static RenderEngine* singleton(); 00044 bool setup(void); 00045 void cleanup(void); 00046 00047 void skipNext() { skip_ = 3; } 00048 void resetSkip() { skip_ = 0; } 00049 void renderFrame(); 00050 void screenshot(int screenShotId); 00051 void screenshot(const char* prefix); 00052 void loadLevelResources(const char** sections); 00053 void resetLevelResources(); 00054 00055 protected: 00057 void resetGameClock(void); 00058 00060 bool configure(void); 00061 00062 void createInputBridge(void); 00063 00064 00067 void setupResources(void); 00068 00071 void createResourceListener(void) {} 00072 00075 void loadResources(void); 00076 00077 protected: 00078 O3dInputBridge* inputBridge_; 00079 static const int MAX_LEVEL_RESOURCE_SECTIONS = 8; 00080 int levelResourceCount_; 00081 const char* levelResources_[ MAX_LEVEL_RESOURCE_SECTIONS ]; 00082 int skip_; 00083 00084 private: 00085 #ifdef _DEBUG 00086 const static int fastExit = 1; 00087 #else 00088 const static int fastExit = 0; 00089 #endif 00090 virtual void chooseSceneManager(void) 00091 { 00092 // Create the SceneManager, in this case a generic one 00093 O3dSchema::sceneManager = O3dSchema::root->createSceneManager(Ogre::ST_GENERIC, "ExampleSMInstance"); 00094 } 00095 virtual void createCamera(void) 00096 { 00097 // Create the camera 00098 O3dSchema::playerCamera = O3dSchema::sceneManager->createCamera("PlayerCam"); 00099 00100 // Position it at 500 in Z direction 00101 O3dSchema::playerCamera->setPosition(Ogre::Vector3(0,0,500)); 00102 // Look back along -Z 00103 O3dSchema::playerCamera->lookAt(Ogre::Vector3(0,0,-300)); 00104 O3dSchema::playerCamera->setNearClipDistance(5); 00105 00106 } 00107 virtual void createViewports(void) 00108 { 00109 // Create one viewport, entire window 00110 Ogre::Viewport* vp = O3dSchema::window->addViewport(O3dSchema::playerCamera); 00111 vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); 00112 00113 // Alter the camera aspect ratio to match the viewport 00114 O3dSchema::playerCamera->setAspectRatio( 00115 Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight())); 00116 } 00117 00118 }; 00119 00120 } 00121 00122 00123 #endif
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:07 2007 by Doxygen version 1.3.9.1.