parent to camera
This commit is contained in:
@@ -37,7 +37,7 @@ void Transform::TranslateLocal(Vec3 offset)
|
||||
Position = bx::add(Position, {localOffset.x, localOffset.y, localOffset.z});
|
||||
}
|
||||
|
||||
void Transform::Rotate(bx::Vec3 rotation)
|
||||
void Transform::Rotate(Vec3 rotation)
|
||||
{
|
||||
float rot[16]{0};
|
||||
bx::mtxRotateXYZ(rot, rotation.x, rotation.y, rotation.z);
|
||||
@@ -46,7 +46,7 @@ void Transform::Rotate(bx::Vec3 rotation)
|
||||
bx::memCopy(Rotation.M, temp, sizeof(temp));
|
||||
}
|
||||
|
||||
void Transform::RotateLocal(bx::Vec3 rotation)
|
||||
void Transform::RotateLocal(Vec3 rotation)
|
||||
{
|
||||
float rot[16]{0};
|
||||
bx::mtxRotateXYZ(rot, rotation.x, rotation.y, rotation.z);
|
||||
@@ -135,7 +135,7 @@ Vec3 Transform::GlobalToLocalDirection(Vec3 global)
|
||||
bx::vec4MulMtx(out, in, MI.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
bx::Vec3 Transform::GlobalToLocalPoint(bx::Vec3 global)
|
||||
bx::Vec3 Transform::GlobalToLocalPoint(Vec3 global)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{global.x, global.y, global.z, 1.0f};
|
||||
@@ -152,7 +152,7 @@ Vec3 Transform::LocalToGlobalDirection(Vec3 local)
|
||||
bx::vec4MulMtx(out, in, test.M);
|
||||
return {out[0], out[1], out[2]};
|
||||
}
|
||||
bx::Vec3 Transform::LocalToGlobalPoint(bx::Vec3 local)
|
||||
bx::Vec3 Transform::LocalToGlobalPoint(Vec3 local)
|
||||
{
|
||||
UpdateMatrix();
|
||||
float in[4]{local.x, local.y, local.z, 1.0f};
|
||||
|
||||
@@ -214,11 +214,11 @@ struct Transform
|
||||
static void CreateTransform(float* out, bx::Vec3 pos, bx::Quaternion rot, bx::Vec3 scale);
|
||||
void Translate(Vec3 offset);
|
||||
void TranslateLocal(Vec3 offset);
|
||||
void Rotate(bx::Vec3 rotation);
|
||||
void RotateLocal(bx::Vec3 rotation);
|
||||
bx::Vec3 LocalToGlobalPoint(bx::Vec3 local);
|
||||
void Rotate(Vec3 rotation);
|
||||
void RotateLocal(Vec3 rotation);
|
||||
bx::Vec3 LocalToGlobalPoint(Vec3 local);
|
||||
Vec3 LocalToGlobalDirection(Vec3 local);
|
||||
bx::Vec3 GlobalToLocalPoint(bx::Vec3 global);
|
||||
bx::Vec3 GlobalToLocalPoint(Vec3 global);
|
||||
Vec3 GlobalToLocalDirection(Vec3 global);
|
||||
Vec3 Right() const;
|
||||
Vec3 Up() const;
|
||||
|
||||
@@ -364,12 +364,13 @@ namespace Game
|
||||
tile.EData.Transform.SetPosition(cardPos);
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||
|
||||
Mat4 tp = camTransform.M.Transpose();
|
||||
Vec3 fw = {tp.M[8], tp.M[9], tp.M[10]};
|
||||
camTransform.UpdateMatrixForCam();
|
||||
Vec3 fw = {camTransform.M.M[2], camTransform.M.M[6], camTransform.M.M[10]};
|
||||
Vec3 pos = camTransform.GetPosition() * -1;
|
||||
pos += fw;
|
||||
quad.EData.Transform.SetPosition(pos);
|
||||
quad.EData.Transform.Rotation = {};
|
||||
quad.EData.Transform.Rotation = camTransform.Rotation.Inverse();
|
||||
quad.EData.Transform.Rotate(Vec3{bx::kPi * 0.5f, 0.0f, 0.0f});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,22 +476,6 @@ namespace Game
|
||||
debug.DebugCardRotation++;
|
||||
if (debug.DebugCardRotation >= 4) debug.DebugCardRotation = 0;
|
||||
}
|
||||
ImGui::SetNextWindowPos({0, 0});
|
||||
if (ImGui::Begin("Stats",
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs |
|
||||
ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
if (GetInstance().Player.CameraM == CameraMode::Freefly)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, {0.8f, 0.1f, 0.1f, 1.0f});
|
||||
ImGui::Text("NOCLIP");
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::Text("Delta: %.01fms", time.Delta * 1000);
|
||||
ImGui::Text("FPS: %.0f", 1.0 / time.Delta);
|
||||
}
|
||||
ImGui::End();
|
||||
if (ImGui::Begin("Log"))
|
||||
{
|
||||
ImGui::Checkbox("Shorten File Names", &GetInstance().DebugData.ShortenLogFileNames);
|
||||
@@ -717,6 +701,7 @@ namespace Game
|
||||
{
|
||||
ZoneScopedN("Rendering");
|
||||
SharedData& shared = GetShared();
|
||||
auto& time = GetInstance().Time;
|
||||
|
||||
HandleEvents();
|
||||
|
||||
@@ -732,6 +717,22 @@ namespace Game
|
||||
{
|
||||
RenderDebugUI();
|
||||
}
|
||||
ImGui::SetNextWindowPos({0, 0});
|
||||
if (ImGui::Begin("Stats",
|
||||
nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs |
|
||||
ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
if (GetInstance().Player.CameraM == CameraMode::Freefly)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, {0.8f, 0.1f, 0.1f, 1.0f});
|
||||
ImGui::Text("NOCLIP");
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
ImGui::Text("Delta: %.01fms", time.Delta * 1000);
|
||||
ImGui::Text("FPS: %.0f", 1.0 / time.Delta);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
GetInstance().GameLevel.Update();
|
||||
GetInstance().GameLevel.Render(MainViewID, Models, Materials);
|
||||
|
||||
Reference in New Issue
Block a user