1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/small3dlib.git synced 2024-11-20 20:29:58 +01:00

Continue HQ program

This commit is contained in:
Miloslav Číž 2019-06-18 20:44:45 +02:00
parent b3951684d3
commit 242bf42ffc
2 changed files with 39 additions and 15 deletions

View file

@ -486,22 +486,46 @@ int main()
S3L_initScene(models,MODELS_TOTAL,&scene);
char fileName[] = "test00.ppm";
S3L_Transform3D transform0, transform1;
S3L_Vec4 target0, target1;
S3L_initTransoform3D(&transform0);
S3L_initTransoform3D(&transform1);
target0 = scene.models[0].transform.translation;
target1 = scene.models[2].transform.translation;
transform0.translation.x = 2 * S3L_FRACTIONS_PER_UNIT;
transform0.translation.y = 4 * S3L_FRACTIONS_PER_UNIT;
transform0.translation.z = -14 * S3L_FRACTIONS_PER_UNIT;
S3L_lookAt(target0,&transform0);
transform1.translation.x = 5 * S3L_FRACTIONS_PER_UNIT;
transform1.translation.y = 6 * S3L_FRACTIONS_PER_UNIT;
transform1.translation.z = 3 * S3L_FRACTIONS_PER_UNIT;
transform1.rotation.x = S3L_FRACTIONS_PER_UNIT / 8;
S3L_lookAt(target1,&transform1);
transform1.rotation.y = -S3L_FRACTIONS_PER_UNIT + transform1.rotation.y;
int frames = 100;
for (int i = 0; i < 100; ++i) // render the frames
for (int i = 0; i < frames; ++i) // render the frames
{
animateWater();
scene.camera.transform.translation.x = 2000;
scene.camera.transform.translation.y = 3000;
scene.camera.transform.translation.z = -S3L_FRACTIONS_PER_UNIT * 8;
float t = i / ((float) frames);
S3L_Vec4 target;
target.x = 0;
target.y = 0;
target.z = 0;
scene.camera.transform.translation.x = interpolate(transform0.translation.x,transform1.translation.x,t);
scene.camera.transform.translation.y = interpolate(transform0.translation.y,transform1.translation.y,t);
scene.camera.transform.translation.z = interpolate(transform0.translation.z,transform1.translation.z,t);
S3L_lookAt(scene.camera.transform.translation,target,&scene.camera.transform);
scene.camera.transform.rotation.x = interpolate(transform0.rotation.x,transform1.rotation.x,t);
scene.camera.transform.rotation.y = interpolate(transform0.rotation.y,transform1.rotation.y,t);
clearFrameBuffer();

View file

@ -327,7 +327,7 @@ typedef struct
static inline void S3L_initTransoform3D(S3L_Transform3D *t);
void S3L_lookAt(S3L_Vec4 pointFrom, S3L_Vec4 pointTo, S3L_Transform3D *t);
void S3L_lookAt(S3L_Vec4 pointTo, S3L_Transform3D *t);
void S3L_setTransform3D(
S3L_Unit tx,
@ -1352,12 +1352,12 @@ void S3L_initTransoform3D(S3L_Transform3D *t)
t->scale.w = 0;
}
void S3L_lookAt(S3L_Vec4 pointFrom, S3L_Vec4 pointTo, S3L_Transform3D *t)
void S3L_lookAt(S3L_Vec4 pointTo, S3L_Transform3D *t)
{
S3L_Vec4 v;
v.x = pointTo.x - pointFrom.x;
v.y = pointTo.z - pointFrom.z;
v.x = pointTo.x - t->translation.x;
v.y = pointTo.z - t->translation.z;
S3L_Unit dx = v.x;
S3L_Unit l = S3L_vec2Length(v);
@ -1369,7 +1369,7 @@ void S3L_lookAt(S3L_Vec4 pointFrom, S3L_Vec4 pointTo, S3L_Transform3D *t)
if (v.y < 0)
t->rotation.y = S3L_FRACTIONS_PER_UNIT / 2 - t->rotation.y;
v.x = pointTo.y - pointFrom.y;
v.x = pointTo.y - t->translation.y;
v.y = l;
l = S3L_vec2Length(v);