Skip to content

Commit

Permalink
Implemented Transform::position properties in inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
AitorSimona committed Oct 21, 2019
1 parent 2b1f6dd commit beb6ac1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CENTRAL 3D/Source/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ std::string GameObject::GetName() const
float3 GameObject::GetPosition()
{
float3 position;
Local_transform.TransformPos(position);
Local_transform.TranslatePart();
/*Local_transform.TransformPos(position);
Local_transform.TranslatePart();*/

position.x = Local_transform.ptr()[12];
position.y = Local_transform.ptr()[13];
position.z = Local_transform.ptr()[14];


return position;
}
Expand Down
46 changes: 46 additions & 0 deletions CENTRAL 3D/Source/PanelInspector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "PanelInspector.h"
#include "Imgui/imgui.h"

#include "Application.h"
#include "ModuleSceneManager.h"

#include "GameObject.h"

#include "mmgr/mmgr.h"

Expand All @@ -19,7 +23,49 @@ bool PanelInspector::Draw()

if (ImGui::Begin(name, &enabled, settingsFlags))
{
GameObject* Selected = App->scene_manager->GetGameObjects().at(App->scene_manager->GetSelectedGameObjects());

ImGui::SetNextItemOpen(true);

if (ImGui::TreeNode("Transform"))
{

// --- Transform ---
float3 position = Selected->GetPosition();
ImGui::Text("X");
ImGui::SameLine();
ImGui::SetNextItemWidth(100.0f);

ImGui::DragFloat(" ", &position.x, 0.005f);

ImGui::SameLine();

ImGui::Text("Y");
ImGui::SameLine();
ImGui::SetNextItemWidth(100.0f);

ImGui::DragFloat(" ", &position.y, 0.005f);

ImGui::SameLine();

ImGui::Text("Z");
ImGui::SameLine();
ImGui::SetNextItemWidth(100.0f);

ImGui::DragFloat(" ", &position.z, 0.005f);

Selected->SetPosition(position.x, position.y, position.z);

ImGui::TreePop();
}

ImGui::Separator();


if (Selected->GetComponent(Component::ComponentType::Mesh))
{

}
}

ImGui::End();
Expand Down

0 comments on commit beb6ac1

Please sign in to comment.