Object inspector window
This commit is contained in:
parent
a2dd35513e
commit
c153c88032
@ -164,6 +164,7 @@ bool SystemClass::Frame()
|
|||||||
m_imguiManager->WidgetButton();
|
m_imguiManager->WidgetButton();
|
||||||
m_imguiManager->WidgetFPS();
|
m_imguiManager->WidgetFPS();
|
||||||
m_imguiManager->WidgetAddObject(m_Application);
|
m_imguiManager->WidgetAddObject(m_Application);
|
||||||
|
m_imguiManager->WidgetObjectWindow(m_Application);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
|
|
||||||
void AddCube();
|
void AddCube();
|
||||||
int GetCubeCount() const { return m_cubes.size(); };
|
int GetCubeCount() const { return m_cubes.size(); };
|
||||||
|
std::vector<Object*> GetCubes() const { return m_cubes; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Render(float);
|
bool Render(float);
|
||||||
|
@ -3,6 +3,10 @@ Pos=60,60
|
|||||||
Size=400,400
|
Size=400,400
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=54,81
|
Pos=1068,19
|
||||||
Size=694,367
|
Size=694,367
|
||||||
|
|
||||||
|
[Window][Objects]
|
||||||
|
Pos=74,113
|
||||||
|
Size=492,353
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "imguiManager.h"
|
#include "imguiManager.h"
|
||||||
#include "applicationclass.h"
|
#include "applicationclass.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
imguiManager::imguiManager()
|
imguiManager::imguiManager()
|
||||||
{
|
{
|
||||||
@ -75,3 +76,25 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
|
|||||||
ImGui::Text("Number of cubes: %d", app->GetCubeCount());
|
ImGui::Text("Number of cubes: %d", app->GetCubeCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Objects");
|
||||||
|
int index = 0;
|
||||||
|
for (auto object : app->GetCubes())
|
||||||
|
{
|
||||||
|
std::string headerName = "Object " + std::to_string(index);
|
||||||
|
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||||
|
{
|
||||||
|
XMVECTOR position = object->GetPosition();
|
||||||
|
XMVECTOR rotation = object->GetRotation();
|
||||||
|
XMVECTOR scale = object->GetScale();
|
||||||
|
ImGui::Text("Position: %.2f %.2f %.2f", XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position));
|
||||||
|
ImGui::Text("Rotation: %.2f %.2f %.2f", XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation));
|
||||||
|
ImGui::Text("Scale: %.2f %.2f %.2f", XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale));
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
@ -26,6 +26,8 @@ public:
|
|||||||
void WidgetFPS();
|
void WidgetFPS();
|
||||||
void WidgetAddObject(ApplicationClass* app);
|
void WidgetAddObject(ApplicationClass* app);
|
||||||
|
|
||||||
|
void WidgetObjectWindow(ApplicationClass* app);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImGuiIO* io;
|
ImGuiIO* io;
|
||||||
};
|
};
|
||||||
|
@ -61,4 +61,32 @@ XMMATRIX Object::GetSRMatrix()
|
|||||||
XMMATRIX Object::GetWorldMatrix()
|
XMMATRIX Object::GetWorldMatrix()
|
||||||
{
|
{
|
||||||
return m_worldMatrix;
|
return m_worldMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMVECTOR Object::GetPosition()
|
||||||
|
{
|
||||||
|
XMFLOAT4X4 matrix;
|
||||||
|
XMStoreFloat4x4(&matrix, m_worldMatrix);
|
||||||
|
return XMVectorSet(matrix._41, matrix._42, matrix._43, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMVECTOR Object::GetRotation()
|
||||||
|
{
|
||||||
|
XMFLOAT4X4 matrix;
|
||||||
|
XMStoreFloat4x4(&matrix, m_rotateMatrix);
|
||||||
|
float rotationX = atan2f(matrix._32, matrix._33);
|
||||||
|
float rotationY = atan2f(-matrix._31, sqrtf(matrix._32 * matrix._32 + matrix._33 * matrix._33));
|
||||||
|
float rotationZ = atan2f(matrix._21, matrix._11);
|
||||||
|
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XMVECTOR Object::GetScale()
|
||||||
|
{
|
||||||
|
XMFLOAT4X4 matrix;
|
||||||
|
XMStoreFloat4x4(&matrix, m_scaleMatrix);
|
||||||
|
float scaleX = XMVectorGetX(XMVector3Length(XMVectorSet(matrix._11, matrix._12, matrix._13, 0.0f)));
|
||||||
|
float scaleY = XMVectorGetX(XMVector3Length(XMVectorSet(matrix._21, matrix._22, matrix._23, 0.0f)));
|
||||||
|
float scaleZ = XMVectorGetX(XMVector3Length(XMVectorSet(matrix._31, matrix._32, matrix._33, 0.0f)));
|
||||||
|
return XMVectorSet(scaleX, scaleY, scaleZ, 0.0f);
|
||||||
}
|
}
|
@ -13,12 +13,20 @@ public:
|
|||||||
void SetSRMatrix(XMMATRIX srMatrix);
|
void SetSRMatrix(XMMATRIX srMatrix);
|
||||||
void SetWorldMatrix(XMMATRIX worldMatrix);
|
void SetWorldMatrix(XMMATRIX worldMatrix);
|
||||||
|
|
||||||
|
void SetPosition(XMVECTOR position);
|
||||||
|
void SetRotation(XMVECTOR rotation);
|
||||||
|
void SetScale(XMVECTOR scale);
|
||||||
|
|
||||||
XMMATRIX GetScaleMatrix();
|
XMMATRIX GetScaleMatrix();
|
||||||
XMMATRIX GetRotateMatrix();
|
XMMATRIX GetRotateMatrix();
|
||||||
XMMATRIX GetTranslateMatrix();
|
XMMATRIX GetTranslateMatrix();
|
||||||
XMMATRIX GetSRMatrix();
|
XMMATRIX GetSRMatrix();
|
||||||
XMMATRIX GetWorldMatrix();
|
XMMATRIX GetWorldMatrix();
|
||||||
|
|
||||||
|
XMVECTOR GetPosition();
|
||||||
|
XMVECTOR GetRotation();
|
||||||
|
XMVECTOR GetScale();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XMMATRIX m_scaleMatrix;
|
XMMATRIX m_scaleMatrix;
|
||||||
XMMATRIX m_rotateMatrix;
|
XMMATRIX m_rotateMatrix;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user