Home
FAQ
Player
Utilities
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

Camera.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: A persepective X11 OpenGL Camera Sensor
00022  * Author: Nate Koenig
00023  * Date: 15 July 2003
00024  * CVS: $Id: Camera.hh,v 1.36 2005/05/06 17:14:57 natepak Exp $
00025  */
00026 
00027 #ifndef CAMERA_HH
00028 #define CAMERA_HH
00029 
00030 #include "Error.hh"
00031 #include "Sensor.hh"
00032 #include "Vector.hh"
00033 #include "RenderOptions.hh"
00034 #include "GLContext.hh"
00035 
00036 // Forward Declarations
00037 class World;
00038 class WorldFile;
00039 class WorldFileNode;
00040 class Body;
00041 class ShaderManager;
00042 class ShaderObject;
00043 
00049 class Camera : public Sensor
00050 {
00051   // Constructor
00052   public: Camera( World *world );
00053 
00054   // Destructor
00055   public: virtual ~Camera();
00056 
00067   public: int Init(int width, int height, double hfov,
00068                    double minDepth, double maxDepth, const char *method, 
00069                    int zBufferDepth);
00070 
00071   public: void InitContext( GLContext &context );
00072 
00074   public: int Fini();
00075 
00077   public: void Update();
00078 
00080   public: void SetPose(GzPose pose);
00081 
00083   public: GzPose GetPose();
00084 
00086   public: void SetFOV(double fov);
00087 
00089   public: double GetFOV() const;
00090 
00092   public: void SetRenderOptions(const RenderOptions *opt);
00093 
00095   public: void GetRenderOptions(RenderOptions *opt) const;
00096 
00098   public: void GetImageSize(int *w, int *h);
00099 
00101   public: const unsigned char *GetImageData() const {return this->rgbImage;}
00102 
00108   public: double GetZValue(int x, int y);
00109 
00130   public: GzPose CalcCameraDelta(int mode, GzVector a, GzVector b);
00131   
00132   // Render the scene from the camera perspective
00133   private: void Render();
00134 
00135   // Render the models
00136   private: void RenderModels( int pass );  
00137 
00138   // Render a shadow map for each light source
00139   private: void RenderShadowMaps();
00140 
00141   // Render a set of axes on a body
00142   private: void RenderAxes(Body *body);
00143 
00144   // Draw an axis with the given pose and size
00145   private: void DrawAxis(GzPose pose, double size, const char *text);
00146     
00148   public: void SetSavePath(const char *pathname);
00149 
00151   public: void EnableSaveFrame(bool enable);
00152 
00153   // Save the camera frame
00154   private: void SaveFrame();
00155  
00156   private: GLuint LoadShader(GLenum target, const char *file);
00157 
00158   private: float *Mult( float *a, float *b);
00159   private: void RenderDepthTexture();
00160 
00161   // GL rendering context
00162   private: GLContext context;
00163 
00164   // Geom rendering options
00165   private: RenderOptions renderOpt;
00166 
00167   // Camera pose
00168   private: GzPose cameraPose;
00169 
00170   // Lens options
00171   private: double hfov;
00172   private: double nearClip, farClip;
00173 
00174   // Image dimensions
00175   private: int imageWidth, imageHeight;
00176   
00177   // RGB image buffer
00178   private: uint8_t *rgbImage;
00179 
00180   // Store projection matrix for GUI calculations
00181   private: GLfloat cameraProjectionMatrix[16];
00182   private: GLfloat cameraViewMatrix[16];
00183 
00184   // Info for saving images
00185   private: bool saveEnable;
00186   private: const char *savePathname;
00187   private: unsigned int saveCount;
00188 
00189   // Shadow mapping
00190   private: GLContext shadowMapContext;
00191   private: GLuint shadowMapTexture;
00192   private: int shadowMapSize;
00193   private: uint8_t *shadowImage;
00194 
00195   private: GLfloat lightProjectionMatrix[16];
00196   private: GLfloat lightViewMatrix[16];
00197 
00198   private: void SaveShadowFrame();
00199   private: ShaderManager *shaderManager;
00200   private: ShaderObject *shaderObject;
00201 };
00202 
00203 #endif
00204 


Last updated $Date: 2004/12/21 01:49:15 $
Generated on Sun May 22 18:39:07 2005 for Gazebo by doxygen 1.4.2