32
33
#include "cameras.h"
34
//opengl allows up to 8 clipping planes
36
//opengl allows up to 6 clipping planes
35
37
const unsigned int MAX_OPENGL_CLIPPLANES=6;
55
ANAGLYPH_GREENMAGENTA,
56
//Colour matrix +accumulation buffer methods
60
ANAGLYPH_ENUM_END //Not a method. end of enum
47
static const Camera *curCam;
66
static Camera *curCam;
48
68
unsigned int effectType;
50
virtual void enable() const=0;
70
virtual void enable(unsigned int pass=0) const =0;
51
71
virtual void disable() const=0;
52
virtual unsigned int getMax() const=0;
74
//Write the effect's state information to file
75
virtual bool writeState(std::ofstream &f,
76
unsigned int format, unsigned int depth) const=0;
77
//read the effects state information from an XML file
78
virtual bool readState(xmlNodePtr &n)=0;
80
virtual bool needCamUpdate() const { return false;}
82
//!Returns true if the effect has any influence on the output
83
virtual bool willDoSomething() const=0;
85
virtual unsigned int numPassesNeeded() const { return 1;}
54
87
virtual unsigned int getType() const { return effectType;};
55
88
static void setCurCam(Camera *c) {curCam=c;}
59
class PlaneCropEffect : public Effect
62
static unsigned int nextGLId;
63
unsigned int openGLId;
64
Point3D origin, normal;
66
PlaneCropEffect(){effectType=EFFECT_PLANE_CROP;openGLId=nextGLId;
67
nextGLId++; ASSERT(nextGLId < MAX_OPENGL_CLIPPLANES);}
72
virtual unsigned int getMax() const;
89
static void setBoundingCube(const BoundCube &c) {bc=c;}
94
class BoxCropEffect : public Effect
97
//controlling ID values for gl plane. No more than MAX_OPENGL_CLIPPLANES allowed
98
unsigned int openGLIdStart,openGLIdEnd;
99
//Cropping margins (Fraction from edge towards opposite edge (complete)). 0->1.
100
//Opposing edges must sum to 0->1. (xLo,xHi,yLo...)
101
float cropFractions[6];
102
//!True if we should transform to camera coordinates before applying crop
103
bool useCamCoordinates;
105
//!Aspect ratio of output image
108
void doClip(const Point3D &origin, const Point3D & normal,unsigned int glOffset) const;
110
BoxCropEffect(){useCamCoordinates=false;effectType=EFFECT_BOX_CROP;openGLIdStart=0; }
113
//!Enable the clipping plane. Values *must* be set before calling
114
void enable(unsigned int pass) const;
116
//!DIsable the clipping plane
117
void disable() const;
121
//Write the effect's state information to file
122
bool writeState(std::ofstream &f, unsigned int format,
123
unsigned int depth) const;
124
//read the effects state information from an XML file
125
bool readState(xmlNodePtr &n);
127
//!Returns true if the effect has any influence on the output
128
bool willDoSomething() const;
130
//!Set the fractions of cube from margin
131
//-- there should be 6 floats (x,y,z)_(low,high) (x_lo, x_hi....)
132
// each low/hi should form a sum between 0 and 1.
133
void setFractions(const float *fractionArray);
135
void useCamCoords(bool enable){useCamCoordinates=enable;};
137
//!Alters the input box to generate cropping bounding box
138
//note the box may be inside out if the cropping limits
139
//exceed themselves..
140
void getCroppedBounds(BoundCube &b) const;
142
float getCropValue(unsigned int pos) const {ASSERT(pos<6); return cropFractions[pos];}
145
class AnaglyphEffect : public Effect
148
unsigned int colourMode;
151
mutable Camera *oldCam;
155
AnaglyphEffect(){effectType=EFFECT_ANAGLYPH;colourMode=ANAGLYPH_REDBLUE;oldCam=0;baseShift=0.01f; eyeFlip=false;}
158
//!Enable the clipping plane. Values *must* be set before calling
159
void enable(unsigned int pass) const;
161
//!DIsable the clipping plane
162
void disable() const;
164
//Write the effect's state information to file
165
bool writeState(std::ofstream &f, unsigned int format,
166
unsigned int depth) const;
167
//read the effects state information from an XML file
168
bool readState(xmlNodePtr &n);
170
//!Whether we should be flipping the lens from its hard-coded left-right
171
void setFlip(bool shouldFlip) {eyeFlip=shouldFlip;};
173
void setMode(unsigned int mode){ASSERT(colourMode<ANAGLYPH_ENUM_END);colourMode=mode;};
174
void setBaseShift(float shift) { baseShift=shift;};
176
bool needCamUpdate() const { return true;}
177
//!Returns true if the effect has any influence on the output
178
bool willDoSomething() const {return true;};
180
virtual unsigned int numPassesNeeded() const { return 2;}
183
float getBaseShift() const { return baseShift;};
184
unsigned int getMode() const { return colourMode;};
190
Effect *makeEffect(unsigned int effectID);
192
Effect *makeEffect(const std::string &s);