"Improved" Dolphin matricies slightly
This commit is contained in:
+17
-17
@@ -130,24 +130,24 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
||||
entityCameraSetZFar(cam, camCam, 100.0f);
|
||||
|
||||
// Floor
|
||||
// entityid_t floorEnt = entityManagerAdd();
|
||||
// componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION);
|
||||
// componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH);
|
||||
// componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL);
|
||||
// componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS);
|
||||
entityid_t floorEnt = entityManagerAdd();
|
||||
componentid_t floorPos = entityAddComponent(floorEnt, COMPONENT_TYPE_POSITION);
|
||||
componentid_t floorMesh = entityAddComponent(floorEnt, COMPONENT_TYPE_MESH);
|
||||
componentid_t floorMat = entityAddComponent(floorEnt, COMPONENT_TYPE_MATERIAL);
|
||||
componentid_t floorPhys = entityAddComponent(floorEnt, COMPONENT_TYPE_PHYSICS);
|
||||
|
||||
// entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f });
|
||||
// entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f });
|
||||
// entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE);
|
||||
// entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN;
|
||||
entityPositionSetPosition(floorEnt, floorPos, (vec3){ -5.0f, 0.0f, -5.0f });
|
||||
entityPositionSetScale(floorEnt, floorPos, (vec3){ 10.0f, 1.0f, 10.0f });
|
||||
entityMeshSetMesh(floorEnt, floorMesh, &PLANE_MESH_SIMPLE);
|
||||
entityMaterialGetShaderMaterial(floorEnt, floorMat)->unlit.color = COLOR_GREEN;
|
||||
|
||||
// entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys);
|
||||
// floorPhysData->type = PHYSICS_BODY_STATIC;
|
||||
// floorPhysData->shape.type = PHYSICS_SHAPE_PLANE;
|
||||
// floorPhysData->shape.data.plane.normal[0] = 0.0f;
|
||||
// floorPhysData->shape.data.plane.normal[1] = 1.0f;
|
||||
// floorPhysData->shape.data.plane.normal[2] = 0.0f;
|
||||
// floorPhysData->shape.data.plane.distance = 0.0f;
|
||||
entityphysics_t *floorPhysData = entityPhysicsGet(floorEnt, floorPhys);
|
||||
floorPhysData->type = PHYSICS_BODY_STATIC;
|
||||
floorPhysData->shape.type = PHYSICS_SHAPE_PLANE;
|
||||
floorPhysData->shape.data.plane.normal[0] = 0.0f;
|
||||
floorPhysData->shape.data.plane.normal[1] = 1.0f;
|
||||
floorPhysData->shape.data.plane.normal[2] = 0.0f;
|
||||
floorPhysData->shape.data.plane.distance = 0.0f;
|
||||
|
||||
// Box
|
||||
phBoxEnt = entityManagerAdd();
|
||||
@@ -158,7 +158,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
||||
|
||||
entityMeshSetMesh(phBoxEnt, boxMesh, &CUBE_MESH_SIMPLE);
|
||||
entityMaterialGetShaderMaterial(phBoxEnt, boxMat)->unlit.color = COLOR_RED;
|
||||
entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 0.0f, 0.0f });
|
||||
entityPositionSetPosition(phBoxEnt, boxPos, (vec3){ 0.0f, 1.0f, 0.0f });
|
||||
|
||||
/* Run the init script. */
|
||||
scriptcontext_t ctx;
|
||||
|
||||
@@ -228,13 +228,14 @@ errorret_t shaderUpdateMVPDolphin() {
|
||||
|
||||
// Set Model/View Matrix
|
||||
if(mvDirt) {
|
||||
// guMtxConcat(
|
||||
// SHADER_BOUND->matrixView,
|
||||
// SHADER_BOUND->matrixModel,
|
||||
// SHADER_BOUND->matrixModelView
|
||||
// );
|
||||
// GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0);
|
||||
GX_LoadPosMtxImm(SHADER_BOUND->matrixView, GX_PNMTX0);
|
||||
guMtxIdentity(SHADER_BOUND->matrixModel);
|
||||
guMtxTransApply(SHADER_BOUND->matrixModel, SHADER_BOUND->matrixModel, 0.0F, 1.0F, 0.0F);
|
||||
guMtxConcat(
|
||||
SHADER_BOUND->matrixModel,
|
||||
SHADER_BOUND->matrixView,
|
||||
SHADER_BOUND->matrixModelView
|
||||
);
|
||||
GX_LoadPosMtxImm(SHADER_BOUND->matrixModelView, GX_PNMTX0);
|
||||
}
|
||||
|
||||
SHADER_BOUND->dirtyMatrix = 0;
|
||||
@@ -256,7 +257,9 @@ void shaderMat4ToMtx(const mat4 inGlmMatrix, Mtx outGXMatrix) {
|
||||
assertNotNull(inGlmMatrix, "Input matrix cannot be null");
|
||||
assertNotNull(outGXMatrix, "Output matrix cannot be null");
|
||||
|
||||
for(int row = 0; row < 4; ++row) {// Can perhaps be 3.
|
||||
guMtxIdentity(outGXMatrix);
|
||||
|
||||
for(int row = 0; row < 3; ++row) {
|
||||
for(int col = 0; col < 4; ++col) {
|
||||
outGXMatrix[row][col] = inGlmMatrix[col][row];
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ typedef struct shaderdolphin_s {
|
||||
mat4 model;
|
||||
|
||||
bool_t isProjectionPerspective;
|
||||
Mtx44 matrixProjection;
|
||||
Mtx matrixView;
|
||||
Mtx matrixModel;
|
||||
Mtx matrixModelView;
|
||||
alignas(32) Mtx44 matrixProjection;
|
||||
alignas(32) Mtx matrixView;
|
||||
alignas(32) Mtx matrixModel;
|
||||
alignas(32) Mtx matrixModelView;
|
||||
|
||||
uint_fast8_t dirtyMatrix;
|
||||
} shaderdolphin_t;
|
||||
|
||||
Reference in New Issue
Block a user