-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from carboncopies/281-update-scenewriterloade…
…r-with-viewport-camera 281 update scenewriterloader with viewport camera
- Loading branch information
Showing
17 changed files
with
1,085 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Source/Core/Loader/ERS_SceneLoader/ERS_FUNCTION_SceneDecoderManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#include <ERS_FUNCTION_SceneDecoderManager.h> | ||
|
||
|
||
|
||
|
||
bool ERS_FUNCTION_DecodeScene(YAML::Node SceneData, ERS_STRUCT_Scene *Scene, ERS_STRUCT_SystemUtils *SystemUtils, ERS_CLASS_ModelLoader* ModelLoader, bool LogEnable) { | ||
|
||
SystemUtils->Logger_->Log("Decoding ERS Scene", 5, LogEnable); | ||
|
||
// Extract Current Version | ||
int Version = 0; | ||
SystemUtils->Logger_->Log("Identifying Scene Format Version", 4, LogEnable); | ||
if (SceneData["SceneFormatVersion"]) { | ||
Version = SceneData["SceneFormatVersion"].as<int>(); | ||
} else { | ||
SystemUtils->Logger_->Log("Unable To Find Metadata Tag For 'SceneFormatVersion', Unable To Identify Version", 9); | ||
return false; | ||
} | ||
|
||
// Attempt Decoding With Known Decoding Systems | ||
if (Version == 1) { | ||
SystemUtils->Logger_->Log("Detected Scene Format To Be Version 1, Starting Decoding Process", 4, LogEnable); | ||
return ERS_FUNCTION_DecodeSceneV1(SceneData, Scene, SystemUtils, ModelLoader, LogEnable); | ||
} else if (Version == 2) { | ||
SystemUtils->Logger_->Log("Detected Scene Format To Be Version 2, Starting Decoding Process", 4, LogEnable); | ||
return ERS_FUNCTION_DecodeSceneV2(SceneData, Scene, SystemUtils, ModelLoader, LogEnable); | ||
} else if (Version == 3) { | ||
SystemUtils->Logger_->Log("Detected Scene Format To Be Version 3, Starting Decoding Process", 4, LogEnable); | ||
return ERS_FUNCTION_DecodeSceneV3(SceneData, Scene, SystemUtils, ModelLoader, LogEnable); | ||
} else { | ||
SystemUtils->Logger_->Log("Scene Format Has Unknown Version, Aborting Load", 8); | ||
return false; | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
Source/Core/Loader/ERS_SceneLoader/ERS_FUNCTION_SceneDecoderManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#pragma once | ||
|
||
// Standard Libraries (BG convention: use <> instead of "") | ||
#include <string> | ||
#include <vector> | ||
|
||
// Third-Party Libraries (BG convention: use <> instead of "") | ||
#include <yaml-cpp/yaml.h> | ||
|
||
// Internal Libraries (BG convention: use <> instead of "") | ||
#include <ERS_STRUCT_SystemUtils.h> | ||
#include <ERS_STRUCT_Scene.h> | ||
|
||
#include <ERS_CLASS_ModelLoader.h> | ||
|
||
#include <ERS_FUNCTION_SceneDecoderV1.h> | ||
#include <ERS_FUNCTION_SceneDecoderV2.h> | ||
#include <ERS_FUNCTION_SceneDecoderV3.h> | ||
|
||
|
||
/** | ||
* @brief Attempts to decode the scene data passed in. Will check against known format versions and decode if it's a known format. | ||
* | ||
* @param SceneData YAML::Node containing the scene data. | ||
* @param Scene Pointer to the scene to be updated. | ||
* @param SystemUtils Pointer to the systemutils struct. | ||
* @param LogEnable Enable or disable information log messages. | ||
* @return true Loading completed without errors. | ||
* @return false Loading failed. | ||
*/ | ||
bool ERS_FUNCTION_DecodeScene(YAML::Node SceneData, ERS_STRUCT_Scene *Scene, ERS_STRUCT_SystemUtils *SystemUtils, ERS_CLASS_ModelLoader* ModelLoader, bool LogEnable = true); |
107 changes: 107 additions & 0 deletions
107
Source/Core/Loader/ERS_SceneLoader/ERS_FUNCTION_SceneDecoderV1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#include <ERS_FUNCTION_SceneDecoderV1.h> | ||
|
||
|
||
|
||
bool ERS_FUNCTION_DecodeSceneV1(YAML::Node SceneData, ERS_STRUCT_Scene *Scene, ERS_STRUCT_SystemUtils *SystemUtils, ERS_CLASS_ModelLoader* ModelLoader, bool LogEnable) { | ||
|
||
// Init | ||
bool Success = true; | ||
SystemUtils->Logger_->Log(std::string("Processing Scene '") + Scene->SceneName + "' With Decoder Version 1", 3, LogEnable); | ||
ERS_CLASS_LoggingSystem* Logger = SystemUtils->Logger_.get(); | ||
|
||
// Grab Metadata | ||
std::vector<YAML::Node> SceneItems; | ||
Success &= ERS_FUNCTION_GetLong (Logger, SceneData, "SceneFormatVersion", Scene->SceneFormatVersion ); | ||
Success &= ERS_FUNCTION_GetString (Logger, SceneData, "SceneName", Scene->SceneName ); | ||
Success &= ERS_FUNCTION_GetNodeVector (Logger, SceneData, "SceneData", SceneItems ); | ||
|
||
// Iterate Through Vector To Add Each Asset To Loading Queue Of Requested Type | ||
for (long i = 0; (long)i < (long)SceneItems.size(); i++) { | ||
|
||
// Get Asset Information | ||
YAML::Node Item = SceneItems[i]; | ||
std::string AssetName, AssetType; | ||
Success &= ERS_FUNCTION_GetString(Logger, Item, "AssetName", AssetName); | ||
Success &= ERS_FUNCTION_GetString(Logger, Item, "AssetType", AssetType); | ||
|
||
|
||
if (AssetType == "Model") { | ||
|
||
ERS_STRUCT_Model Model; | ||
Success &= ERS_FUNCTION_GetLong (Logger, Item, "AssetID", Model.AssetID ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "AssetPosition", Model.ModelPosition ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "AssetRotation", Model.ModelRotation ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "AssetScale", Model.ModelScale ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "CastDynamicShadows", Model.CastDynamicShadows_ ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "CastStaticShadows", Model.CastStaticShadows_ ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "ReceiveShadows", Model.ReceiveShadows_ ); | ||
Success &= ERS_FUNCTION_GetLong (Logger, Item, "ShaderOverrideIndex", Model.ShaderOverrideIndex_ ); | ||
Success &= ERS_FUNCTION_GetString (Logger, Item, "AssetName", Model.Name ); | ||
Success &= ERS_FUNCTION_GetLongVector (Logger, Item, "AttachedScripts", Model.AttachedScriptIndexes_ ); | ||
|
||
Scene->Models.push_back(std::make_shared<ERS_STRUCT_Model>(Model)); | ||
ModelLoader->AddModelToLoadingQueue(Scene->Models[Scene->Models.size()-1]); | ||
Scene->Models[Scene->Models.size()-1]->ApplyTransformations(); | ||
|
||
} else if (AssetType == std::string("DirectionalLight")) { | ||
|
||
ERS_STRUCT_DirectionalLight Light; | ||
Success &= ERS_FUNCTION_GetString (Logger, Item, "AssetName", Light.UserDefinedName ); | ||
Success &= ERS_FUNCTION_GetVec3Color (Logger, Item, "Color", Light.Color ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "Pos", Light.Pos ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "Rot", Light.Rot ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "Intensity", Light.Intensity ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "MaxDistance", Light.MaxDistance ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "CastShadows", Light.CastsShadows_ ); | ||
Success &= ERS_FUNCTION_GetLongVector (Logger, Item, "AttachedScripts", Light.AttachedScriptIndexes_ ); | ||
Scene->DirectionalLights.push_back(std::make_shared<ERS_STRUCT_DirectionalLight>(Light)); | ||
|
||
} else if (AssetType == std::string("PointLight")) { | ||
|
||
ERS_STRUCT_PointLight Light; | ||
Success &= ERS_FUNCTION_GetString (Logger, Item, "AssetName", Light.UserDefinedName ); | ||
Success &= ERS_FUNCTION_GetVec3Color (Logger, Item, "Color", Light.Color ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "Pos", Light.Pos ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "Intensity", Light.Intensity ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "MaxDistance", Light.MaxDistance ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "CastShadows", Light.CastsShadows_ ); | ||
Success &= ERS_FUNCTION_GetLongVector (Logger, Item, "AttachedScripts", Light.AttachedScriptIndexes_ ); | ||
Scene->PointLights.push_back(std::make_shared<ERS_STRUCT_PointLight>(Light)); | ||
|
||
} else if (AssetType == std::string("SpotLight")) { | ||
|
||
ERS_STRUCT_SpotLight Light; | ||
Success &= ERS_FUNCTION_GetString (Logger, Item, "AssetName", Light.UserDefinedName ); | ||
Success &= ERS_FUNCTION_GetVec3Color (Logger, Item, "Color", Light.Color ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "Pos", Light.Pos ); | ||
Success &= ERS_FUNCTION_GetVec3 (Logger, Item, "Rot", Light.Rot ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "Intensity", Light.Intensity ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "MaxDistance", Light.MaxDistance ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "CutOff", Light.CutOff ); | ||
Success &= ERS_FUNCTION_GetFloat (Logger, Item, "RollOff", Light.Rolloff ); | ||
Success &= ERS_FUNCTION_GetBool (Logger, Item, "CastShadows", Light.CastsShadows_ ); | ||
Success &= ERS_FUNCTION_GetLongVector (Logger, Item, "AttachedScripts", Light.AttachedScriptIndexes_ ); | ||
Scene->SpotLights.push_back(std::make_shared<ERS_STRUCT_SpotLight>(Light)); | ||
|
||
} else { | ||
SystemUtils->Logger_->Log(std::string("Unsupported/Unknown Asset Type: ") + AssetType, 9); | ||
} | ||
|
||
} | ||
|
||
// Indicate Scene Is Loaded | ||
if (!Success) { | ||
SystemUtils->Logger_->Log("Scene Decoding Failed", 8); | ||
} else { | ||
SystemUtils->Logger_->Log("Finished Decoding Scene", 4); | ||
} | ||
Scene->IsSceneLoaded = Success; | ||
return Success; | ||
|
||
} | ||
|
||
|
40 changes: 40 additions & 0 deletions
40
Source/Core/Loader/ERS_SceneLoader/ERS_FUNCTION_SceneDecoderV1.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//======================================================================// | ||
// This file is part of the BrainGenix-ERS Environment Rendering System // | ||
//======================================================================// | ||
|
||
#pragma once | ||
|
||
// Standard Libraries (BG convention: use <> instead of "") | ||
#include <string> | ||
#include <vector> | ||
|
||
// Third-Party Libraries (BG convention: use <> instead of "") | ||
#include <yaml-cpp/yaml.h> | ||
|
||
// Internal Libraries (BG convention: use <> instead of "") | ||
#include <ERS_STRUCT_SystemUtils.h> | ||
#include <ERS_STRUCT_Scene.h> | ||
#include <ERS_STRUCT_Model.h> | ||
#include <ERS_STRUCT_SceneCamera.h> | ||
#include <ERS_STRUCT_SpotLight.h> | ||
#include <ERS_STRUCT_PointLight.h> | ||
#include <ERS_STRUCT_DirectionalLight.h> | ||
|
||
#include <ERS_CLASS_ModelLoader.h> | ||
|
||
#include <ERS_FUNCTION_YAMLHelpers.h> | ||
|
||
|
||
|
||
|
||
/** | ||
* @brief Decodes the specified version of the scene format. | ||
* | ||
* @param SceneData YAML::Node containing the scene data. | ||
* @param Scene Pointer to the scene to be updated. | ||
* @param SystemUtils Pointer to the systemutils struct. | ||
* @param LogEnable Enable or disable information log messages. | ||
* @return true Loading completed without errors. | ||
* @return false Loading failed. | ||
*/ | ||
bool ERS_FUNCTION_DecodeSceneV1(YAML::Node SceneData, ERS_STRUCT_Scene *Scene, ERS_STRUCT_SystemUtils *SystemUtils, ERS_CLASS_ModelLoader* ModelLoader, bool LogEnable = true); |
Oops, something went wrong.