Skip to content

Commit

Permalink
obj textures
Browse files Browse the repository at this point in the history
  • Loading branch information
gramosomi committed May 26, 2024
1 parent 9b5cb1c commit 93bd6a0
Show file tree
Hide file tree
Showing 29 changed files with 872 additions and 852 deletions.
1 change: 0 additions & 1 deletion common/include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ typedef struct Point {
x * other.y - y * other.x);
}


} Point;

struct Point2D {
Expand Down
8 changes: 4 additions & 4 deletions engine/include/Camera.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef CAMERA_HPP
#define CAMERA_HPP

#include <string>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <string>

#include "Camera.hpp"
#include "utils.hpp"


class Camera {
public:
glm::vec3 position;
Expand All @@ -21,8 +21,8 @@ class Camera {
float far;

Camera();
Camera(glm::vec3 position, glm::vec3 lookAt, glm::vec3 up, int fov, float near,
float far);
Camera(glm::vec3 position, glm::vec3 lookAt, glm::vec3 up, int fov,
float near, float far);

Camera(const Camera& other);

Expand Down
48 changes: 24 additions & 24 deletions engine/include/controller.hpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#pragma once

#include <glm/glm.hpp>

#include "Camera.hpp"

class CameraController {
public:
// Ctor
CameraController(Camera& camera)
: m_camera{camera} {
// This is temporary while the conversion from CameraData to Camera type
// is still not in place.
m_camera.forward = glm::normalize(m_camera.forward - m_camera.position);
}
// Copy
CameraController(const CameraController&) = delete;
CameraController& operator=(const CameraController&) = delete;
// Move
CameraController(CameraController&&) = delete;
CameraController& operator=(CameraController&&) = delete;
// Dtor
~CameraController() = default;
public:
// Ctor
CameraController(Camera& camera) : m_camera{camera} {
// This is temporary while the conversion from CameraData to Camera type
// is still not in place.
m_camera.forward = glm::normalize(m_camera.forward - m_camera.position);
}
// Copy
CameraController(const CameraController&) = delete;
CameraController& operator=(const CameraController&) = delete;
// Move
CameraController(CameraController&&) = delete;
CameraController& operator=(CameraController&&) = delete;
// Dtor
~CameraController() = default;

void update(float delta_time, bool& imgui);
void update(float delta_time, bool& imgui);

private:
static constexpr float normal_speed = 5.f;
static constexpr float sprint_speed = 10.f;
// FIXME: Change ref to something else
Camera& m_camera;
float m_speed = normal_speed;
float m_sensitivity = 1.f;
private:
static constexpr float normal_speed = 5.f;
static constexpr float sprint_speed = 10.f;
// FIXME: Change ref to something else
Camera& m_camera;
float m_speed = normal_speed;
float m_sensitivity = 1.f;
};

glm::vec3 spherical2Cartesian(float theta, float phi, float r);
Expand Down
12 changes: 4 additions & 8 deletions engine/include/curves.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "model.hpp"
#include "utils.hpp"


enum Transformations {TIMEROTATION, TIMETRANSLATE, STATIC};

enum Transformations { TIMEROTATION, TIMETRANSLATE, STATIC };

class TimeRotations {
public:
Expand Down Expand Up @@ -44,10 +42,8 @@ class TimeTranslations {
std::array<float, 16> rotationMatrix(Point x, Point y, Point z);
};


glm::mat4 Scalematrix(float x, float y, float z);
glm::mat4 Rotationmatrix(float angle, float x, float y, float z);
glm::mat4 Translatematrix(float x, float y, float z);

glm::mat4 Scalematrix(float x, float y, float z);
glm::mat4 Rotationmatrix(float angle, float x, float y, float z);
glm::mat4 Translatematrix(float x, float y, float z);

#endif // CURVES_HPP
131 changes: 67 additions & 64 deletions engine/include/frustsum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,84 @@
#define FRUSTSUM_CPP

#include <math.h>
#include <iostream>

#include <glm/glm.hpp>
#include "Window.hpp"
#include "Camera.hpp"
#include <iostream>

#include "Camera.hpp"
#include "Window.hpp"

struct Plane {

glm::vec3 point = { 0.f, 0.f, 0.f };
glm::vec3 normal = { 0.f, 1.f, 0.f };
glm::vec4 abcd = { 0.f, 0.f, 0.f, 0.f };

Plane() = default;
Plane(const Plane& other) = default;
Plane(const glm::vec3& normal, glm::vec3 point);

// rethink distance to point
float distanceToPoint(const glm::vec3& point) const {
return abcd.x * point.x + abcd.y * point.y + abcd.z * point.z + abcd.w;
}


void printPlane() {
std::cout << "Point: " << point.x << " " << point.y << " " << point.z << std::endl;
std::cout << "Normal: " << normal.x << " " << normal.y << " " << normal.z << std::endl;
}


glm::vec3 point = {0.f, 0.f, 0.f};
glm::vec3 normal = {0.f, 1.f, 0.f};
glm::vec4 abcd = {0.f, 0.f, 0.f, 0.f};

Plane() = default;
Plane(const Plane& other) = default;
Plane(const glm::vec3& normal, glm::vec3 point);

// rethink distance to point
float distanceToPoint(const glm::vec3& point) const {
return abcd.x * point.x + abcd.y * point.y + abcd.z * point.z + abcd.w;
}

void printPlane() {
std::cout << "Point: " << point.x << " " << point.y << " " << point.z
<< std::endl;
std::cout << "Normal: " << normal.x << " " << normal.y << " " << normal.z
<< std::endl;
}
};

struct Frustsum {
Plane nearFace;
Plane farFace;
Plane rightFace;
Plane leftFace;
Plane topFace;
Plane bottomFace;
bool on = true;

Frustsum() = default;
Frustsum(const Frustsum& other) = default;
Frustsum(const Plane& nearFace, const Plane& farFace, const Plane& rightFace, const Plane& leftFace, const Plane& topFace, const Plane& bottomFace)
: nearFace(nearFace), farFace(farFace), rightFace(rightFace), leftFace(leftFace), topFace(topFace), bottomFace(bottomFace) {}
Frustsum(const Camera& cam, float ratio, bool on);

void printFrustsum() {
std::cout << "Near" << std::endl;
nearFace.printPlane();
std::cout << "Far" << std::endl;
farFace.printPlane();
std::cout << "right" << std::endl;
rightFace.printPlane();
std::cout << "left" << std::endl;
leftFace.printPlane();
std::cout << "top" << std::endl;
topFace.printPlane();
std::cout << "bottom" << std::endl;
bottomFace.printPlane();
}

Plane nearFace;
Plane farFace;
Plane rightFace;
Plane leftFace;
Plane topFace;
Plane bottomFace;
bool on = true;

Frustsum() = default;
Frustsum(const Frustsum& other) = default;
Frustsum(const Plane& nearFace, const Plane& farFace, const Plane& rightFace,
const Plane& leftFace, const Plane& topFace, const Plane& bottomFace)
: nearFace(nearFace),
farFace(farFace),
rightFace(rightFace),
leftFace(leftFace),
topFace(topFace),
bottomFace(bottomFace) {}
Frustsum(const Camera& cam, float ratio, bool on);

void printFrustsum() {
std::cout << "Near" << std::endl;
nearFace.printPlane();
std::cout << "Far" << std::endl;
farFace.printPlane();
std::cout << "right" << std::endl;
rightFace.printPlane();
std::cout << "left" << std::endl;
leftFace.printPlane();
std::cout << "top" << std::endl;
topFace.printPlane();
std::cout << "bottom" << std::endl;
bottomFace.printPlane();
}
};


struct BoundingSphere {
glm::vec3 center;
float radius;

glm::vec3 center;
float radius;

BoundingSphere() = default;
BoundingSphere(const BoundingSphere& other) = default;
BoundingSphere(const glm::vec3& center, float radius) : center(center), radius(radius) {}
BoundingSphere(std::vector<Vertex> points);

bool isInsideFrustsum(const Frustsum& frustsum, glm::mat4 transformations) const;
BoundingSphere() = default;
BoundingSphere(const BoundingSphere& other) = default;
BoundingSphere(const glm::vec3& center, float radius)
: center(center), radius(radius) {}
BoundingSphere(std::vector<Vertex> points);

bool isInsideFrustsum(const Frustsum& frustsum,
glm::mat4 transformations) const;
};

#endif // FRUSTSUM_CPP
#endif // FRUSTSUM_CPP
8 changes: 4 additions & 4 deletions engine/include/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class Group {
std::vector<Group> subgroups;
std::vector<glm::mat4> static_transformations;


std::vector<TimeRotations> rotations;
std::vector<TimeTranslations> translates;
std::vector<Transformations> order;

Group();
Group(std::vector<Model> models, std::vector<Group> subgroups,
std::vector<glm::mat4> static_transformations, std::vector<TimeRotations> rotations,
std::vector<glm::mat4> static_transformations,
std::vector<TimeRotations> rotations,
std::vector<TimeTranslations> translates,
std::vector<Transformations> order); // Updated constructor

Expand All @@ -34,8 +34,8 @@ class Group {

void rotate(float angle, float x, float y, float z);

void drawGroup(bool lights, const Frustsum& frustsum, bool normals, float elapsed_time, int& nr_models);

void drawGroup(bool lights, const Frustsum& frustsum, bool normals,
float elapsed_time, int& nr_models);
};

#endif // GROUP_HPP
Loading

0 comments on commit 93bd6a0

Please sign in to comment.