1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-12-22 01:26:17 +01:00

makeRotationMatrix -> makeRotationMatrixZXY

This commit is contained in:
Miloslav Číž 2019-05-20 15:01:00 +02:00
parent c9db9ae0d7
commit f3b2a0fa39
2 changed files with 20 additions and 11 deletions

13
s3l.h
View file

@ -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,

View file

@ -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);