Skip to content

Commit

Permalink
Merged dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SNAKFRIEN committed Jul 2, 2021
2 parents bacfbf4 + d5f4c77 commit fcf147a
Show file tree
Hide file tree
Showing 29 changed files with 1,097 additions and 515 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,5 @@ Lumen_Engine/Sandbox/assets/models/Astronaut/
Lumen_Engine/Sandbox/assets/gltfExternalAssets

Lumen_Engine/Sandbox/assets/models/ConferenceRoom/

*.png
4 changes: 2 additions & 2 deletions Lumen_Engine/Lumen/src/Lumen/ImGui/ImGuiLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace Lumen
void ImGuiLayer::OnImGuiRender()
{
static bool show = true;
ImGui::ShowDemoWindow(&show);
ImPlot::ShowDemoWindow();
//ImGui::ShowDemoWindow(&show);
//ImPlot::ShowDemoWindow();
}
}
60 changes: 59 additions & 1 deletion Lumen_Engine/Lumen/src/Lumen/ModelLoading/ILumenScene.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
#include "ILumenScene.h"

Lumen::ILumenScene::Node* Lumen::ILumenScene::Node::AddChild()
{
m_ChildNodes.push_back(std::make_unique<Node>());
m_Transform.AddChild(m_ChildNodes.back()->m_Transform);
m_ChildNodes.back()->m_Parent = this;
return m_ChildNodes.back().get();
}

void Lumen::ILumenScene::Node::AddChild(std::unique_ptr<Lumen::ILumenScene::Node>& a_Node)
{

if (a_Node->m_Parent)
a_Node->m_Parent->RemoveChild(a_Node);

//m_ChildNodes.pu
}

void Lumen::ILumenScene::Node::RemoveChild(std::unique_ptr<Lumen::ILumenScene::Node>& a_Node)
{
/*auto fIter = std::find(m_ChildNodes.begin(), m_ChildNodes.end(), &a_Node);
if (fIter != m_ChildNodes.end())
{
m_ChildNodes.erase(fIter);
}
m_Transform.RemoveChild(a_Node->m_Transform);
a_Node->m_Parent = nullptr;
a_Node->m_Transform.SetParent(nullptr);*/
}

Lumen::ILumenScene::Node* Lumen::ILumenScene::Node::GetFirstIntermediateNode(const Node* a_ParentNode) const
{
auto p = m_Parent;
Node* n = nullptr;
while (p != nullptr)
{
if (p == a_ParentNode)
{
return n;
}
n = p;
p = p->m_Parent;
}
}

bool Lumen::ILumenScene::Node::IsChildOf(const Node& a_Node) const
{
auto p = m_Parent;
while (p != nullptr)
{
if (p == &a_Node)
{
return true;
}
p = p->m_Parent;
}
return false;
}

Lumen::MeshInstance* Lumen::ILumenScene::AddMesh()
{
m_MeshInstances.push_back(std::make_unique<MeshInstance>());
Expand All @@ -16,4 +74,4 @@ void Lumen::ILumenScene::Clear()
{
m_VolumeInstances.clear();
m_MeshInstances.clear();
}
}
36 changes: 33 additions & 3 deletions Lumen_Engine/Lumen/src/Lumen/ModelLoading/ILumenScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,42 @@ namespace Lumen
class ILumenScene
{
public:
struct Node
{
Node()
: m_MeshInstancePtr(nullptr)
, m_VolumeInstancePtr(nullptr)
, m_Parent(nullptr)
, m_Name("Unnamed Node")
, m_ScenePtr(nullptr)
{}


Node* AddChild();

void AddChild(std::unique_ptr<Lumen::ILumenScene::Node>& a_Node);
void RemoveChild(std::unique_ptr<Lumen::ILumenScene::Node>& a_Node);

Node* GetFirstIntermediateNode(const Node* a_ParentNode) const;

bool IsChildOf(const Node& a_Node) const;

Transform m_Transform;
std::string m_Name;
Node* m_Parent;
ILumenScene* m_ScenePtr; // Initialized to the scene pointer for the root node
std::vector<std::unique_ptr<Node>> m_ChildNodes;
Lumen::MeshInstance* m_MeshInstancePtr;
Lumen::VolumeInstance* m_VolumeInstancePtr;
};

/// <summary>
/// Takes in camera data on initialization
/// </summary>
/// <param name="a_CamPosition"></param>
/// <param name="a_CamUp"></param>
ILumenScene(glm::vec3 a_CamPosition = glm::vec3(0, 0, -50.f), glm::vec3 a_CamUp = glm::vec3(0, 1, 0))
: m_Camera(std::make_unique<Camera>(a_CamPosition, a_CamUp)) {};
: m_Camera(std::make_unique<Camera>(a_CamPosition, a_CamUp)) {};
virtual ~ILumenScene() {};

// Adds a mesh instance to the scene. Use this instead of manually adding instances to m_MeshInstances
Expand All @@ -35,8 +64,9 @@ namespace Lumen
std::vector<unsigned int> m_MeshLightIndices;
std::vector<std::unique_ptr<Lumen::VolumeInstance>> m_VolumeInstances;
const std::unique_ptr<Camera> m_Camera;
//accelleration structure
std::vector<std::unique_ptr<Node>> m_RootNodes; // GLTF allows for multiple root nodes in the same scene, so support that
//accelleration structure

private:
};
}
}
2 changes: 1 addition & 1 deletion Lumen_Engine/Lumen/src/Lumen/ModelLoading/SceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void Lumen::SceneManager::LoadNodes(fx::gltf::Document& a_Doc, GLTFResource& a_R
t.SetRotation(rotation);
t.SetScale(scale);

transform = t.GetTransformationMatrix();
transform = t.GetWorldTransformationMatrix();
}

const glm::mat4 chainedTransform = a_TransformMat * transform;
Expand Down
Loading

0 comments on commit fcf147a

Please sign in to comment.