mirror of https://github.com/AxioDL/zeus.git
Non-inverted lookAt implementation
This commit is contained in:
parent
9762710b85
commit
65a49aca92
12
src/Math.cpp
12
src/Math.cpp
|
@ -73,16 +73,18 @@ CTransform lookAt(const CVector3f& pos, const CVector3f& lookPos, const CVector3
|
||||||
{
|
{
|
||||||
CVector3f vLook,vRight,vUp;
|
CVector3f vLook,vRight,vUp;
|
||||||
|
|
||||||
vLook = pos - lookPos;
|
vLook = lookPos - pos;
|
||||||
|
if (vLook.magnitude() < FLT_EPSILON)
|
||||||
|
vLook = {0.f, 1.f, 0.f};
|
||||||
vLook.normalize();
|
vLook.normalize();
|
||||||
|
|
||||||
vRight = up.cross(vLook);
|
vRight = vLook.cross(up);
|
||||||
vRight.normalize();
|
vRight.normalize();
|
||||||
|
|
||||||
vUp = vLook.cross(vRight);
|
vUp = vRight.cross(vLook);
|
||||||
|
|
||||||
CMatrix3f rmBasis(vRight, vUp, vLook);
|
CMatrix3f rmBasis(vRight, vLook, vUp);
|
||||||
return CTransform(rmBasis.transposed(), CVector3f(-pos.dot(vRight), -pos.dot(vUp), -pos.dot(vLook)));
|
return CTransform(rmBasis, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector3f getBezierPoint(const CVector3f& a, const CVector3f& b, const CVector3f& c, const CVector3f& d, float t)
|
CVector3f getBezierPoint(const CVector3f& a, const CVector3f& b, const CVector3f& c, const CVector3f& d, float t)
|
||||||
|
|
Loading…
Reference in New Issue