Removed dependencies on GLM
This commit is contained in:
parent
cd8f4147c2
commit
e138cd7035
|
@ -74,7 +74,6 @@ LIBS += -L$$EXTERNALS_DIR/glew-2.0.0/lib/Release/x64 -lglew32s \
|
|||
INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||
$$EXTERNALS_DIR/assimp/include \
|
||||
$$EXTERNALS_DIR/glew-2.0.0/include \
|
||||
$$EXTERNALS_DIR/glm/glm \
|
||||
$$EXTERNALS_DIR/lzo-2.09/include \
|
||||
$$EXTERNALS_DIR/nodtool/include \
|
||||
$$EXTERNALS_DIR/nodtool/logvisor/include \
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "CGraphics.h"
|
||||
#include <Math/CQuaternion.h>
|
||||
#include <Math/MathUtil.h>
|
||||
#include <gtc/matrix_transform.hpp>
|
||||
|
||||
CCamera::CCamera()
|
||||
: mMode(eFreeCamera)
|
||||
|
@ -243,15 +242,17 @@ void CCamera::UpdateTransform() const
|
|||
|
||||
void CCamera::UpdateView() const
|
||||
{
|
||||
// todo: don't use glm
|
||||
UpdateTransform();
|
||||
|
||||
if (mViewDirty)
|
||||
{
|
||||
glm::vec3 glmpos(mPosition.X, mPosition.Y, mPosition.Z);
|
||||
glm::vec3 glmdir(mDirection.X, mDirection.Y, mDirection.Z);
|
||||
glm::vec3 glmup(mUpVector.X, mUpVector.Y, mUpVector.Z);
|
||||
mViewMatrix = CMatrix4f::FromGlmMat4(glm::lookAt(glmpos, glmpos + glmdir, glmup)).Transpose();
|
||||
mViewMatrix = CMatrix4f(
|
||||
mRightVector.X, mRightVector.Y, mRightVector.Z, -mRightVector.Dot(mPosition),
|
||||
mUpVector.X, mUpVector.Y, mUpVector.Z, -mUpVector.Dot(mPosition),
|
||||
-mDirection.X, -mDirection.Y, -mDirection.Z, mDirection.Dot(mPosition),
|
||||
0.f, 0.f, 0.f, 1.f
|
||||
);
|
||||
|
||||
mViewDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <gtx/transform.hpp>
|
||||
|
||||
// ************ STATIC MEMBER INITIALIZATION ************
|
||||
u32 CRenderer::sNumRenderers = 0;
|
||||
|
|
|
@ -101,9 +101,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
|
|||
case eInverseMV: // Mode 0
|
||||
case eSimpleMode: // Mode 10 - maybe not correct?
|
||||
{
|
||||
glm::mat4 InvMV = glm::inverse(glm::transpose(ViewMtx.ToGlmMat4()) * glm::transpose(ModelMtx.ToGlmMat4()));
|
||||
InvMV[0][3] = InvMV[1][3] = InvMV[2][3] = 0.f;
|
||||
TexMtx = CMatrix4f::FromGlmMat4(InvMV);
|
||||
TexMtx = (ModelMtx * ViewMtx).Transpose().Inverse();
|
||||
PostMtx = CMatrix4f(0.5f, 0.0f, 0.0f, 0.5f,
|
||||
0.0f, 0.5f, 0.0f, 0.5f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
|
@ -113,8 +111,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
|
|||
|
||||
case eInverseMVTranslated: // Mode 1
|
||||
{
|
||||
glm::mat4 InvMV = glm::inverse(glm::transpose(ViewMtx.ToGlmMat4()) * glm::transpose(ModelMtx.ToGlmMat4()));
|
||||
TexMtx = CMatrix4f::FromGlmMat4(InvMV);
|
||||
TexMtx = (ModelMtx * ViewMtx).Transpose().Inverse();
|
||||
PostMtx = CMatrix4f(0.5f, 0.0f, 0.0f, 0.5f,
|
||||
0.0f, 0.5f, 0.0f, 0.5f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
|
@ -166,7 +163,7 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
|
|||
case eModelMatrix: // Mode 6
|
||||
{
|
||||
// It looks ok, but I can't tell whether it's correct...
|
||||
TexMtx = CMatrix4f::FromGlmMat4(glm::transpose(ModelMtx.ToGlmMat4()));
|
||||
TexMtx = ModelMtx.Transpose();
|
||||
PostMtx = CMatrix4f(0.5f, 0.0f, 0.0f, TexMtx[0][3] * 0.50000001f,
|
||||
0.0f, 0.5f, 0.0f, TexMtx[1][3] * 0.50000001f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
|
@ -180,9 +177,8 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
|
|||
{
|
||||
CMatrix4f View = CGraphics::sMVPBlock.ViewMatrix;
|
||||
|
||||
glm::mat4 Mtx = glm::inverse(glm::transpose(ViewMtx.ToGlmMat4()) * glm::transpose(ModelMtx.ToGlmMat4()));
|
||||
Mtx[0][3] = Mtx[1][3] = Mtx[2][3] = 0.f;
|
||||
TexMtx = CMatrix4f::FromGlmMat4(Mtx);
|
||||
TexMtx = (ModelMtx * ViewMtx).Transpose().Inverse();
|
||||
TexMtx[0][3] = TexMtx[1][3] = TexMtx[2][3] = 0.f;
|
||||
|
||||
float XY = (View[3][0] + View[3][1]) * 0.025f * mAnimParams[1];
|
||||
XY = (XY - (int) XY);
|
||||
|
|
|
@ -86,7 +86,6 @@ LIBS += -L$$EXTERNALS_DIR/glew-2.0.0/lib/Release/x64 -lglew32s \
|
|||
INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||
$$EXTERNALS_DIR/assimp/include \
|
||||
$$EXTERNALS_DIR/glew-2.0.0/include \
|
||||
$$EXTERNALS_DIR/glm/glm \
|
||||
$$EXTERNALS_DIR/lzo-2.09/include \
|
||||
$$EXTERNALS_DIR/nodtool/include \
|
||||
$$EXTERNALS_DIR/nodtool/logvisor/include \
|
||||
|
|
|
@ -138,21 +138,6 @@ float CMatrix4f::Determinant() const
|
|||
return (A - B + C - D);
|
||||
}
|
||||
|
||||
glm::mat4 CMatrix4f::ToGlmMat4() const
|
||||
{
|
||||
glm::mat4 Out = glm::mat4(1);
|
||||
memcpy(&Out[0][0], &m[0][0], sizeof(glm::mat4));
|
||||
return Out;
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CMatrix4f CMatrix4f::FromGlmMat4(const glm::mat4& rkSrc)
|
||||
{
|
||||
CMatrix4f Out;
|
||||
memcpy(&Out[0][0], &rkSrc[0][0], sizeof(CMatrix4f));
|
||||
return Out;
|
||||
}
|
||||
|
||||
// ************ OPERATORS ************
|
||||
inline float* CMatrix4f::operator[](long Index)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef CMATRIX4_H
|
||||
#define CMATRIX4_H
|
||||
|
||||
#include <glm.hpp>
|
||||
|
||||
class CQuaternion;
|
||||
class CVector3f;
|
||||
class CVector4f;
|
||||
|
@ -30,12 +28,6 @@ public:
|
|||
CMatrix4f Inverse() const;
|
||||
float Determinant() const;
|
||||
|
||||
// Conversion
|
||||
glm::mat4 ToGlmMat4() const;
|
||||
|
||||
// Static
|
||||
static CMatrix4f FromGlmMat4(const glm::mat4& rkSrc);
|
||||
|
||||
// Operators
|
||||
inline float* operator[](long Index);
|
||||
inline const float* operator[](long Index) const;
|
||||
|
|
|
@ -323,19 +323,6 @@ CTransform4f CTransform4f::ScaleMatrix(CVector3f Scale)
|
|||
return Out;
|
||||
}
|
||||
|
||||
CTransform4f CTransform4f::FromGlmMat4(const glm::mat4& rkMtx)
|
||||
{
|
||||
CTransform4f Out;
|
||||
for (int iRow = 0; iRow < 3; iRow++)
|
||||
for (int iCol = 0; iCol < 4; iCol++)
|
||||
Out[iRow][iCol] = rkMtx[iRow][iCol];
|
||||
return Out;
|
||||
}
|
||||
|
||||
static CTransform4f FromGlmMat4(const glm::mat4&)
|
||||
{
|
||||
}
|
||||
|
||||
// ************ CONSTANTS ************
|
||||
const CTransform4f CTransform4f::skIdentity(1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <FileIO/FileIO.h>
|
||||
#include <Common/Serialization/IArchive.h>
|
||||
#include "CMatrix4f.h"
|
||||
#include <glm.hpp>
|
||||
|
||||
class CVector3f;
|
||||
class CVector4f;
|
||||
|
@ -48,7 +47,6 @@ public:
|
|||
static CTransform4f TranslationMatrix(CVector3f Translation);
|
||||
static CTransform4f RotationMatrix(CQuaternion Rotation);
|
||||
static CTransform4f ScaleMatrix(CVector3f Scale);
|
||||
static CTransform4f FromGlmMat4(const glm::mat4& rkMtx);
|
||||
|
||||
// Operators
|
||||
float* operator[](long Index);
|
||||
|
|
|
@ -57,7 +57,6 @@ CONFIG (release, debug|release) {
|
|||
|
||||
# Include Paths
|
||||
INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||
$$EXTERNALS_DIR/glm/glm \
|
||||
$$EXTERNALS_DIR/lzo-2.09/include \
|
||||
$$EXTERNALS_DIR/tinyxml2/include \
|
||||
$$EXTERNALS_DIR/zlib/include
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "MathUtil.h"
|
||||
#include "CMatrix4f.h"
|
||||
#include <gtc/matrix_transform.hpp>
|
||||
|
||||
namespace Math
|
||||
{
|
||||
|
@ -367,13 +366,22 @@ std::pair<bool,float> RayTriangleIntersection(const CRay& rkRay,
|
|||
|
||||
CMatrix4f PerspectiveMatrix(float FOV, float Aspect, float Near, float Far)
|
||||
{
|
||||
// todo: don't use glm
|
||||
return CMatrix4f::FromGlmMat4(glm::perspective(FOV, Aspect, Near, Far)).Transpose();
|
||||
float TanHalfFOV = tanf( DegreesToRadians(FOV) / 2.f );
|
||||
return CMatrix4f(
|
||||
1.f / (Aspect * TanHalfFOV), 0, 0, 0,
|
||||
0, 1.f / TanHalfFOV, 0, 0,
|
||||
0, 0, -(Far+Near)/(Far-Near), (-2.f*Far*Near)/(Far-Near),
|
||||
0, 0, -1, 0
|
||||
);
|
||||
}
|
||||
|
||||
CMatrix4f OrthographicMatrix(float Left, float Right, float Bottom, float Top, float Near, float Far)
|
||||
{
|
||||
return CMatrix4f::FromGlmMat4(glm::ortho(Left, Right, Bottom, Top, Near, Far)).Transpose();
|
||||
return CMatrix4f (
|
||||
2/(Right-Left), 0, 0, -(Right+Left)/(Right-Left),
|
||||
0, 2/(Top-Bottom), 0, -(Top+Bottom)/(Top-Bottom),
|
||||
0, 0, -2/(Far-Near), -(Far+Near)/(Far-Near),
|
||||
0, 0, 0, 1);
|
||||
}
|
||||
|
||||
} // End namespace
|
||||
|
|
Loading…
Reference in New Issue