enki/interactions/CircularCam.h

Go to the documentation of this file.
00001 /*
00002     Enki - a fast 2D robot simulator
00003     Copyright (C) 1999-2008 Stephane Magnenat <stephane at magnenat dot net>
00004     Copyright (C) 2004-2005 Markus Waibel <markus dot waibel at epfl dot ch>
00005     Copyright (c) 2004-2005 Antoine Beyeler <abeyeler at ab-ware dot com>
00006     Copyright (C) 2005-2006 Laboratory of Intelligent Systems, EPFL, Lausanne
00007     Copyright (C) 2006-2008 Laboratory of Robotics Systems, EPFL, Lausanne
00008     See AUTHORS for details
00009 
00010     This program is free software; the authors of any publication 
00011     arising from research using this software are asked to add the 
00012     following reference:
00013     Enki - a fast 2D robot simulator
00014     http://lis.epfl.ch/enki
00015     Stephane Magnenat <stephane at magnenat dot net>,
00016     Markus Waibel <markus dot waibel at epfl dot ch>
00017     Laboratory of Intelligent Systems, EPFL, Lausanne.
00018 
00019     You can redistribute this program and/or modify
00020     it 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     This program is distributed in the hope that it will be useful,
00025     but WITHOUT ANY WARRANTY; without even the implied warranty of
00026     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027     GNU General Public License for more details.
00028 
00029     You should have received a copy of the GNU General Public License
00030     along with this program; if not, write to the Free Software
00031     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00032 */
00033 
00034 #ifndef __ENKI_CIRCULARCAM_H
00035 #define __ENKI_CIRCULARCAM_H
00036 
00037 #include "../Interaction.h"
00038 #include "../PhysicalEngine.h"
00039 
00040 #include <valarray>
00041 
00045 namespace Enki
00046 {
00048 
00052     struct PixelOperationFunctor
00053     {
00055         virtual ~PixelOperationFunctor() { }
00057         virtual void operator()(double &zBuffer2, Color &pixelBuffer, const double &objectDist2, const Color &objectColor) = 0;
00058     };
00059     
00060     
00062 
00067     class CircularCam : public LocalInteraction
00068     {
00069     protected:
00071         Vector positionOffset;
00073         double height;
00075         Vector absPos;
00077         double absOrientation;
00078 
00079     public:
00081         std::valarray<double> zbuffer;
00083         std::valarray<Color> image;
00085         double halfFieldOfView;
00087         double angleOffset;
00088         
00090         bool useFog;
00092         double fogDensity;
00094         Color lightThreshold;
00095         
00097         PixelOperationFunctor *pixelOperation;
00098 
00099     public :
00101 
00109         CircularCam(Robot *owner, Vector pos, double height, double orientation, double halfFieldOfView, unsigned pixelCount);
00111         virtual ~CircularCam(){}
00112         virtual void init(double dt, World* w);
00113         virtual void objectStep(double dt, World *w, PhysicalObject *po);
00114         virtual void wallsStep(double dt, World* w);
00115         virtual void finalize(double dt, World* w);
00116         
00118         void setRange(double range);
00120         Point getAbsolutePosition(void) { return absPos; }
00122         double getAbsoluteOrientation(void) { return absOrientation; }
00123         
00124     protected:
00126         double interpolateLinear(double s0, double s1, double sv, double d0, double d1);
00128         void drawTexturedLine(const Point &p0, const Point &p1, const Texture &texture);
00129     };
00130     
00131     
00134 
00135     class OmniCam : public LocalInteraction
00136     {
00137     public:
00139         std::valarray<double> zbuffer;
00141         std::valarray<Color> image;
00142         
00143     protected:
00145         CircularCam cam0;
00147         CircularCam cam1;
00148 
00149     public :
00151 
00156         OmniCam(Robot *owner, double height, unsigned halfPixelCount);
00158         virtual ~OmniCam(){}
00159         virtual void init(double dt, World* w);
00160         virtual void objectStep(double dt, World *w, PhysicalObject *po);
00161         virtual void wallsStep(double dt, World* w);
00162         virtual void finalize(double dt, World* w);
00164         void setRange(double range);
00166         void setFogConditions(bool useFog, double density = 0.0, Color threshold = Color::black);
00168         void setPixelOperationFunctor(PixelOperationFunctor *pixelOperationFunctor);
00169     };
00170 }
00171 #endif
00172 

Generated on Sun Mar 1 03:10:09 2009 for Enki by  doxygen 1.5.1