diff --git a/wrap/gui/view.h b/wrap/gui/view.h index af718773..c6247923 100644 --- a/wrap/gui/view.h +++ b/wrap/gui/view.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2004/05/12 20:55:18 ponchio +*** empty log message *** + Revision 1.5 2004/05/07 12:46:08 cignoni Restructured and adapted in a better way to opengl @@ -53,7 +56,7 @@ y is upward! #include #include #include -#include +#include namespace vcg { /** @@ -68,10 +71,13 @@ public: void SetView(); Point3 Project(const Point3 &p) const; Point3 UnProject(const Point3 &p) const; - Point3 ViewPoint(); + Point3 ViewPoint() const; /// Return the plane perpendicular to the view axis and passing through point P. Plane3 ViewPlaneFromModel(const Point3 &p); + + /// Return the line of view passing through point P. + Line3 ViewLineFromModel(const Point3 &p); /// Return the line passing through the point p and the observer. Line3 ViewLineFromWindow(const Point3 &p); @@ -107,7 +113,7 @@ template void View::SetView() { } -template Point3 View::ViewPoint() { +template Point3 View::ViewPoint() const { Matrix44 mi=model; Invert(mi); return mi* Point3(0, 0, 0); @@ -116,11 +122,22 @@ template Point3 View::ViewPoint() { template Plane3 View::ViewPlaneFromModel(const Point3 &p) { Point3 vp=ViewPoint(); - Plane3 pl; // plane perpedicular to view direction and passing through manip center - pl.n=(vp-p); - pl.d=pl.n*p; + Plane3 pl; // plane perpedicular to view direction and passing through manip center + pl.n=(vp-p); + pl.d=pl.n*p; return pl; } + +// Note that p it is assumed to be in model coordinate. +template Line3 View::ViewLineFromModel(const Point3 &p) +{ + Point3 vp=ViewPoint(); + Line3 line; + line.SetOrigin(vp); + line.SetDirection(p - vp); + return line; +} + // Note that p it is assumed to be in window coordinate. template Line3 View::ViewLineFromWindow(const Point3 &p) { @@ -173,4 +190,4 @@ template Point3 View::WindowCoordToNormDevCoord(const Point3 }//namespace -#endif \ No newline at end of file +#endif