virtual void GUIPanel() override { Application::GUIPanel(); // proj ImGui::Separator(); ImGui::DragFloat("Cam FOV", &m_CameraFOV, 0.05f); // model ImGui::Separator(); ImGui::Separator(); AVector3 pos = m_Root.GetLocalTranslation(); ImGui::DragFloat3("Cube Pos", (float*)&pos, 0.05f); m_Root.SetLocalTranslation(pos); AVector3 rot = m_Root.GetLocalRotation() * AVector3(Rad2Deg); ImGui::DragFloat3("Cube Rot", (float*)&rot, 0.05f); m_Root.SetLocalRotation(rot * AVector3(Deg2Rad)); AVector3 sca = m_Root.GetLocalScale(); ImGui::DragFloat3("Cube Scale", (float*)&sca, 0.05f); m_Root.SetLocalScale(sca); ImGui::Checkbox("Spin Cube", &m_SpinCube); ImGui::DragFloat("Spin Speed", &m_CubeRotationSpeed, 0.001f); // application ImGui::Separator(); if (ImGui::Button("Reset")) { ResetScene(); } }
virtual void Tick(float deltaTime) override { Application::Tick(deltaTime); m_AppTime += deltaTime; constexpr float tau = 6.28318530718; AVector3 r = m_Root.GetLocalRotation(); r.x = WrapMinMax(r.x, 0.f, tau); r.y = WrapMinMax(r.y, 0.f, tau); r.z = WrapMinMax(r.z, 0.f, tau); m_Root.SetLocalRotation(r); r = m_Root.GetLocalRotation(); if (m_SpinCube) { m_Root.SetLocalRotation(r += AVector3(deltaTime * m_CubeRotationSpeed)); } size_t i = 0; for (int x = -CUBES_XYZ[0]; x < CUBES_XYZ[0]; ++x) { for (int y = -CUBES_XYZ[1]; y < CUBES_XYZ[1]; ++y) { for (int z = -CUBES_XYZ[2]; z < CUBES_XYZ[2]; ++z) { m_Cubes[i].SetLocalRotation((AVector3((float)x, (float)y, (float)z ) * AVector3(m_AppTime*m_CubeRotationSpeed))); ++i; } } } m_CamTarget = m_Root.GetLocalTranslation(); m_Proj = AMatrix4x4::PerspectiveFOV(m_CameraFOV * Deg2Rad, (float)m_Width / (float)m_Height); m_View = AMatrix4x4::LookAt(m_CamPosition, m_CamTarget, m_CamUp); AMatrix4x4::Invert(m_View); m_Scene.Update(); for (auto& so : m_Cubes) { m_MatrixMVP = so.GetModelNoUpdate() * (m_View * m_Proj); SetMVP(m_MatrixMVP.v); RenderCube(); } }