00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _SPHEREMESH_H_
00011 #define _SPHEREMESH_H_
00012
00013 #include <celmath/vecmath.h>
00014 #include <celmath/frustum.h>
00015 #include <celengine/mesh.h>
00016 #include <celengine/dispmap.h>
00017
00023 class SphereMesh
00024 {
00025 public:
00026 SphereMesh(float radius, int _nRings, int _nSlices);
00027 SphereMesh(Vec3f size, int _nRings, int _nSlices);
00028 SphereMesh(Vec3f size,
00029 const DisplacementMap& dispmap,
00030 float height = 1.0f);
00031 SphereMesh(Vec3f size,
00032 int _nRings, int _nSlices,
00033 DisplacementMapFunc func,
00034 void* info);
00035 ~SphereMesh();
00036
00038 Mesh* convertToMesh() const;
00039
00040 private:
00041 void createSphere(float radius, int nRings, int nSlices);
00042 void generateNormals();
00043 void scale(Vec3f);
00044 void fixNormals();
00045 void displace(const DisplacementMap& dispmap, float height);
00046 void displace(DisplacementMapFunc func, void* info);
00047
00048 int nRings;
00049 int nSlices;
00050 int nVertices;
00051 float* vertices;
00052 float* normals;
00053 float* texCoords;
00054 float* tangents;
00055 int nIndices;
00056 unsigned short* indices;
00057 };
00058
00059 #endif // _SPHEREMESH_H_