diff --git a/kraken/KRCamera.cpp b/kraken/KRCamera.cpp index c9c69d0..32c4bc1 100644 --- a/kraken/KRCamera.cpp +++ b/kraken/KRCamera.cpp @@ -70,6 +70,7 @@ std::string KRCamera::getElementName() { tinyxml2::XMLElement *KRCamera::saveXML( tinyxml2::XMLNode *parent) { tinyxml2::XMLElement *e = KRNode::saveXML(parent); + e->SetAttribute("skybox", m_skyBox.c_str()); return e; } @@ -78,11 +79,20 @@ tinyxml2::XMLElement *KRCamera::saveXML( tinyxml2::XMLNode *parent) void KRCamera::loadXML(tinyxml2::XMLElement *e) { KRNode::loadXML(e); + const char *szSkyBoxName = e->Attribute("skybox"); + m_skyBox = szSkyBoxName ? szSkyBoxName : ""; } -void KRCamera::flushSkybox() +void KRCamera::setSkyBox(const std::string &skyBox) { - m_pSkyBoxTexture = NULL; // NOTE: the texture manager manages the loading and unloading of the skybox textures + m_pSkyBoxTexture = NULL; + m_skyBox = skyBox; + +} + +const std::string KRCamera::getSkyBox() const +{ + return m_skyBox; } void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint renderBufferHeight) @@ -301,8 +311,8 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende GLDEBUG(glDepthFunc(GL_LEQUAL)); GLDEBUG(glDepthRangef(0.0, 1.0)); - if(!m_pSkyBoxTexture && settings.m_skyBoxName.length()) { - m_pSkyBoxTexture = getContext().getTextureManager()->getTextureCube(settings.m_skyBoxName.c_str()); + if(!m_pSkyBoxTexture && m_skyBox.length()) { + m_pSkyBoxTexture = getContext().getTextureManager()->getTextureCube(m_skyBox.c_str()); } if(m_pSkyBoxTexture) { diff --git a/kraken/KRCamera.h b/kraken/KRCamera.h index b8f2098..60dc81a 100644 --- a/kraken/KRCamera.h +++ b/kraken/KRCamera.h @@ -74,6 +74,9 @@ public: void setFadeColor(const KRVector4 &fade_color); KRVector4 getFadeColor(); + + void setSkyBox(const std::string &skyBox); + const std::string getSkyBox() const; private: void createBuffers(GLint renderBufferWidth, GLint renderBufferHeight); @@ -92,6 +95,7 @@ private: void destroyBuffers(); KRTexture *m_pSkyBoxTexture; + std::string m_skyBox; KRViewport m_viewport; float m_particlesAbsoluteTime; diff --git a/kraken/KRRenderSettings.cpp b/kraken/KRRenderSettings.cpp index 86bfaed..f3c5a66 100644 --- a/kraken/KRRenderSettings.cpp +++ b/kraken/KRRenderSettings.cpp @@ -56,11 +56,6 @@ KRRenderSettings::KRRenderSettings() m_cShadowBuffers = 0; - - - m_skyBoxName = ""; - - volumetric_environment_enable = false; volumetric_environment_downsample = 2; @@ -148,8 +143,6 @@ KRRenderSettings& KRRenderSettings::operator=(const KRRenderSettings &s) dust_particle_enable=s.dust_particle_enable; perspective_nearz=s.perspective_nearz; perspective_farz=s.perspective_farz; - - m_skyBoxName=s.m_skyBoxName; debug_display = s.debug_display; m_lodBias = s.m_lodBias; @@ -168,10 +161,6 @@ void KRRenderSettings::setViewportSize(const KRVector2 &size) { m_viewportSize = size; } -void KRRenderSettings::setSkyBox(const std::string &skyBoxName) { - m_skyBoxName = skyBoxName; -} - float KRRenderSettings::getPerspectiveNearZ() { return perspective_nearz; diff --git a/kraken/KRRenderSettings.h b/kraken/KRRenderSettings.h index a00e73b..beb442e 100644 --- a/kraken/KRRenderSettings.h +++ b/kraken/KRRenderSettings.h @@ -21,7 +21,6 @@ public: const KRVector2 &getViewportSize(); void setViewportSize(const KRVector2 &size); - void setSkyBox(const std::string &skyBoxName); float getPerspectiveNearZ(); float getPerspectiveFarZ(); @@ -85,8 +84,6 @@ public: float perspective_nearz; float perspective_farz; - std::string m_skyBoxName; - enum debug_display_type{ KRENGINE_DEBUG_DISPLAY_NONE = 0, KRENGINE_DEBUG_DISPLAY_TIME, diff --git a/kraken/KRScene.cpp b/kraken/KRScene.cpp index 85c6f75..2b0a73d 100644 --- a/kraken/KRScene.cpp +++ b/kraken/KRScene.cpp @@ -50,8 +50,6 @@ KRScene::KRScene(KRContext &context, std::string name) : KRResource(context, nam m_pFirstLight = NULL; m_pRootNode = new KRNode(*this, "scene_root"); notify_sceneGraphCreate(m_pRootNode); - - m_skyBoxName = name + "_skybox"; } KRScene::~KRScene() { @@ -126,9 +124,6 @@ void KRScene::render(KRCamera *pCamera, unordered_map &visibleBound std::vectordirectional_lights; std::vectorspot_lights; -// pCamera->settings.setSkyBox(m_skyBoxName); // This is temporary until the camera is moved into the scene graph -// NOTE: the skybox is now selected in the CircaViewController - std::set outerNodes = std::set(m_nodeTree.getOuterSceneNodes()); // HACK - Copying the std::set as it is potentially modified as KRNode's update their bounds during the iteration. This is very expensive and will be eliminated in the future. // Get lights from outer nodes (directional lights, which have no bounds) @@ -409,7 +404,6 @@ bool KRScene::save(KRDataBlock &data) { tinyxml2::XMLElement *scene_node = doc.NewElement( "scene" ); doc.InsertEndChild(scene_node); m_pRootNode->saveXML(scene_node); - scene_node->SetAttribute("skybox", m_skyBoxName.c_str()); // This is temporary until the camera is moved into the scene graph tinyxml2::XMLPrinter p; doc.Print(&p); @@ -427,8 +421,6 @@ KRScene *KRScene::Load(KRContext &context, const std::string &name, KRDataBlock KRScene *new_scene = new KRScene(context, name); tinyxml2::XMLElement *scene_element = doc.RootElement(); - const char *szSkyBoxName = scene_element->Attribute("skybox"); - new_scene->m_skyBoxName = szSkyBoxName ? szSkyBoxName : ""; // This is temporary until the camera is moved into the scene graph KRNode *n = KRNode::LoadXML(*new_scene, scene_element->FirstChildElement()); if(n) { diff --git a/kraken/KRScene.h b/kraken/KRScene.h index 0ba470c..fd747ef 100644 --- a/kraken/KRScene.h +++ b/kraken/KRScene.h @@ -110,8 +110,6 @@ private: KROctree m_nodeTree; - std::string m_skyBoxName; - public: template T *find()