From 1257fd3a4af71e997f01f7a75f60f86fe7b64697 Mon Sep 17 00:00:00 2001 From: mcallieri Date: Wed, 7 Dec 2005 10:57:52 +0000 Subject: [PATCH] added commodity function ProjectWorldtoViewport() to obtain directly pixel indices without calling two separate function of two different objects --- vcg/math/shot.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vcg/math/shot.h b/vcg/math/shot.h index 344163c8..4c4e1042 100644 --- a/vcg/math/shot.h +++ b/vcg/math/shot.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +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 + Revision 1.15 2005/12/01 01:03:37 cignoni Removed excess ';' from end of template functions, for gcc compiling @@ -144,6 +147,10 @@ public: /// point. The would be z depth S Depth(const vcg::Point3 & p)const; + /// project a 3d point from 3D WORLD to 2D VIEWPORT + vcg::Point2 ProjectWorldtoViewport(const vcg::Point3 & p) const; + + }; // end class definition template @@ -226,6 +233,11 @@ S Shot::Depth(const vcg::Point3 & p)const { return ConvertToCameraCoordinates(p).Z(); } +template +vcg::Point2 Shot::ProjectWorldtoViewport(const vcg::Point3 & p)const +{ + return camera.LocalToViewport( camera.Project( ConvertToCameraCoordinates(p) ) ); +} class Shotf: public Shot{}; class Shotd: public Shot{};