Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 167 vs 168 for /trunk/Source Code/Scenes/Headers/Scene.h

Diff revisions: vs.
  @@ -78,10 +78,11 @@
78 78 inline vectorImpl<FileData>& getModelDataArray() {return _modelDataArray;}
79 79 inline vectorImpl<FileData>& getVegetationDataArray() {return _vegetationDataArray;}
80 80 inline const vectorImpl<Task_ptr>& getTasks() {return _tasks;}
81 + inline SceneState& state() {return _sceneState;}
82 + inline SceneRenderState& renderState() {return _sceneState.getRenderState();}
81 83 inline SceneGraph* getSceneGraph() {return _sceneGraph;}
82 - inline SceneState* state() {return _sceneState;}
83 - inline SceneRenderState* renderState() {return _sceneRenderState;}
84 - void removeTasks();
84 +
85 + void clearTasks();
85 86 void removeTask(Task_ptr taskItem);
86 87 void removeTask(U32 guid);
87 88 void addTask(Task_ptr taskItem);
  @@ -90,7 +91,9 @@
90 91 void addPatch(vectorImpl<FileData>& data);
91 92 void addLight(Light* const lightItem);
92 93
93 - inline void cacheResolution(const vec2<U16>& newResolution) {_sceneRenderState->_cachedResolution = newResolution;}
94 + inline void cacheResolution(const vec2<U16>& newResolution) {
95 + _sceneState.getRenderState()._cachedResolution = newResolution;
96 + }
94 97
95 98 ///Object picking
96 99 void findSelection(const vec3<F32>& camOrigin, U32 x, U32 y);
  @@ -100,14 +103,17 @@
100 103 void renderCallback(boost::function0<void> renderCallback) {_renderCallback = renderCallback;}
101 104 boost::function0<void> renderCallback() {return _renderCallback;}
102 105
106 + ///Update all cameras
107 + void updateCameras();
103 108 ///Override this if you need a custom physics implementation (idle,update,process,etc)
104 109 virtual PhysicsSceneInterface* createPhysicsImplementation();
105 110
106 111 protected:
107 112 ///Global info
108 - GFXDevice& _GFX;
109 - ParamHandler& _paramHandler;
110 - SceneGraph* _sceneGraph;
113 + GFXDevice& _GFX;
114 + ParamHandler& _paramHandler;
115 + SceneGraph* _sceneGraph;
116 + CameraManager* _cameraMgr;
111 117
112 118 PhysicsSceneInterface* _physicsInterface;
113 119 ///Datablocks for models,vegetation,terrains,tasks etc
  @@ -134,10 +140,8 @@
134 140
135 141 private:
136 142 vectorImpl<Task_ptr> _tasks;
137 - ///saves all the rendering information for the scene (camera position, light info, draw states)
138 - SceneRenderState* _sceneRenderState;
139 143 ///Contains all game related info for the scene (wind speed, visibility ranges, etc)
140 - SceneState* _sceneState;
144 + SceneState _sceneState;
141 145 vectorImpl<SceneGraphNode* > _skiesSGN;///<Add multiple skies that you can toggle through
142 146
143 147 protected:
  @@ -150,7 +154,7 @@
150 154 virtual bool loadTasks(bool continueOnErrors) {return true;}
151 155 virtual bool loadPhysics(bool continueOnErrors);
152 156 virtual void loadXMLAssets();
153 - virtual bool load(const std::string& name);
157 + virtual bool load(const std::string& name, CameraManager* const cameraMgr);
154 158 bool loadModel(const FileData& data);
155 159 bool loadGeometry(const FileData& data);
156 160 virtual bool unload();
  @@ -159,9 +163,7 @@
159 163 ///Description in SceneManager
160 164 virtual bool deinitializeAI(bool continueOnErrors);
161 165 ///Check if Scene::load() was called
162 - bool checkLoadFlag() {return _loadComplete;}
163 - ///End all tasks
164 - void clearTasks();
166 + bool checkLoadFlag() const {return _loadComplete;}
165 167 ///Unload scenegraph
166 168 void clearObjects();
167 169 ///Destroy lights
  @@ -170,8 +172,29 @@
170 172 void clearPhysics();
171 173 /**End loading and unloading logic*/
172 174
173 - Light* addDefaultLight();
174 - Sky* addDefaultSky();
175 + Light* addDefaultLight();
176 + Sky* addDefaultSky();
177 + Camera* addDefaultCamera();//Default camera
178 + ///simple function to load the scene elements.
179 + inline bool SCENE_LOAD(const std::string& name, CameraManager* const cameraMgr, const bool contOnErrorRes, const bool contOnErrorTasks){
180 + if(!Scene::load(name,cameraMgr)) {
181 + ERROR_FN(Locale::get("ERROR_SCENE_LOAD"), "scene load function");
182 + return false;
183 + }
184 + if(!loadResources(contOnErrorRes)){
185 + ERROR_FN(Locale::get("ERROR_SCENE_LOAD"), "scene load resources");
186 + if(!contOnErrorRes) return false;
187 + }
188 + if(!loadTasks(contOnErrorTasks)){
189 + ERROR_FN(Locale::get("ERROR_SCENE_LOAD"), "scene load tasks");
190 + if(!contOnErrorTasks) return false;
191 + }
192 + if(!loadPhysics(contOnErrorTasks)){
193 + ERROR_FN(Locale::get("ERROR_SCENE_LOAD"), "scene load physics");
194 + if(!contOnErrorTasks) return false;
195 + }
196 + return true;
197 + }
175 198
176 199 public: //Input
177 200 virtual void onKeyDown(const OIS::KeyEvent& key);
  @@ -185,21 +208,17 @@
185 208 virtual void onMouseMove(const OIS::MouseEvent& key){}
186 209 virtual void onMouseClickDown(const OIS::MouseEvent& key,OIS::MouseButtonID button);
187 210 virtual void onMouseClickUp(const OIS::MouseEvent& key,OIS::MouseButtonID button);
211 +
212 + protected: //Input
213 + vec2<F32> _previousMousePos;
214 + bool _mousePressed[8];
188 215 };
189 216
190 217 ///usage: REGISTER_SCENE(A,B) where: - A is the scene's class name
191 218 /// -B is the name used to refer to that scene in the XML files
192 219 ///Call this function after each scene declaration
193 - #define REGISTER_SCENE_W_NAME(scene, sceneName) bool scene ## _registered = SceneManager::getInstance().registerScene<scene>(#sceneName);
220 + #define REGISTER_SCENE_W_NAME(scene, sceneName) bool scene ## _registered = SceneManager::getOrCreateInstance().registerScene<scene>(#sceneName);
194 221 ///same as REGISTER_SCENE(A,B) but in this case the scene's name in XML must be the same as the class name
195 - #define REGISTER_SCENE(scene) bool scene ## _registered = SceneManager::getInstance().registerScene<scene>(#scene);
196 - ///simple macro to load the scene elements. Use "loadState' as loading flag
197 - #define SCENE_LOAD(Name, ContOnErrorRes, ContOnErrorTasks) bool loadState = Scene::load(Name); \
198 - if(loadState) loadState = loadResources(ContOnErrorRes); \
199 - if(loadState) loadState = loadTasks(ContOnErrorTasks); \
200 - if(loadState) loadState = loadPhysics(ContOnErrorTasks); \
201 - if(!loadState) return false;
202 -
203 - ///Add all of the hardware headers in one:
222 + #define REGISTER_SCENE(scene) bool scene ## _registered = SceneManager::getOrCreateInstance().registerScene<scene>(#scene);
204 223
205 224 #endif