|
@@ -150,7 +150,7 @@ void update()
|
|
uint32_t i, j;
|
|
uint32_t i, j;
|
|
uint32_t faceCount;
|
|
uint32_t faceCount;
|
|
uint32_t timeToWait = FRAME_TARGET_TIME - (SDL_GetTicks() - previousFrameTime);
|
|
uint32_t timeToWait = FRAME_TARGET_TIME - (SDL_GetTicks() - previousFrameTime);
|
|
- matrix4_t scaleMatrix, translateMatrix, rotationXMatrix, rotationYMatrix, rotationZMatrix;
|
|
|
|
|
|
+ matrix4_t worldMatrix;
|
|
if (timeToWait <= FRAME_TARGET_TIME)
|
|
if (timeToWait <= FRAME_TARGET_TIME)
|
|
{
|
|
{
|
|
SDL_Delay(timeToWait);
|
|
SDL_Delay(timeToWait);
|
|
@@ -167,11 +167,13 @@ void update()
|
|
mesh.translation.x += 0.01;
|
|
mesh.translation.x += 0.01;
|
|
mesh.translation.z = 5;
|
|
mesh.translation.z = 5;
|
|
|
|
|
|
- scaleMatrix = mat4Scale(mesh.scale.x, mesh.scale.y, mesh.scale.z);
|
|
|
|
- rotationXMatrix = mat4RotationX(mesh.rotation.x);
|
|
|
|
- rotationYMatrix = mat4RotationY(mesh.rotation.y);
|
|
|
|
- rotationZMatrix = mat4RotationZ(mesh.rotation.z);
|
|
|
|
- translateMatrix = mat4Translate(mesh.translation.x, mesh.translation.y, mesh.translation.z);
|
|
|
|
|
|
+ worldMatrix = mat4Identity;
|
|
|
|
+
|
|
|
|
+ worldMatrix = mat4ProdMat4(mat4Scale(mesh.scale.x, mesh.scale.y, mesh.scale.z), worldMatrix);
|
|
|
|
+ worldMatrix = mat4ProdMat4(mat4RotationZ(mesh.rotation.z), worldMatrix);
|
|
|
|
+ worldMatrix = mat4ProdMat4(mat4RotationY(mesh.rotation.y), worldMatrix);
|
|
|
|
+ worldMatrix = mat4ProdMat4(mat4RotationX(mesh.rotation.x), worldMatrix);
|
|
|
|
+ worldMatrix = mat4ProdMat4(mat4Translate(mesh.translation.x, mesh.translation.y, mesh.translation.z), worldMatrix);
|
|
|
|
|
|
arrayEmpty(projectedTriangles);
|
|
arrayEmpty(projectedTriangles);
|
|
|
|
|
|
@@ -192,12 +194,7 @@ void update()
|
|
{
|
|
{
|
|
transformedVertices[j] = vec4FromVec3(vertices[j]);
|
|
transformedVertices[j] = vec4FromVec3(vertices[j]);
|
|
|
|
|
|
- transformedVertices[j] = mat4ProdVec4(rotationXMatrix, transformedVertices[j]);
|
|
|
|
- transformedVertices[j] = mat4ProdVec4(rotationYMatrix, transformedVertices[j]);
|
|
|
|
- transformedVertices[j] = mat4ProdVec4(rotationZMatrix, transformedVertices[j]);
|
|
|
|
-
|
|
|
|
- transformedVertices[j] = mat4ProdVec4(scaleMatrix, transformedVertices[j]);
|
|
|
|
- transformedVertices[j] = mat4ProdVec4(translateMatrix, transformedVertices[j]);
|
|
|
|
|
|
+ transformedVertices[j] = mat4ProdVec4(worldMatrix, transformedVertices[j]);
|
|
}
|
|
}
|
|
|
|
|
|
if (!doNotCull)
|
|
if (!doNotCull)
|