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.
|
//! From GLM_GTC_matrix_transform extension.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
detail::tmat4x4<T> lookAt(
|
detail::tmat4x4<T> lookAt(
|
||||||
|
detail::tmat4x4<T> const & m,
|
||||||
detail::tvec3<T> const & eye,
|
detail::tvec3<T> const & eye,
|
||||||
detail::tvec3<T> const & center,
|
detail::tvec3<T> const & center,
|
||||||
detail::tvec3<T> const & up);
|
detail::tvec3<T> const & up);
|
||||||
|
@ -326,6 +326,7 @@ namespace matrix_transform
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline detail::tmat4x4<T> lookAt(
|
inline detail::tmat4x4<T> lookAt(
|
||||||
|
detail::tmat4x4<T> const & m,
|
||||||
const detail::tvec3<T>& eye,
|
const detail::tvec3<T>& eye,
|
||||||
const detail::tvec3<T>& center,
|
const detail::tvec3<T>& center,
|
||||||
const detail::tvec3<T>& up)
|
const detail::tvec3<T>& up)
|
||||||
@ -350,7 +351,7 @@ namespace matrix_transform
|
|||||||
Result[3][1] =-dot(y, eye);
|
Result[3][1] =-dot(y, eye);
|
||||||
Result[3][2] = dot(f, 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 matrix_transform
|
||||||
}//namespace gtc
|
}//namespace gtc
|
||||||
|
@ -109,6 +109,14 @@ namespace glm
|
|||||||
valType scale,
|
valType scale,
|
||||||
valType bias);
|
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 transform2
|
||||||
}//namespace gtx
|
}//namespace gtx
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -153,6 +153,35 @@ namespace transform2
|
|||||||
return m * scaleBias(scale, bias);
|
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 transform2
|
||||||
}//namespace gtx
|
}//namespace gtx
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user