Added function to get near and far plane for a box (exact).

This commit is contained in:
Federico Ponchio 2008-11-07 15:15:06 +00:00
parent df84db769c
commit 01c0bc106f
1 changed files with 23 additions and 0 deletions

View File

@ -168,6 +168,29 @@ static ScalarType GetFarPlane(vcg::Shot<ScalarType> & shot, vcg::Box3<ScalarType
return farDist;
}
/// given a shot and the mesh bounding box, return near and far plane (exact)
static void GetNearFarPlanes(vcg::Shot<ScalarType> & shot, vcg::Box3<ScalarType> bbox, ScalarType &nr, ScalarType &fr)
{
vcg::Point3<ScalarType> zaxis = shot.Axis(2);
ScalarType offset = zaxis * shot.GetViewPoint();
bool first = true;
for(int i = 0; i < 8; i++) {
vcg::Point3<ScalarType> 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<ScalarType> & shot,
vcg::Point2<ScalarType> p1,
vcg::Point2<ScalarType> p2)