From 02f23020fc4585286160f72f896cdb94f70be67e Mon Sep 17 00:00:00 2001 From: mcallieri Date: Mon, 18 Dec 2006 15:26:24 +0000 Subject: [PATCH] added a function to approximate a far plane value given a shot and the mesh bbox --- wrap/gl/shot.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/wrap/gl/shot.h b/wrap/gl/shot.h index 5ae0de72..e17ea669 100644 --- a/wrap/gl/shot.h +++ b/wrap/gl/shot.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.10 2006/12/18 14:28:07 matteodelle +*** empty log message *** + Revision 1.9 2006/12/18 09:46:39 callieri camera+shot revamp: changed field names to something with more sense, cleaning of various functions, correction of minor bugs/incongruences, removal of the infamous reference in shot. @@ -130,6 +133,35 @@ static void UnsetView() glPopAttrib(); } +/// given a shot and the mesh bounding box, returns an approximate far plane distance +/// distance is always approximated by excess +static ScalarType GetFarPlane(vcg::Shot & shot, vcg::Box3 bbox) +{ + ScalarType farDist; + + Point3 farcorner; + Point3 campos = shot.Extrinsics.tra; + + if (abs(campos.X() - mainmodel->bbox.max.X()) > abs(campos.X() - bbox.min.X())) + farcorner.X() = mainmodel->bbox.max.X(); + else + farcorner.X() = mainmodel->bbox.min.X(); + + if (abs(campos.Y() - mainmodel->bbox.max.Y()) > abs(campos.Y() - bbox.min.Y())) + farcorner.Y() = mainmodel->bbox.max.Y(); + else + farcorner.Y() = mainmodel->bbox.min.Y(); + + if (abs(campos.Z() - mainmodel->bbox.max.Z()) > abs(campos.Z() - bbox.min.Z())) + farcorner.Z() = mainmodel->bbox.max.Z(); + else + farcorner.Z() = mainmodel->bbox.min.Z(); + + farDist = (campos - farcorner).Norm(); + + return farDist; +} + static void SetSubView(vcg::Shot & shot, vcg::Point2 p1, vcg::Point2 p2)