From f4010f0dce9cc6561ad07cf19c2278baba9a997d Mon Sep 17 00:00:00 2001 From: ganovelli Date: Wed, 7 Dec 2011 13:15:28 +0000 Subject: [PATCH] corrected setOrtho --- vcg/math/camera.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vcg/math/camera.h b/vcg/math/camera.h index d43edbac..db624ece 100644 --- a/vcg/math/camera.h +++ b/vcg/math/camera.h @@ -172,12 +172,20 @@ public: int cameraType; /// Type of camera: PERSPECTIVE,ORTHO,ISOMETRIC,CAVALIERI - void SetOrtho(S dist) + void SetOrtho( S l,S r, S b, S t, vcg::Point2 viewport) { cameraType = ORTHO; - ViewportPx = ( ((ViewportPx[0] * PixelSizeMm[0]) * (ViewportPx[1] * PixelSizeMm[1])) / FocalMm ) * dist; + ViewportPx = viewport; + + PixelSizeMm[0] = (r-l) / (S)ViewportPx[0]; + PixelSizeMm[1] = (t-b) / (S)ViewportPx[1]; + + CenterPx[0] = -l/(r-l) * (S)ViewportPx[0]; + CenterPx[1] = -b/(t-b) * (S)ViewportPx[1]; + }; + bool IsOrtho() const { return ( cameraType == ORTHO );