69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#include "ModelWorld.h"
|
|
#include <RenderingSystem.h>
|
|
|
|
ModelWorld::ModelWorld()
|
|
{
|
|
light.lightDirection = glm::normalize(glm::vec3((cos(lightPitch) * cos(lightYaw)), (sin(lightPitch)), (cos(lightPitch) * sin(lightYaw))));
|
|
light.radiance = 3.f * lightColor;
|
|
RenderingSystem::instance().exposure = 0.45f;
|
|
|
|
model = std::make_shared<Actor>("Models/David_Brown_25D_tractor_SF/David_Brown_25D_tractor_SF.obj");
|
|
model->setPosition({ 0,0,0 });
|
|
addActor(model);
|
|
|
|
camera.Position = { 0,10,20 };
|
|
}
|
|
|
|
void ModelWorld::logicalTick(float deltaTime)
|
|
{
|
|
World::logicalTick(deltaTime);
|
|
}
|
|
|
|
void ModelWorld::rendererTick(float deltaTime)
|
|
{
|
|
World::rendererTick(deltaTime);
|
|
}
|
|
|
|
void ModelWorld::cursorPosCallback(GLFWwindow* window, double xpos, double ypos)
|
|
{
|
|
static bool firstMouse = true;
|
|
static float lastX;
|
|
static float lastY;
|
|
|
|
float xoffset = xpos - lastX;
|
|
float yoffset = lastY - ypos;
|
|
|
|
lastX = xpos;
|
|
lastY = ypos;
|
|
|
|
if (firstMouse)
|
|
{
|
|
firstMouse = false;
|
|
return;
|
|
}
|
|
|
|
if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS)
|
|
camera.processMouseMovement(xoffset, yoffset);
|
|
}
|
|
|
|
void ModelWorld::scrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
|
{
|
|
camera.processMouseScroll(yoffset);
|
|
}
|
|
|
|
void ModelWorld::processInput(GLFWwindow* window, float deltaTime)
|
|
{
|
|
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
|
camera.processKeyboard(FORWARD, deltaTime);
|
|
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
|
camera.processKeyboard(BACKWARD, deltaTime);
|
|
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
|
camera.processKeyboard(LEFT, deltaTime);
|
|
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
|
camera.processKeyboard(RIGHT, deltaTime);
|
|
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
|
camera.processKeyboard(UP, deltaTime);
|
|
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
|
camera.processKeyboard(DOWN, deltaTime);
|
|
}
|