mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 12:41:54 +00:00
Uniformalized matrix transform function
This commit is contained in:
parent
5811efecad
commit
afdbba7d82
@ -137,6 +137,7 @@ namespace glm
|
||||
//! From GLM_GTC_matrix_transform extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> lookAt(
|
||||
detail::tmat4x4<T> const & m,
|
||||
detail::tvec3<T> const & eye,
|
||||
detail::tvec3<T> const & center,
|
||||
detail::tvec3<T> const & up);
|
||||
|
@ -326,6 +326,7 @@ namespace matrix_transform
|
||||
|
||||
template <typename T>
|
||||
inline detail::tmat4x4<T> lookAt(
|
||||
detail::tmat4x4<T> const & m,
|
||||
const detail::tvec3<T>& eye,
|
||||
const detail::tvec3<T>& center,
|
||||
const detail::tvec3<T>& up)
|
||||
@ -350,7 +351,7 @@ namespace matrix_transform
|
||||
Result[3][1] =-dot(y, eye);
|
||||
Result[3][2] = dot(f, eye);
|
||||
*/
|
||||
return gtc::matrix_transform::translate(Result, -eye);
|
||||
return m * gtc::matrix_transform::translate(Result, -eye);
|
||||
}
|
||||
}//namespace matrix_transform
|
||||
}//namespace gtc
|
||||
|
@ -109,6 +109,14 @@ namespace glm
|
||||
valType scale,
|
||||
valType bias);
|
||||
|
||||
//! Build a look at view matrix.
|
||||
//! From GLM_GTX_transform2 extension.
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> lookAt(
|
||||
detail::tvec3<T> const & eye,
|
||||
detail::tvec3<T> const & center,
|
||||
detail::tvec3<T> const & up);
|
||||
|
||||
}//namespace transform2
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
@ -153,6 +153,35 @@ namespace transform2
|
||||
return m * scaleBias(scale, bias);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tmat4x4<T> lookAt(
|
||||
const detail::tvec3<T>& eye,
|
||||
const detail::tvec3<T>& center,
|
||||
const detail::tvec3<T>& up)
|
||||
{
|
||||
detail::tvec3<T> f = normalize(center - eye);
|
||||
detail::tvec3<T> u = normalize(up);
|
||||
detail::tvec3<T> s = normalize(cross(f, u));
|
||||
u = cross(s, f);
|
||||
|
||||
detail::tmat4x4<T> Result(1);
|
||||
Result[0][0] = s.x;
|
||||
Result[1][0] = s.y;
|
||||
Result[2][0] = s.z;
|
||||
Result[0][1] = u.x;
|
||||
Result[1][1] = u.y;
|
||||
Result[2][1] = u.z;
|
||||
Result[0][2] =-f.x;
|
||||
Result[1][2] =-f.y;
|
||||
Result[2][2] =-f.z;
|
||||
/* Test this instead of translate3D
|
||||
Result[3][0] =-dot(s, eye);
|
||||
Result[3][1] =-dot(y, eye);
|
||||
Result[3][2] = dot(f, eye);
|
||||
*/
|
||||
return gtc::matrix_transform::translate(Result, -eye);
|
||||
}
|
||||
|
||||
}//namespace transform2
|
||||
}//namespace gtx
|
||||
}//namespace glm
|
||||
|
Loading…
Reference in New Issue
Block a user