00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __CIRCULARCAM_H
00032 #define __CIRCULARCAM_H
00033
00034 #include <enki/Interaction.h>
00035 #include <enki/PhysicalEngine.h>
00036
00037 #include <valarray>
00038
00042 namespace Enki
00043 {
00045
00047 struct PixelOperationFunctor
00048 {
00050 virtual ~PixelOperationFunctor() { }
00052 virtual void operator()(double &zBuffer2, An::Color &pixelBuffer, const double &objectDist2, const An::Color &objectColor) = 0;
00053 };
00054
00056
00057 class CircularCam : public LocalInteraction
00058 {
00059 protected:
00061 An::Vector positionOffset;
00063 double height;
00065 An::Vector absPos;
00067 double absOrientation;
00068
00069 public:
00071 std::valarray<double> zbuffer;
00073 std::valarray<An::Color> image;
00075 double fieldOfView;
00077 double angleOffset;
00078
00080 bool useFog;
00082 double fogDensity;
00084 An::Color lightThreshold;
00085
00087 PixelOperationFunctor *pixelOperation;
00088
00089 public :
00091 CircularCam(Robot *owner, An::Vector pos, double height, double orientation, double fieldOfView, unsigned pixelCount);
00093 virtual ~CircularCam(){}
00094 virtual void init();
00095 virtual void objectStep (double dt, PhysicalObject *po, World *w);
00096 virtual void wallsStep(World *w);
00097 virtual void finalize(double dt);
00098
00100 An::Point getAbsolutePosition(void) { return absPos; }
00102 double getAbsoluteOrientation(void) { return absOrientation; }
00103
00104 protected:
00106 double interpolateLinear(double s0, double s1, double sv, double d0, double d1);
00108 void drawTexturedLine(const An::Point &p0, const An::Point &p1, const An::Texture &texture);
00109 };
00110 }
00111 #endif
00112