mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 12:41:54 +00:00
Ticket #37: Added pickMatrix function
This commit is contained in:
parent
7a3aa677be
commit
9fbfb8c208
@ -133,6 +133,14 @@ namespace glm
|
||||
detail::tmat4x4<T> const & proj,
|
||||
detail::tvec4<U> const & viewport);
|
||||
|
||||
//! Define a picking region
|
||||
//! From GLM_GTC_matrix_transform extension.
|
||||
template <typename T, typename U>
|
||||
detail::tmat4x4<T> pickMatrix(
|
||||
detail::tvec2<T> const & center,
|
||||
detail::tvec2<T> const & delta,
|
||||
detail::tvec4<U> const & viewport);
|
||||
|
||||
//! Build a look at view matrix.
|
||||
//! From GLM_GTC_matrix_transform extension.
|
||||
template <typename T>
|
||||
|
@ -324,6 +324,25 @@ namespace matrix_transform
|
||||
return detail::tvec3<T>(obj);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
detail::tmat4x4<T> pickMatrix
|
||||
(
|
||||
detail::tvec2<T> const & center,
|
||||
detail::tvec2<T> const & delta,
|
||||
detail::tvec4<U> const & viewport
|
||||
)
|
||||
{
|
||||
assert(delta.x > 0.0f && delta.y > 0.0f)
|
||||
detail::tmat4x4<T> Result(1.0f);
|
||||
|
||||
if(!(delta.x > 0.0f && delta.y > 0.0f))
|
||||
return Result; // Error
|
||||
|
||||
// Translate and scale the picked region to the entire window
|
||||
Result = translate(Result, (T(viewport[2]) - T(2) * (x - T(viewport[0]))) / delta.x, (T(viewport[3]) - T(2) * (y - T(viewport[1]))) / delta.y, T(0));
|
||||
return scale(Result, T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline detail::tmat4x4<T> lookAt(
|
||||
const detail::tvec3<T>& eye,
|
||||
|
Loading…
Reference in New Issue
Block a user