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/Managers/SceneManager.cpp

Diff revisions: vs.
  @@ -2,10 +2,14 @@
2 2 #include "Headers/AIManager.h"
3 3
4 4 #include "SceneList.h"
5 - #include "Rendering/Headers/Renderer.h"
6 5 #include "Geometry/Importer/Headers/DVDConverter.h"
7 6
8 - SceneManager::SceneManager() : _activeScene(NULL){
7 + SceneManager::SceneManager() : FrameListener(),
8 + _activeScene(NULL),
9 + _init(false)
10 + {
11 + DVDConverter::createInstance();
12 + AIManager::createInstance();
9 13 }
10 14
11 15 SceneManager::~SceneManager(){
  @@ -20,7 +24,14 @@
20 24 DVDConverter::getInstance().DestroyInstance();
21 25 }
22 26
23 - bool SceneManager::load(const std::string& sceneName, const vec2<U16>& resolution, Camera* const camera){
27 + bool SceneManager::init(){
28 + REGISTER_FRAME_LISTENER(&(this->getInstance()));
29 + _init = true;
30 + return true;
31 + }
32 +
33 + bool SceneManager::load(const std::string& sceneName, const vec2<U16>& resolution, CameraManager* const cameraMgr){
34 + assert(_init == true);
24 35 PRINT_FN(Locale::get("SCENE_MANAGER_LOAD_SCENE_DATA"));
25 36 //Initialize the model importer:
26 37 if(!DVDConverter::getInstance().init()){
  @@ -33,35 +44,41 @@
33 44 cacheResolution(resolution);
34 45 _activeScene->preLoad();
35 46 _activeScene->loadXMLAssets();
36 - PRINT_FN(Locale::get("SCENE_MANAGER_ADD_DEFAULT_CAMERA"));
37 - _activeScene->renderState()->updateCamera(camera);
38 - return _activeScene->load(sceneName);
47 + return _activeScene->load(sceneName, cameraMgr);
39 48 }
40 49
41 50 Scene* SceneManager::createScene(const std::string& name){
42 51 Scene* scene = NULL;
43 52
44 - if(!name.empty()){
53 + if(!name.empty())
45 54 scene = _sceneFactory[name]();
46 - }
47 - if(scene != NULL){
55 +
56 + if(scene != NULL)
48 57 _sceneMap.insert(std::make_pair(name, scene));
49 - }
50 58
51 59 return scene;
52 60 }
53 61
62 + bool SceneManager::framePreRenderStarted(const FrameEvent& evt){
63 + _activeScene->renderState().getCamera().renderLookAt();
64 + return true;
65 + }
66 +
54 67 void SceneManager::render(const RenderStage& stage) {
55 - GFXDevice& GFX = GFX_DEVICE;
56 - GFX.setRenderStage(stage);
57 68 assert(_activeScene != NULL);
58 - if(_activeScene->renderCallback().empty()){
59 - SceneGraph* sg = _activeScene->getSceneGraph();
60 - GFX.render(DELEGATE_BIND(&SceneGraph::update,sg),_activeScene->renderState());
61 - }else{
62 - GFX.render(_activeScene->renderCallback(),_activeScene->renderState());
69 +
70 + if(_renderFunction.empty()){
71 + if(_activeScene->renderCallback().empty()){
72 + _renderFunction = DELEGATE_BIND(&SceneGraph::update, _activeScene->getSceneGraph());
73 + }else{
74 + _renderFunction = _activeScene->renderCallback();
75 + }
63 76 }
64 77
78 + GFXDevice& GFX = GFX_DEVICE;
79 + GFX.setRenderStage(stage);
80 + GFX.render(_renderFunction,_activeScene->renderState());
81 +
65 82 if(bitCompare(stage,FINAL_STAGE) || bitCompare(stage,DEFERRED_STAGE)){
66 83 // Draw bounding boxes, skeletons, axis gizmo, etc.
67 84 GFX.debugDraw();