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

Finish lookAt

This commit is contained in:
Miloslav Číž 2019-06-05 22:18:01 +02:00
parent 79dd3c6284
commit f0b17d67ba

View file

@ -1096,16 +1096,22 @@ void S3L_lookAt(S3L_Vec4 pointFrom, S3L_Vec4 pointTo, S3L_Transform3D *t)
v.x = pointTo.x - pointFrom.x; v.x = pointTo.x - pointFrom.x;
v.y = pointTo.z - pointFrom.z; v.y = pointTo.z - pointFrom.z;
S3L_Unit dx = v.x;
S3L_Unit l = S3L_vec2Length(v); S3L_Unit l = S3L_vec2Length(v);
v.x = (v.x * S3L_FRACTIONS_PER_UNIT) / l;
t->rotation.y = S3L_asin(v.x); dx = (v.x * S3L_FRACTIONS_PER_UNIT) / l; // normalize
t->rotation.y = S3L_asin(dx);
if (v.y < 0) if (v.y < 0)
t->rotation.y = S3L_FRACTIONS_PER_UNIT / 2 - t->rotation.y; t->rotation.y = S3L_FRACTIONS_PER_UNIT / 2 - t->rotation.y;
// TODO v.x = pointTo.y - pointFrom.y;
v.y = l;
dx = (v.x * S3L_FRACTIONS_PER_UNIT) / S3L_vec2Length(v);
t->rotation.x = S3L_asin(dx);
} }
void S3L_setTransform3D( void S3L_setTransform3D(