Moving projection to viewport
This commit is contained in:
@@ -8,12 +8,8 @@ using namespace Seele::Component;
|
||||
using namespace Seele::Math;
|
||||
|
||||
Camera::Camera()
|
||||
: aspectRatio(0)
|
||||
, fieldOfView(glm::radians(70.f))
|
||||
, bNeedsViewBuild(false)
|
||||
, bNeedsProjectionBuild(false)
|
||||
: bNeedsViewBuild(false)
|
||||
, viewMatrix(Matrix4())
|
||||
, projectionMatrix(Matrix4())
|
||||
{
|
||||
yaw = 0;
|
||||
pitch = 0;
|
||||
@@ -54,14 +50,6 @@ void Camera::moveY(float amount)
|
||||
bNeedsViewBuild = true;
|
||||
}
|
||||
|
||||
void Camera::setViewport(Gfx::PViewport newViewport)
|
||||
{
|
||||
viewport = newViewport;
|
||||
aspectRatio = viewport->getSizeX() / (float)viewport->getSizeY();
|
||||
|
||||
bNeedsProjectionBuild = true;
|
||||
}
|
||||
|
||||
void Camera::buildViewMatrix()
|
||||
{
|
||||
Vector eyePos = getTransform().getPosition();//getAbsoluteTransform().getPosition();
|
||||
@@ -71,18 +59,3 @@ void Camera::buildViewMatrix()
|
||||
|
||||
bNeedsViewBuild = false;
|
||||
}
|
||||
|
||||
void Camera::buildProjectionMatrix()
|
||||
{
|
||||
projectionMatrix = glm::perspective(fieldOfView, aspectRatio, 1.0f, 1000.f);
|
||||
static Matrix4 correctionMatrix =
|
||||
Matrix4(
|
||||
Vector4(1, 0, 0, 0),
|
||||
Vector4(0, 1, 0, 0),
|
||||
Vector4(0, 0, 0.5f, 0),
|
||||
Vector4(0, 0, 0.5f, 1));
|
||||
projectionMatrix = correctionMatrix * projectionMatrix;
|
||||
bNeedsProjectionBuild = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,11 +20,6 @@ struct Camera
|
||||
assert (!bNeedsViewBuild);
|
||||
return viewMatrix;
|
||||
}
|
||||
Math::Matrix4 getProjectionMatrix() const
|
||||
{
|
||||
assert (!bNeedsProjectionBuild);
|
||||
return projectionMatrix;
|
||||
}
|
||||
Math::Vector getCameraPosition() const
|
||||
{
|
||||
return Math::Vector(viewMatrix[3]);
|
||||
@@ -34,21 +29,13 @@ struct Camera
|
||||
void mouseScroll(float x);
|
||||
void moveX(float amount);
|
||||
void moveY(float amount);
|
||||
float aspectRatio;
|
||||
float fieldOfView;
|
||||
void buildViewMatrix();
|
||||
void buildProjectionMatrix();
|
||||
Math::Matrix4 viewMatrix;
|
||||
Math::Matrix4 projectionMatrix;
|
||||
//Transforms relative to actor
|
||||
float yaw;
|
||||
float pitch;
|
||||
private:
|
||||
bool bNeedsViewBuild;
|
||||
bool bNeedsProjectionBuild;
|
||||
|
||||
Gfx::PViewport viewport;
|
||||
|
||||
};
|
||||
} // namespace Component
|
||||
} // namespace Seele
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "Graphics/GraphicsResources.h"
|
||||
#include "Asset/MeshAsset.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
@@ -7,9 +7,7 @@ namespace Component
|
||||
{
|
||||
struct StaticMesh
|
||||
{
|
||||
PVertexShaderInput vertexBuffer;
|
||||
Gfx::PIndexBuffer indexBuffer;
|
||||
PMaterialAsset material;
|
||||
PMeshAsset mesh;
|
||||
};
|
||||
} // namespace Component
|
||||
} // namespace Seele
|
||||
|
||||
Reference in New Issue
Block a user