2022-01-11 10:41:18 +08:00
|
|
|
|
#ifndef HGL_GRAPH_SCENE_INFO_INCLUDE
|
2021-05-24 20:44:20 +08:00
|
|
|
|
#define HGL_GRAPH_SCENE_INFO_INCLUDE
|
2021-04-26 20:36:56 +08:00
|
|
|
|
|
|
|
|
|
#include<hgl/math/Matrix.h>
|
|
|
|
|
#include<hgl/CompOperator.h>
|
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
/**
|
2022-01-11 10:41:18 +08:00
|
|
|
|
* MVP矩阵
|
2021-04-26 20:36:56 +08:00
|
|
|
|
*/
|
|
|
|
|
struct MVPMatrix
|
|
|
|
|
{
|
2022-01-18 12:10:02 +08:00
|
|
|
|
Matrix4f model; ///< model: Local to World
|
|
|
|
|
//Matrix4f normal; ///<transpose(inverse(mat3(model)));
|
2022-01-11 10:41:18 +08:00
|
|
|
|
Matrix3x4f normal; ///<这里用3x4,在Shader中是3x3(但实际它是3x4保存)
|
2021-04-26 20:36:56 +08:00
|
|
|
|
|
2022-01-18 12:10:02 +08:00
|
|
|
|
Matrix4f mv; ///< view * model
|
|
|
|
|
Matrix4f mvp; ///< projection * view * model
|
2021-04-26 20:36:56 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-01-18 12:10:02 +08:00
|
|
|
|
void Set(const Matrix4f &local_to_world,const Matrix4f &view_projection,const Matrix4f &view)
|
2021-04-26 20:36:56 +08:00
|
|
|
|
{
|
2022-01-18 12:10:02 +08:00
|
|
|
|
model =local_to_world;
|
|
|
|
|
normal =transpose(inverse(model));
|
|
|
|
|
mv =view*model;
|
|
|
|
|
mvp =view_projection*model;
|
2021-04-26 20:36:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompOperatorMemcmp(const MVPMatrix &);
|
|
|
|
|
};//struct MVPMatrix
|
2021-06-22 21:33:47 +08:00
|
|
|
|
|
|
|
|
|
constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix);
|
2021-04-26 20:36:56 +08:00
|
|
|
|
}//namespace graph
|
2021-04-30 18:56:20 +08:00
|
|
|
|
}//namespace hgl
|
2021-05-24 20:44:20 +08:00
|
|
|
|
#endif//HGL_GRAPH_SCENE_INFO_INCLUDE
|