Vector4 Camera::unproject(const Vector4 &p) const
{
Vector4 r = invert(proj_matrix)*Vector4(p.x, p.y, p.z, 1.0f);
- r = object_matrix*Vector4(r.x, r.y, r.z, p.w);
+ r = object_matrix*Vector4(r.x/r.w, r.y/r.w, r.z/r.w, p.w);
return r;
}
+Vector3 Camera::unproject(const Vector3 &p) const
+{
+ return unproject(Vector4(p.x, p.y, p.z, 1.0f)).slice<3>(0);
+}
+
void Camera::apply() const
{
MatrixStack::projection() = proj_matrix;
Vector3 project(const Vector4 &) const;
Vector3 project(const Vector3 &) const;
Vector4 unproject(const Vector4 &) const;
+ Vector3 unproject(const Vector3 &) const;
void apply() const;