00001 #ifndef GREENSPACE_H
00002 #define GREENSPACE_H
00003
00004 #include <vrs/environment/config.h>
00005 #include <vrs/shape.h>
00006 #include <vrs/image/image.h>
00007 #include <vrs/distantlight.h>
00008 #include <vrs/opengl/backgroundgl.h>
00009
00010 namespace VRS {
00011 template<typename T> class Iterator;
00012 class Facet;
00013 class Texture2DGL;
00014 class PolygonSet;
00015 class ImageTexture2DGL;
00016 }
00017
00018 namespace EnvironmentRenderer {
00019
00025 class VRS_ENV_API GreenSpace : public VRS::Shape {
00026 public:
00072 GreenSpace(VRS::SO<VRS::Iterator<VRS::SO<VRS::Facet> > > surface,
00073 VRS::SO<VRS::Iterator<VRS::SO<VRS::Image> > > textures = NULL,
00074 double grassLength = 1.0,
00075 double grassDensity = 1.0,
00076 double angle = 100.0,
00077 unsigned int fans = 1,
00078 unsigned int lamellas = 1,
00079 double aspectRatio = 1.0,
00080 double topPadding = 0.0,
00081 double alphaTestValue = 0.5,
00082 double displayDistance = 100.0);
00083
00084
00087
00090 VRS::SO<VRS::Iterator<VRS::SO<VRS::Facet> > > getSurface() const;
00091 void setSurface(VRS::SO<VRS::Iterator<VRS::SO<VRS::Facet> > > surface);
00092
00098 VRS::SO<VRS::Iterator<VRS::SO<VRS::Image> > > getTextures() const;
00099 void setTextures(VRS::SO<VRS::Iterator<VRS::SO<VRS::Image> > > textures);
00100
00102 double getGrassDensity() const;
00103 void setGrassDensity(double density);
00104
00106 double getGrassLength() const;
00107 void setGrassLength(double density);
00108
00110 double getAngle() const;
00111 void setAngle(double angle);
00112
00115 void setFans(unsigned int fans);
00116 unsigned int getFans() const;
00117
00120 void setLamellas(unsigned int lamellas);
00121 unsigned int getLamellas() const;
00122
00124 void setAspectRatio(double aspectRatio);
00125 double getAspectRatio() const;
00126
00128 void setTopPadding(double aspectRatio);
00129 double getTopPadding() const;
00130
00132 void setAlphaTestValue(double alphaTestValue);
00133 double getAlphaTestValue() const;
00134
00136 void setDisplayDistance(double distance);
00137 double getDisplayDistance() const;
00138
00151 static VRS::SO<VRS::Image> getGrassTexture(unsigned int texWidth, unsigned int texHeight,
00152 double surfaceWidth, double surfaceLength,
00153 VRS::SO<GreenSpace> greenSpace,
00154 VRS::SO<VRS::DistantLight> sun = new VRS::DistantLight(VRS::Vector(0.0, 1.0, 0.0), VRS::Color::white, 1.0),
00155 VRS::SO<VRS::BackgroundGL> background = new VRS::BackgroundGL());
00156
00158 inline virtual VRS::Bounds boundingBox() const;
00159
00160
00161
00162 bool needsUpdate() const;
00163 void setBoundingBox(const VRS::Bounds &bounds);
00164
00165 VRS_TYPEINFO(GreenSpace, VRS::Shape);
00166 VRS_SERIALIZABLE(GreenSpace);
00167
00168 private:
00169
00170 GreenSpace();
00171
00172
00173
00174 VRS::SO<VRS::Iterator<VRS::SO<VRS::Facet> > > m_surface;
00175 VRS::SO<VRS::Iterator<VRS::SO<VRS::Image> > > m_grassTextures;
00176
00177 double m_grassDensity;
00178 double m_grassLength;
00179 double m_angle;
00180 double m_aspectRatio;
00181 double m_topPadding;
00182 double m_alphaTestValue;
00183 double m_displayDistance;
00184 unsigned int m_fans;
00185 unsigned int m_lamellas;
00186
00187 mutable bool m_needsUpdate;
00188
00189 VRS::Bounds m_boundingBox;
00190 };
00191
00192
00193 inline VRS::SO<VRS::Iterator<VRS::SO<VRS::Facet> > > GreenSpace::getSurface() const
00194 {
00195 return m_surface;
00196 }
00197
00198 inline VRS::SO<VRS::Iterator<VRS::SO<VRS::Image> > > GreenSpace::getTextures() const {
00199 return m_grassTextures;
00200 }
00201
00202 inline VRS::Bounds GreenSpace::boundingBox() const {
00203 return m_boundingBox;
00204 }
00205
00206 inline void GreenSpace::setBoundingBox(const VRS::Bounds &bounds)
00207 {
00208 m_boundingBox = bounds;
00209 }
00210
00211 inline double GreenSpace::getGrassDensity() const {
00212 return m_grassDensity;
00213 }
00214
00215 inline double GreenSpace::getGrassLength() const {
00216 return m_grassLength;
00217 }
00218
00219 inline double GreenSpace::getAngle() const {
00220 return m_angle;
00221 }
00222
00223 inline unsigned int GreenSpace::getFans() const
00224 {
00225 return m_fans;
00226 }
00227
00228 inline unsigned int GreenSpace::getLamellas() const
00229 {
00230 return m_lamellas;
00231 }
00232
00233 inline double GreenSpace::getAspectRatio() const
00234 {
00235 return m_aspectRatio;
00236 }
00237
00238 inline double GreenSpace::getTopPadding() const
00239 {
00240 return m_topPadding;
00241 }
00242
00243 inline double GreenSpace::getAlphaTestValue() const
00244 {
00245 return m_alphaTestValue;
00246 }
00247
00248 inline double GreenSpace::getDisplayDistance() const
00249 {
00250 return m_displayDistance;
00251 }
00252
00253 }
00254
00255 #endif // GREENSPACE_H
00256