gxcamera.h

Go to the documentation of this file.
00001 
00004 
00005 //
00006 // Copyright (c) 2002-2004 California Institute of Technology
00007 // Copyright (c) 2004-2007 University of Southern California
00008 // Rob Peters <rjpeters at usc dot edu>
00009 //
00010 // created: Thu Nov 21 15:18:58 2002
00011 // commit: $Id: gxcamera.h 10065 2007-04-12 05:54:56Z rjpeters $
00012 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/gfx/gxcamera.h $
00013 //
00014 // --------------------------------------------------------------------
00015 //
00016 // This file is part of GroovX.
00017 //   [http://ilab.usc.edu/rjpeters/groovx/]
00018 //
00019 // GroovX is free software; you can redistribute it and/or modify it
00020 // under the terms of the GNU General Public License as published by
00021 // the Free Software Foundation; either version 2 of the License, or
00022 // (at your option) any later version.
00023 //
00024 // GroovX is distributed in the hope that it will be useful, but
00025 // WITHOUT ANY WARRANTY; without even the implied warranty of
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027 // General Public License for more details.
00028 //
00029 // You should have received a copy of the GNU General Public License
00030 // along with GroovX; if not, write to the Free Software Foundation,
00031 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00032 //
00034 
00035 #ifndef GROOVX_GFX_GXCAMERA_H_UTC20050626084024_DEFINED
00036 #define GROOVX_GFX_GXCAMERA_H_UTC20050626084024_DEFINED
00037 
00038 #include "geom/rect.h"
00039 
00040 #include "gfx/gbvec.h"
00041 #include "gfx/gxnode.h"
00042 
00043 #include "io/fields.h"
00044 
00045 namespace Gfx
00046 {
00047   class Canvas;
00048 }
00049 
00050 // ########################################################
00051 
00053 
00054 class GxCamera : public GxNode
00055 {
00056 public:
00057   GxCamera() : GxNode(), itsWidth(0), itsHeight(0) {}
00058 
00060   virtual ~GxCamera() throw();
00061 
00063   void reshape(Gfx::Canvas& canvas, int w, int h);
00064 
00066   int width() const { return itsWidth; }
00068   int height() const { return itsHeight; }
00069 
00071   virtual void getBoundingCube(Gfx::Bbox& /*bbox*/) const {}
00072 
00073 private:
00074   int itsWidth;
00075   int itsHeight;
00076 };
00077 
00079 class GxPerspectiveCamera : public GxCamera, public FieldContainer
00080 {
00081 public:
00083   GxPerspectiveCamera();
00084 
00086   virtual ~GxPerspectiveCamera() throw();
00087 
00089   static GxPerspectiveCamera* make() { return new GxPerspectiveCamera; }
00090 
00092   static const FieldMap& classFields();
00093 
00094   virtual io::version_id class_version_id() const;
00095   virtual void read_from(io::reader& reader);
00096   virtual void write_to(io::writer& writer) const;
00097 
00098   virtual void draw(Gfx::Canvas& canvas) const;
00099 
00100 private:
00101   double itsFovY;
00102   double itsNearZ;
00103   double itsFarZ;
00104   GbVec3<double> translation;
00105 };
00106 
00108 class GxFixedRectCamera : public GxCamera
00109 {
00110 public:
00112   GxFixedRectCamera() :
00113     GxCamera(),
00114     itsRect(geom::rect<double>::ltrb(-1.0, 1.0, 1.0, -1.0))
00115   {}
00116 
00118   virtual ~GxFixedRectCamera() throw();
00119 
00120   virtual void read_from(io::reader& /*reader*/) {}
00121   virtual void write_to(io::writer& /*writer*/) const {}
00122 
00124   void setRect(const geom::rect<double>& rect) { itsRect = rect; }
00125 
00127   const geom::rect<double>& getRect() const { return itsRect; }
00128 
00129   virtual void draw(Gfx::Canvas& canvas) const;
00130 
00131 private:
00132   geom::rect<double> itsRect;
00133 };
00134 
00136 class GxMinRectCamera : public GxCamera
00137 {
00138 public:
00140   GxMinRectCamera() :
00141     GxCamera(),
00142     itsRect(geom::rect<double>::ltrb(-1.0, 1.0, 1.0, -1.0))
00143   {}
00144 
00146   virtual ~GxMinRectCamera() throw();
00147 
00148   virtual void read_from(io::reader& /*reader*/) {}
00149   virtual void write_to(io::writer& /*writer*/) const {}
00150 
00152   void setRect(const geom::rect<double>& rect) { itsRect = rect; }
00153 
00155   const geom::rect<double>& getRect() const { return itsRect; }
00156 
00157   virtual void draw(Gfx::Canvas& canvas) const;
00158 
00159 private:
00160   geom::rect<double> itsRect;
00161 };
00162 
00164 class GxFixedScaleCamera : public GxCamera, public FieldContainer
00165 {
00166 public:
00168   GxFixedScaleCamera();
00169 
00171   virtual ~GxFixedScaleCamera() throw();
00172 
00174   static GxFixedScaleCamera* make() { return new GxFixedScaleCamera; }
00175 
00177   static const FieldMap& classFields();
00178 
00179   virtual io::version_id class_version_id() const;
00180   virtual void read_from(io::reader& reader);
00181   virtual void write_to(io::writer& writer) const;
00182 
00184   double getLogPixelsPerUnit() const;
00186   void setLogPixelsPerUnit(double s);
00187 
00189   double getPixelsPerUnit() const { return itsPixelsPerUnit; }
00191   void setPixelsPerUnit(double s);
00192 
00193   virtual void draw(Gfx::Canvas& canvas) const;
00194 
00195 private:
00196   double itsPixelsPerUnit;
00197 };
00198 
00200 
00202 class GxPsyphyCamera : public GxCamera, public FieldContainer
00203 {
00204 public:
00206   GxPsyphyCamera();
00207 
00209   virtual ~GxPsyphyCamera() throw();
00210 
00212   static GxPsyphyCamera* make() { return new GxPsyphyCamera; }
00213 
00215   static const FieldMap& classFields();
00216 
00217   virtual io::version_id class_version_id() const;
00218   virtual void read_from(io::reader& reader);
00219   virtual void write_to(io::writer& writer) const;
00220 
00222   double getUnitAngle() const { return itsDegreesPerUnit; }
00224   void setUnitAngle(double deg_per_unit);
00225 
00227   double getViewingDistIn() const { return itsViewingDistance; }
00229   void setViewingDistIn(double inches);
00230 
00231   virtual void draw(Gfx::Canvas& canvas) const;
00232 
00233 private:
00234   double itsDegreesPerUnit;
00235   double itsViewingDistance;    // inches
00236 };
00237 
00238 static const char __attribute__((used)) vcid_groovx_gfx_gxcamera_h_utc20050626084024[] = "$Id: gxcamera.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00239 #endif // !GROOVX_GFX_GXCAMERA_H_UTC20050626084024_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:38 2008 by Doxygen version 1.5.5.