From abbcfe10a97b990e8e026c83e6bd1ed54f3ce220 Mon Sep 17 00:00:00 2001 From: mcallieri Date: Mon, 12 Dec 2005 16:53:43 +0000 Subject: [PATCH] corrected UnProject, it's necessary also a ZDepth value to perform inverse projection --- vcg/math/shot.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vcg/math/shot.h b/vcg/math/shot.h index 4c4e1042..4fd7bae4 100644 --- a/vcg/math/shot.h +++ b/vcg/math/shot.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.17 2005/12/07 10:57:52 callieri +added commodity function ProjectWorldtoViewport() to obtain directly pixel indices without calling two separate function of two different objects + Revision 1.16 2005/12/02 16:14:35 callieri in Shot::Axis changed Row3 to GetRow3 . row3 was the old method name of Matrix44 @@ -141,7 +144,8 @@ public: /// project onto the camera plane vcg::Point2 Project(const vcg::Point3 & p) const; - vcg::Point3 UnProject(const vcg::Point2 & p) const; + /// inverse projection from camera plane + Zdepth to original 3D + vcg::Point3 UnProject(const vcg::Point2 & p, const S & d) const; /// take the distance from the point p and the plane parallel to the camera plane and passing through the view /// point. The would be z depth @@ -224,8 +228,9 @@ vcg::Point2 Shot::Project(const vcg::Point3 & p) const{ return camera.Project(ConvertToCameraCoordinates(p)); } template -vcg::Point3 Shot::UnProject(const vcg::Point2 & p) const{ - vcg::Point3 q = camera.UnProject(p); +vcg::Point3 Shot::UnProject(const vcg::Point2 & p, const S & d) const{ + Point2 tp = camera.ViewportToLocal(p); + vcg::Point3 q = camera.UnProject(tp, d); return ConvertToWorldCoordinates(q); } template