airplane
This commit is contained in:
@@ -17,6 +17,7 @@ public:
|
|||||||
glm::mat4 GetFrustrumMatrix();
|
glm::mat4 GetFrustrumMatrix();
|
||||||
|
|
||||||
void UpdateProjection(int width, int height);
|
void UpdateProjection(int width, int height);
|
||||||
|
void UpdateProjection();
|
||||||
|
|
||||||
// Keyboard
|
// Keyboard
|
||||||
void MoveCamera(uint8_t posDelta);
|
void MoveCamera(uint8_t posDelta);
|
||||||
@@ -33,6 +34,7 @@ public:
|
|||||||
|
|
||||||
glm::vec3 Position = {};
|
glm::vec3 Position = {};
|
||||||
float Roll, Pitch, Yaw;
|
float Roll, Pitch, Yaw;
|
||||||
|
float FOV = 45.0f;
|
||||||
glm::vec3 LookDirection = {};
|
glm::vec3 LookDirection = {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -176,9 +176,7 @@ int Inferno::run()
|
|||||||
|
|
||||||
if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar))
|
if (showPreview && ImGui::Begin("Preview", nullptr, ImGuiWindowFlags_NoScrollbar))
|
||||||
{
|
{
|
||||||
const bool allowMove = ImGui::IsWindowHovered();
|
if (ImGui::IsWindowHovered())
|
||||||
|
|
||||||
if (allowMove)
|
|
||||||
{
|
{
|
||||||
this->moveInput();
|
this->moveInput();
|
||||||
} else
|
} else
|
||||||
@@ -201,12 +199,18 @@ int Inferno::run()
|
|||||||
|
|
||||||
if (ImGui::Begin("Render"))
|
if (ImGui::Begin("Render"))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showRenderSettings && ImGui::Begin("Inferno HART"))
|
if (showRenderSettings && ImGui::Begin("Inferno HART"))
|
||||||
{
|
{
|
||||||
|
if (ImGui::TreeNode("Render"))
|
||||||
|
{
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Camera"))
|
if (ImGui::TreeNode("Camera"))
|
||||||
{
|
{
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
@@ -223,9 +227,13 @@ int Inferno::run()
|
|||||||
camera.UpdateView();
|
camera.UpdateView();
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::Text("Camera Zoom");
|
||||||
|
ImGui::DragFloat("Zoom", &camera.FOV, -0.1f, 0.0f, 180.0f, "%.2f", ImGuiSliderFlags_None); ImGui::SameLine();
|
||||||
|
camera.UpdateProjection();
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using namespace inferno;
|
|||||||
|
|
||||||
Camera::Camera()
|
Camera::Camera()
|
||||||
{
|
{
|
||||||
mProjMatrix = glm::perspective( glm::radians( 45.0f ), 1.0f, 0.1f, 1000.0f );
|
mProjMatrix = glm::perspective( glm::radians(FOV), 1.0f, 0.1f, 1000.0f );
|
||||||
|
|
||||||
Roll = 0.0f;
|
Roll = 0.0f;
|
||||||
Pitch = 0.0f;
|
Pitch = 0.0f;
|
||||||
@@ -20,7 +20,7 @@ Camera::Camera()
|
|||||||
|
|
||||||
Camera::Camera(int w, int h)
|
Camera::Camera(int w, int h)
|
||||||
{
|
{
|
||||||
mProjMatrix = glm::perspective(glm::radians(45.0f), (float)w / (float)h, 0.1f, 1000.0f);
|
mProjMatrix = glm::perspective(glm::radians(FOV), (float)w / (float)h, 0.1f, 1000.0f);
|
||||||
|
|
||||||
Roll = 0.0f;
|
Roll = 0.0f;
|
||||||
Pitch = 0.0f;
|
Pitch = 0.0f;
|
||||||
@@ -42,9 +42,9 @@ void Camera::UpdateView()
|
|||||||
glm::mat4 matYaw = glm::mat4(1.0f); //identity matrix
|
glm::mat4 matYaw = glm::mat4(1.0f); //identity matrix
|
||||||
|
|
||||||
// roll, pitch and yaw
|
// roll, pitch and yaw
|
||||||
matRoll = glm::rotate( matRoll, Roll, glm::vec3(0.0f, 0.0f, 1.0f));
|
matRoll = glm::rotate(matRoll, Roll, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
matPitch = glm::rotate( matPitch, Pitch, glm::vec3(1.0f, 0.0f, 0.0f));
|
matPitch = glm::rotate(matPitch, Pitch, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
matYaw = glm::rotate( matYaw, Yaw, glm::vec3( 0.0f, 1.0f, 0.0f));
|
matYaw = glm::rotate(matYaw, Yaw, glm::vec3( 0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
glm::mat4 rotate = matRoll * matPitch * matYaw;
|
glm::mat4 rotate = matRoll * matPitch * matYaw;
|
||||||
|
|
||||||
@@ -74,7 +74,12 @@ glm::mat4 Camera::GetProjectionMatrix()
|
|||||||
void Camera::UpdateProjection(int width, int height)
|
void Camera::UpdateProjection(int width, int height)
|
||||||
{
|
{
|
||||||
mViewport = {width, height};
|
mViewport = {width, height};
|
||||||
mProjMatrix = glm::perspective(glm::radians(45.0f), (float)width / (float)height, 0.1f, 1000.0f);
|
mProjMatrix = glm::perspective(glm::radians(FOV), (float)width / (float)height, 0.1f, 1000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::UpdateProjection()
|
||||||
|
{
|
||||||
|
mProjMatrix = glm::perspective(glm::radians(FOV), mViewport.x / mViewport.y, 0.1f, 1000.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::MoveCamera(uint8_t posDelta)
|
void Camera::MoveCamera(uint8_t posDelta)
|
||||||
|
|||||||
Reference in New Issue
Block a user