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 #ifndef GLHEIGHTFIELD_H
00029 #define GLHEIGHTFIELD_H
00030
00031 #include "glscene.h"
00032 #include "glgeometricobject.h"
00033 #include "glsurface.h"
00034 #include "glimage.h"
00035 #include "smltgl.h"
00036
00040 namespace GLScene
00041 {
00042
00043 class GLHeightField: public GLGeometricObject, public GLSurfaceGenerator, public GLFieldHolder
00044 {
00045 float* heightMap;
00046 bool generated;
00047 GLSurface surface;
00048 GLsizei imageWidth, imageHeight;
00049
00050 public:
00051 static std::string refvalName;
00052 static std::string imageName;
00053 static std::string widthName;
00054 static std::string lengthName;
00055 static std::string heightName;
00056
00057 SML_TAG(heightfield)
00058
00059 GLField<GLuint> referenceValue;
00060 GLField<GLImage> image;
00061 GLField<GLfloat> width;
00062 GLField<GLfloat> length;
00063 GLField<GLfloat> height;
00064
00065 GLHeightField();
00066 virtual ~GLHeightField();
00067
00068 virtual bool intersection( GLGeometricObject* ){ return false; };
00069 virtual bool inclusion( GLGeometricObject* ){ return false; };
00070
00072 virtual FieldBasePtr getFieldByIndex( short index );
00073
00076 void getVertecies(const GLfloat u, const GLuint nOfV, GLfloat* const verts3) const;
00078 void getNormals(const GLfloat u, const GLuint nOfN, GLfloat* const normals3) const;
00079
00080 virtual void render();
00081
00082 private:
00083
00085 void generate();
00086
00087 float getHeightAt(const float& u, const float& v) const;
00088
00089 };
00090
00091 };
00092 #endif