added 3d plotting

This commit is contained in:
Lauchmelder 2021-12-22 15:45:52 +01:00
parent 5f0e8f9c6e
commit 918f51dc14
16 changed files with 301 additions and 248 deletions

View file

@ -0,0 +1,15 @@
#pragma once
struct Rect
{
float x, y;
float w, h;
};
struct BoundingBox
{
float x, y, z;
float w, h, d;
};
typedef BoundingBox BBox;

View file

@ -13,6 +13,11 @@ public:
void SetScale(const glm::vec3&) = delete;
void Scale(const glm::vec3&) = delete;
inline void LookAt(const glm::vec3& target)
{
transformation = glm::lookAt(position, target, glm::vec3(0.0f, 1.0f, 0.0f));
}
inline const glm::mat4& GetView() const
{
return transformation;
@ -40,6 +45,11 @@ public:
{
projection = glm::perspective(glm::radians(fov), aspect, zNear, zFar);
}
inline void Update(float fov, float aspect, float zNear, float zFar)
{
projection = glm::perspective(glm::radians(fov), aspect, zNear, zFar);
}
};
class OrthogonalCamera : public CameraBase
@ -49,4 +59,9 @@ public:
{
projection = glm::ortho(left, right, bottom, top, zNear, zFar);
}
inline void Update(float left, float right, float bottom, float top, float zNear, float zFar)
{
projection = glm::ortho(left, right, bottom, top, zNear, zFar);
}
};

View file

@ -23,7 +23,7 @@ public:
Drawable(const Drawable& other) = delete;
void operator=(const Drawable& other) = delete;
virtual void InitializeShader(const CameraBase& camera) const = 0;
virtual void PreRender(const CameraBase& camera) const { };
void Draw(const CameraBase& camera) const;
void SetPrimitiveType(PrimitiveType type);