Viewpoint.h

Go to the documentation of this file.
00001 
00011 #pragma once
00012 
00013 
00014 #include "PortablePicture.h"
00015 
00019 class Viewpoint
00020 {
00021 public:
00023     Viewpoint() {}
00024 /*
00025  * Mutators
00026  */
00028     void setExtrinsics (const ColVector3 up_vector, const Vertex center_of_projection, const Vertex lookat_point);
00029 
00031     void setIntrinsics (double vert_fov, double width_over_height, double near_plane, double far_plane) ;
00032 
00034     void loadFromFiles (const char *photo_filename, const char *silhouette_filename /* can be NULL */);
00035 
00036 
00037 /*
00038  * Accessors
00039  */
00041     unsigned int getWidth()        const { return photo.getWidth(); }
00042 
00044     unsigned int getHeight()       const { return photo.getHeight(); }
00045 
00049     Vertex getLookatPoint()        const { return lookatPoint; }
00050 
00053     Vertex getCenterOfProjection() const { return COP; }
00054 
00056     ColVector3 getUpVector()       const { return upVector; }
00057 
00059     double getDistanceToObject()   const 
00060     {   
00061         ColVector3 diff = COP - lookatPoint;
00062         return diff.getLength();
00063     }
00064 
00066     RgbByte colorAt (unsigned int u, unsigned int v) const { return photo.at(v,u); }
00067 
00069     bool pixelIsTransparent (unsigned int u, unsigned int v) const
00070     {
00071         if (!bHasSilhouette) return false;
00072         return (silhouette.at(v,u) == RgbByte(0,0,0));        
00073     }
00074 
00076     bool hasSilhouette () const { return bHasSilhouette; }
00077 
00078 /*
00079  * Methods
00080  */
00082     double *getModelviewMatrix () const;
00083 
00085     double *getProjectionMatrix() const;
00086 
00089     std::vector< unsigned int > imageBuffer;
00090 
00092     PortablePixMap photo;
00093 
00094 private:
00095 
00096     // extrinsic camera information
00097     ColVector3 upVector;
00098     Vertex COP;
00099     Vertex lookatPoint;
00100 
00101     // intrinsic camera information
00102     double verticalFOV;
00103     double widthOverHeight; // aka aspect ratio
00104     double nearPlane;       // aka focal length
00105     double farPlane;  // we calculate this ourselves
00106 
00107     Matrix4x4d modelview;
00108     Matrix4x4d projection;
00109 
00110     // image data
00111     PortablePixMap silhouette;
00112     bool bHasSilhouette;
00113 };
00114 
00119 class ViewpointList : public std::vector< Viewpoint > 
00120 {
00121 public:
00122     ViewpointList() {}
00123 
00124     void loadFromFile (const char *filename);
00125 
00126 private:
00127     void loadSettingsFromCol (const char *filename);
00128     void loadSettingsFromXml(const char *filename);
00129 };

Generated on Tue May 21 03:34:51 2002 for Archimedes by doxygen1.2.15