added a scene
This commit is contained in:
parent
10708e5c7f
commit
a66222fdba
|
@ -13,7 +13,7 @@
|
|||
using namespace sim::graphics;
|
||||
|
||||
static double yaw = 0, pitch = 0;
|
||||
static glm::vec<3, double> pos(56, 90, 8);
|
||||
static glm::vec<3, double> pos(0, 0, 2);
|
||||
static glm::vec<3, double> velocity(0);
|
||||
|
||||
void camera::rotate(double y, double p)
|
||||
|
@ -35,7 +35,7 @@ void camera::move(double xoff, double yoff, double zoff)
|
|||
void camera::update()
|
||||
{
|
||||
glm::vec<2, double> off(0, 0);
|
||||
double m = 0.01;
|
||||
double m = 0.002;
|
||||
|
||||
if(keyboard::is_pressed(GLFW_KEY_W))
|
||||
off.y += 1;
|
||||
|
@ -60,15 +60,15 @@ void camera::update()
|
|||
glm::vec<2, double> rotated = glm::vec<2, double>(off.x, off.y) * mat;
|
||||
bool on_ground = false;
|
||||
|
||||
velocity.z -= 0.00981;
|
||||
velocity.z -= 0.000981;
|
||||
|
||||
if(pos.z + velocity.z < 3.5)
|
||||
if(pos.z + velocity.z < 1.6)
|
||||
{
|
||||
on_ground = true;
|
||||
|
||||
if(keyboard::is_pressed(GLFW_KEY_SPACE))
|
||||
{
|
||||
velocity.z += 0.4;
|
||||
velocity.z += 0.04;
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -84,6 +84,11 @@ void camera::update()
|
|||
|
||||
velocity.x += rotated.x * m;
|
||||
velocity.y += rotated.y * m;
|
||||
|
||||
if(std::abs(pos.x + velocity.x) > 2.9)
|
||||
velocity.x = 0;
|
||||
if(std::abs(pos.y + velocity.y) > 3.9)
|
||||
velocity.y = 0;
|
||||
|
||||
pos += velocity;
|
||||
velocity *= glm::vec<3, double>(on_ground ? 0.9 : 0.9999);
|
||||
|
|
|
@ -54,13 +54,13 @@ unsigned int texture::load(std::string path)
|
|||
unsigned int texid;
|
||||
|
||||
glCreateTextures(GL_TEXTURE_2D, 1, &texid);
|
||||
glTextureStorage2D(texid, 1, format_in, width, height);
|
||||
glTextureStorage2D(texid, 8, format_in, width, height);
|
||||
glTextureSubImage2D(texid, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
stbi_image_free(data);
|
||||
|
||||
glTextureParameteri(texid, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(texid, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(texid, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTextureParameteri(texid, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTextureParameteri(texid, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(texid, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glGenerateTextureMipmap(texid);
|
||||
|
|
|
@ -70,7 +70,8 @@ void window::create()
|
|||
|
||||
shader::init_program();
|
||||
|
||||
Model.load("Minimalistic Modern Office", "Minimalistic Modern Office.fbx");
|
||||
// Model.load("Minimalistic Modern Office", "Minimalistic Modern Office.fbx");
|
||||
Model.load("../assets", "scene.obj");
|
||||
|
||||
glViewport(0, 0, 800, 600);
|
||||
}
|
||||
|
@ -94,12 +95,7 @@ void window::loop()
|
|||
double mouse_x, mouse_y;
|
||||
mouse::get(mouse_x, mouse_y);
|
||||
|
||||
mat_model = glm::translate(mat_model, glm::vec3(0, -90, 0));
|
||||
// mat_model = glm::rotate(mat_model, float(M_PI * 0.125), glm::vec3(1, 1, 1));
|
||||
mat_model = glm::scale(mat_model, glm::vec3(15, 60, 15));
|
||||
mat_model = glm::rotate(mat_model, -float(M_PI) / 2, glm::vec3(0, 1, 0));
|
||||
|
||||
glm::mat4 mat_projection = glm::perspective(glm::radians(90.0f), (float)resize::get_aspect(), 0.1f, 200.f);
|
||||
glm::mat4 mat_projection = glm::perspective(glm::radians(90.0f), (float)resize::get_aspect(), 0.01f, 20.f);
|
||||
|
||||
glUniformMatrix4fv(shader::gl_tex_mat, 1, false, &mat_colour[0][0]);
|
||||
glUniformMatrix4fv(shader::gl_projection, 1, false, &mat_projection[0][0]);
|
||||
|
|
Loading…
Reference in New Issue