From 01c0bc106fad24ef4558f1cefb9a70013461e8f2 Mon Sep 17 00:00:00 2001 From: ponchio Date: Fri, 7 Nov 2008 15:15:06 +0000 Subject: [PATCH] Added function to get near and far plane for a box (exact). --- wrap/gl/shot.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wrap/gl/shot.h b/wrap/gl/shot.h index d1e50b21..2aca638b 100644 --- a/wrap/gl/shot.h +++ b/wrap/gl/shot.h @@ -168,6 +168,29 @@ static ScalarType GetFarPlane(vcg::Shot & shot, vcg::Box3 & shot, vcg::Box3 bbox, ScalarType &nr, ScalarType &fr) +{ + vcg::Point3 zaxis = shot.Axis(2); + ScalarType offset = zaxis * shot.GetViewPoint(); + bool first = true; + for(int i = 0; i < 8; i++) { + vcg::Point3 c = bbox.P(i); + ScalarType d = -(zaxis * c - offset); + if(first || d < nr) { + nr = d; + first = false; + } + if(first || d > fr) { + fr = d; + first = false; + } + } +} + + + static void SetSubView(vcg::Shot & shot, vcg::Point2 p1, vcg::Point2 p2)