mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-12-22 01:26:17 +01:00
Finish lookAt
This commit is contained in:
parent
79dd3c6284
commit
f0b17d67ba
1 changed files with 10 additions and 4 deletions
14
small3dlib.h
14
small3dlib.h
|
@ -1096,16 +1096,22 @@ void S3L_lookAt(S3L_Vec4 pointFrom, S3L_Vec4 pointTo, S3L_Transform3D *t)
|
|||
v.x = pointTo.x - pointFrom.x;
|
||||
v.y = pointTo.z - pointFrom.z;
|
||||
|
||||
S3L_Unit dx = v.x;
|
||||
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)
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue