Browse Source

Add camera component

master
Riyyi 3 years ago
parent
commit
e884d68ce0
  1. 19
      inferno/src/inferno/scene/components.cpp
  2. 31
      inferno/src/inferno/scene/components.h

19
inferno/src/inferno/scene/components.cpp

@ -0,0 +1,19 @@
#include "inferno/scene/components.h"
namespace Inferno {
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value)
{
stream << "{ " << value.x << ", " << value.y << ", " << value.z << " }";
return stream;
}
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value)
{
stream << "mat4 "
<< value[0] << "\n " << value[1] << "\n "
<< value[2] << "\n " << value[3];
return stream;
}
}

31
inferno/src/inferno/scene/components.h

@ -3,7 +3,10 @@
#include <string> // std::string
#include "glm/ext/vector_float3.hpp" // glm::vec3
#include "glm/ext/matrix_float4x4.hpp" // glm::mat4
#include "glm/ext/vector_float3.hpp" // glm::vec3
#include "inferno/log.h"
namespace Inferno {
@ -18,11 +21,31 @@ namespace Inferno {
};
struct TransformComponent {
glm::vec3 translate = { 0.0f, 0.0f, 0.0f };
glm::vec3 rotate = { 0.0f, 0.0f, 0.0f } ;
glm::vec3 scale = { 1.0f, 1.0f, 1.0f };
glm::vec3 translate { 0.0f, 0.0f, 0.0f };
glm::vec3 rotate { 0.0f, 0.0f, 0.0f } ;
glm::vec3 scale { 1.0f, 1.0f, 1.0f };
glm::mat4 transform { 1.0f }; // Identity matrix
};
struct OrthographicCameraComponment {
float zoomLevel = 1.0f;
glm::vec3 rotateAxis { 0.0f, 0.0f, 1.0f };
glm::mat4 projection { 1.0f }; // Identity matrix
};
struct PerspectiveCameraComponent {
float fov = 90.0f;
float pitch = 0.0f;
float yaw = -90.0f;
glm::vec3 up { 0.0f, 1.0f, 0.0f };
glm::mat4 projection { 1.0f }; // Identity matrix
};
// ----------------------------------------
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value);
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value);
}
#endif // COMPONENTS_H

Loading…
Cancel
Save