diff --git a/s3l.h b/s3l.h index c9ebac0..580461d 100644 --- a/s3l.h +++ b/s3l.h @@ -293,9 +293,8 @@ void S3L_makeScaleMatrix( S3L_Unit scaleZ, S3L_Mat4 *m); -/** Makes a rotation matrix. For the rotation conventions (meaning, order, - units) see the specific structure comments. */ -void S3L_makeRotationMatrix( +/** Makes a matrixfor rotation in the ZXY order. */ +void S3L_makeRotationMatrixZXY( S3L_Unit aroundX, S3L_Unit aroundY, S3L_Unit aroundZ, @@ -709,7 +708,7 @@ void S3L_makeScaleMatrix( #undef M } -void S3L_makeRotationMatrix( +void S3L_makeRotationMatrixZXY( S3L_Unit aroundX, S3L_Unit aroundY, S3L_Unit aroundZ, @@ -774,7 +773,7 @@ void S3L_rotationToDirections( { S3L_Mat4 m; - S3L_makeRotationMatrix(-1 * rotation.x,-1 * rotation.y,-1 * rotation.z,&m); + S3L_makeRotationMatrixZXY(-1 * rotation.x,-1 * rotation.y,-1 * rotation.z,&m); if (forw != 0) { @@ -1496,7 +1495,7 @@ void S3L_makeWorldMatrix(S3L_Transform3D worldTransform, S3L_Mat4 *m) S3L_Mat4 t; - S3L_makeRotationMatrix( + S3L_makeRotationMatrixZXY( worldTransform.rotation.x, worldTransform.rotation.y, worldTransform.rotation.z, @@ -1523,7 +1522,7 @@ void S3L_makeCameraMatrix(S3L_Transform3D cameraTransform, S3L_Mat4 *m) S3L_Mat4 r; - S3L_makeRotationMatrix( + S3L_makeRotationMatrixZXY( cameraTransform.rotation.x, cameraTransform.rotation.y, cameraTransform.rotation.z, diff --git a/testSDL.c b/testSDL.c index a9dfcb8..939eddc 100644 --- a/testSDL.c +++ b/testSDL.c @@ -153,6 +153,10 @@ void draw() S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf); + modelTransform.translation.x += 2 * S3L_FRACTIONS_PER_UNIT; + S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf); + modelTransform.translation.x -= 2 * S3L_FRACTIONS_PER_UNIT; + if (offScreenPixels > 0) printf("offscreen pixels: %d\n",offScreenPixels); @@ -270,11 +274,11 @@ int main() if (keys['a']) S3L_vec3Sub(&camera.transform.translation,camR); - if (keys['x']) - camera.transform.translation.y += 10; - if (keys['c']) - camera.transform.translation.y -= 10; + S3L_vec3Add(&camera.transform.translation,camU); + + if (keys['x']) + S3L_vec3Sub(&camera.transform.translation,camU); if (keys['q']) camera.transform.rotation.y -= 1; @@ -288,6 +292,12 @@ int main() if (keys['t']) camera.transform.rotation.x += 1; + if (keys['f']) + camera.transform.rotation.z -= 1; + + if (keys['g']) + camera.transform.rotation.z += 1; + SDL_RenderClear(renderer); SDL_RenderCopy(renderer,texture,NULL,NULL); SDL_RenderPresent(renderer);