mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-21 20:39:57 +01:00
makeRotationMatrix -> makeRotationMatrixZXY
This commit is contained in:
parent
c9db9ae0d7
commit
f3b2a0fa39
2 changed files with 20 additions and 11 deletions
13
s3l.h
13
s3l.h
|
@ -293,9 +293,8 @@ void S3L_makeScaleMatrix(
|
||||||
S3L_Unit scaleZ,
|
S3L_Unit scaleZ,
|
||||||
S3L_Mat4 *m);
|
S3L_Mat4 *m);
|
||||||
|
|
||||||
/** Makes a rotation matrix. For the rotation conventions (meaning, order,
|
/** Makes a matrixfor rotation in the ZXY order. */
|
||||||
units) see the specific structure comments. */
|
void S3L_makeRotationMatrixZXY(
|
||||||
void S3L_makeRotationMatrix(
|
|
||||||
S3L_Unit aroundX,
|
S3L_Unit aroundX,
|
||||||
S3L_Unit aroundY,
|
S3L_Unit aroundY,
|
||||||
S3L_Unit aroundZ,
|
S3L_Unit aroundZ,
|
||||||
|
@ -709,7 +708,7 @@ void S3L_makeScaleMatrix(
|
||||||
#undef M
|
#undef M
|
||||||
}
|
}
|
||||||
|
|
||||||
void S3L_makeRotationMatrix(
|
void S3L_makeRotationMatrixZXY(
|
||||||
S3L_Unit aroundX,
|
S3L_Unit aroundX,
|
||||||
S3L_Unit aroundY,
|
S3L_Unit aroundY,
|
||||||
S3L_Unit aroundZ,
|
S3L_Unit aroundZ,
|
||||||
|
@ -774,7 +773,7 @@ void S3L_rotationToDirections(
|
||||||
{
|
{
|
||||||
S3L_Mat4 m;
|
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)
|
if (forw != 0)
|
||||||
{
|
{
|
||||||
|
@ -1496,7 +1495,7 @@ void S3L_makeWorldMatrix(S3L_Transform3D worldTransform, S3L_Mat4 *m)
|
||||||
|
|
||||||
S3L_Mat4 t;
|
S3L_Mat4 t;
|
||||||
|
|
||||||
S3L_makeRotationMatrix(
|
S3L_makeRotationMatrixZXY(
|
||||||
worldTransform.rotation.x,
|
worldTransform.rotation.x,
|
||||||
worldTransform.rotation.y,
|
worldTransform.rotation.y,
|
||||||
worldTransform.rotation.z,
|
worldTransform.rotation.z,
|
||||||
|
@ -1523,7 +1522,7 @@ void S3L_makeCameraMatrix(S3L_Transform3D cameraTransform, S3L_Mat4 *m)
|
||||||
|
|
||||||
S3L_Mat4 r;
|
S3L_Mat4 r;
|
||||||
|
|
||||||
S3L_makeRotationMatrix(
|
S3L_makeRotationMatrixZXY(
|
||||||
cameraTransform.rotation.x,
|
cameraTransform.rotation.x,
|
||||||
cameraTransform.rotation.y,
|
cameraTransform.rotation.y,
|
||||||
cameraTransform.rotation.z,
|
cameraTransform.rotation.z,
|
||||||
|
|
18
testSDL.c
18
testSDL.c
|
@ -153,6 +153,10 @@ void draw()
|
||||||
|
|
||||||
S3L_drawModelIndexed(ver,tri,12,modelTransform,&camera,&conf);
|
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)
|
if (offScreenPixels > 0)
|
||||||
printf("offscreen pixels: %d\n",offScreenPixels);
|
printf("offscreen pixels: %d\n",offScreenPixels);
|
||||||
|
|
||||||
|
@ -270,11 +274,11 @@ int main()
|
||||||
if (keys['a'])
|
if (keys['a'])
|
||||||
S3L_vec3Sub(&camera.transform.translation,camR);
|
S3L_vec3Sub(&camera.transform.translation,camR);
|
||||||
|
|
||||||
if (keys['x'])
|
|
||||||
camera.transform.translation.y += 10;
|
|
||||||
|
|
||||||
if (keys['c'])
|
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'])
|
if (keys['q'])
|
||||||
camera.transform.rotation.y -= 1;
|
camera.transform.rotation.y -= 1;
|
||||||
|
@ -288,6 +292,12 @@ int main()
|
||||||
if (keys['t'])
|
if (keys['t'])
|
||||||
camera.transform.rotation.x += 1;
|
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_RenderClear(renderer);
|
||||||
SDL_RenderCopy(renderer,texture,NULL,NULL);
|
SDL_RenderCopy(renderer,texture,NULL,NULL);
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|
Loading…
Reference in a new issue