updated MVPMatrix struct

This commit is contained in:
2022-01-11 10:41:18 +08:00
parent 92770495a7
commit b7714d8a83
3 changed files with 10 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
#ifndef HGL_GRAPH_SCENE_INFO_INCLUDE
#ifndef HGL_GRAPH_SCENE_INFO_INCLUDE
#define HGL_GRAPH_SCENE_INFO_INCLUDE
#include<hgl/math/Matrix.h>
@@ -8,25 +8,25 @@ namespace hgl
namespace graph
{
/**
* MVP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* MVP矩阵
*/
struct MVPMatrix
{
Matrix4f l2w; ///< Local to World
Matrix4f inverse_l2w;
//Matrix4f normal; ///<transpose(inverse(mat3(l2w)));
Matrix3x4f normal; ///<这里用3x4在Shader中是3x3(但实际它是3x4保存)
Matrix4f mv; ///< view * local_to_world
Matrix4f mvp; ///< projection * view * local_to_world
Matrix4f inverse_mvp;
public:
void Set(const Matrix4f &w,const Matrix4f &vp)
void Set(const Matrix4f &w,const Matrix4f &vp,const Matrix4f &v)
{
l2w=w;
inverse_l2w=inverse(l2w);
normal=transpose(inverse(l2w));
mv=v*l2w;
mvp=vp*l2w;
inverse_mvp=inverse(mvp);
}
CompOperatorMemcmp(const MVPMatrix &);