init
This commit is contained in:
1 parent
b299a8d8a2
commit
edda71212c
941 files changed
+272423
-31
No files matched your search
@@ -7,6 +7,8 @@
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <assimp/Importer.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Object3D.h"
|
||||
@@ -25,21 +27,22 @@ bool mouse_lock = true;
|
||||
float last_x = 400, last_y = 300;
|
||||
|
||||
// Flipped Stuff
|
||||
const float flip_cooldown = 1.0f; // In seconds
|
||||
const float FLIP_COOLDOWN = 1.0f; // In seconds
|
||||
float last_flip = 0.0f;
|
||||
int flipped = 1; // 1 for normal, -1 for flipped
|
||||
bool flipping = false;
|
||||
glm::vec3 flip_target = glm::vec3(0.0f);
|
||||
|
||||
// Jump
|
||||
const float jump_cooldown = 1.0f;
|
||||
const float JUMP_COOLDOWN = 0.0f;
|
||||
const float JUMP_POWER = 10.0f; // Initial Jump Speed
|
||||
float last_jump = 0.0f;
|
||||
|
||||
// Various other settings
|
||||
const float camera_speed = 1.0f;
|
||||
const float max_camera_speed = 2.0f;
|
||||
const float CAMERA_SPEED = 1.0f;
|
||||
const float MAX_CAMERA_SPEED = 2.0f;
|
||||
|
||||
const float look_sensitivity = 0.1f;
|
||||
const float LOOK_SENSITIVITY = 0.1f;
|
||||
const float Z_FAR = 1000.0f;
|
||||
const float Z_NEAR = 0.1f;
|
||||
const bool WIREFRAME_MODE = !true;
|
||||
@@ -54,7 +57,7 @@ glm::mat4 projection = glm::mat4(1.0f);
|
||||
float yaw, pitch = 0;
|
||||
|
||||
// Camera
|
||||
Camera camera = Camera(camera_speed, glm::vec3(0.0f, 0.0f, 115.0f));
|
||||
Camera camera = Camera(CAMERA_SPEED, glm::vec3(0.0f, 0.0f, 115.0f));
|
||||
|
||||
|
||||
// Lighting
|
||||
@@ -84,8 +87,8 @@ void mouse_callback(GLFWwindow * window, double xpos, double ypos)
|
||||
return;
|
||||
}
|
||||
|
||||
x_offset *= look_sensitivity;
|
||||
y_offset *= look_sensitivity;
|
||||
x_offset *= LOOK_SENSITIVITY;
|
||||
y_offset *= LOOK_SENSITIVITY;
|
||||
|
||||
yaw += x_offset * flipped;
|
||||
pitch += y_offset * flipped;
|
||||
@@ -209,10 +212,11 @@ int main()
|
||||
|
||||
|
||||
// Orbitting sun thing?
|
||||
float t = glfwGetTime() * 10.0f;
|
||||
float t = glfwGetTime() * 0.1f;
|
||||
float radius = 15.0f;
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
model = glm::scale(model, glm::vec3(109)); // The sun should be BIG
|
||||
model = glm::rotate(model, glm::radians(t), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
glm::vec3 sun_pos = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
model = glm::translate(model, sun_pos);
|
||||
@@ -304,6 +308,7 @@ int main()
|
||||
{
|
||||
const double FPS = frame_count / (delta_time);
|
||||
std::cout << "FPS: " << FPS << std::endl;
|
||||
std::cout << "pos: " << camera.position.x << " " << camera.position.y << " " << camera.position.z << std::endl;
|
||||
|
||||
frame_count = 0;
|
||||
start_time = glfwGetTime();
|
||||
@@ -402,23 +407,23 @@ void processInput(GLFWwindow *window)
|
||||
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||
// camera.velocity -= glm::normalize(glm::cross(camera.target, glm::normalize(glm::cross(camera.target, camera.worldUp)))) * camera.speed * 0.5f;
|
||||
{
|
||||
if (current_time - last_jump > jump_cooldown && camera.position.y == 0)
|
||||
if (current_time - last_jump > JUMP_COOLDOWN && camera.position.y == 0)
|
||||
{
|
||||
camera.vertical_velocity.y += 10.0f;
|
||||
camera.vertical_velocity.y = JUMP_POWER;
|
||||
last_jump = current_time;
|
||||
}
|
||||
}
|
||||
|
||||
// Sprint
|
||||
if(glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||
camera.speed = camera_speed * 7.5;
|
||||
camera.speed = CAMERA_SPEED * 7.5;
|
||||
if(glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_RELEASE)
|
||||
camera.speed = camera_speed * 20;
|
||||
camera.speed = CAMERA_SPEED * 20;
|
||||
|
||||
// World Flip
|
||||
if(glfwGetKey(window, GLFW_KEY_F) == GLFW_PRESS)
|
||||
{
|
||||
if (current_time - last_flip > flip_cooldown && !flipping)
|
||||
if (current_time - last_flip > FLIP_COOLDOWN && !flipping)
|
||||
{
|
||||
// flip_target = camera.worldUp;
|
||||
// flip_target *= -1;
|
||||
|
||||
Reference in new issue
Block a user