Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maths::C_Ray C_Camera::GetRayToNearPlane(float x, float y) const
- {
- maths::C_Ray ray;
- maths::C_Matrix4 invMV = ComputeInverseMatrix();
- maths::C_Matrix4 mvp = m_Matrix * m_ProjectionMatrix;
- maths::C_Frustum frustum = mvp.ExtractFrustum();
- maths::C_Vector3 points[8];
- frustum.GetCornerPoints(points);
- float nx = 1.0f - x;
- float ny = 1.0f - y;
- maths::C_Vector3 target = points[0] * nx * ny + points[1] * x * ny + points[2] * x * y + points[3] * nx * y;
- ray.m_Position.Set(invMV.Cell[12], invMV.Cell[13], invMV.Cell[14]);
- ray.m_Direction = (target - ray.m_Position);
- ray.m_Direction.Normalize();
- ray.m_Position.Set(invMV.Cell[12], invMV.Cell[13], invMV.Cell[14]);
- return ray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement