00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_MESH_GENERATOR_H__
00009 #define __SP_MESH_GENERATOR_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spMath.hpp"
00014 #include "Base/spMathRandomizer.hpp"
00015 #include "Base/spMeshBuffer.hpp"
00016 #include "SceneGraph/spSceneMesh.hpp"
00017
00018
00019 namespace sp
00020 {
00021 namespace scene
00022 {
00023
00024
00026 struct SP_EXPORT SMeshConstruct
00027 {
00028 SMeshConstruct();
00029 SMeshConstruct(
00030 s32 MeshSegments, f32 MeshRadius = 0.5f, bool MeshHasCap = true,
00031 const video::EShadingTypes DefShading = video::SHADING_GOURAUD
00032 );
00033 SMeshConstruct(
00034 s32 MeshSegments, f32 MeshRadiusInner, f32 MeshRadiusOuter, bool MeshHasCap = true,
00035 const video::EShadingTypes DefShading = video::SHADING_GOURAUD
00036 );
00037 SMeshConstruct(
00038 s32 MeshSegmentsVert, s32 MeshSegmentsHorz, f32 MeshRadiusInner, f32 MeshRadiusOuter,
00039 bool MeshHasCap = true, const video::EShadingTypes DefShading = video::SHADING_GOURAUD
00040 );
00041 SMeshConstruct(
00042 s32 MeshSegmentsVert, s32 MeshSegmentsHorz, f32 MeshRadiusInner, f32 MeshRadiusOuter,
00043 f32 SpiralRotationDegree, f32 SpiralRotationDistance, bool MeshHasCap = true,
00044 const video::EShadingTypes DefShading = video::SHADING_GOURAUD
00045 );
00046 ~SMeshConstruct();
00047
00048
00049
00050 void checkDefaultSegments(const EBasicMeshes Model, s32 &Segments);
00051 void checkDefaultShading(const EBasicMeshes Model);
00052
00053
00054
00055
00056 s32 SegmentsVert;
00057 s32 SegmentsHorz;
00058 f32 RadiusInner;
00059 f32 RadiusOuter;
00060 bool HasCap;
00061 video::EShadingTypes Shading;
00062
00063
00064 f32 RotationDegree;
00065 f32 RotationDistance;
00066
00067
00068
00069 };
00070
00071
00072 namespace MeshGenerator
00073 {
00074
00084 SP_EXPORT void createMesh(
00085 video::MeshBuffer &Surface, const EBasicMeshes Model, SMeshConstruct Construct = SMeshConstruct()
00086 );
00087
00088 SP_EXPORT void createCube (video::MeshBuffer &Surface, f32 Radius, s32 SegmentsVert, s32 SegmentsHorz);
00089 SP_EXPORT void createCone (video::MeshBuffer &Surface, f32 Radius = 0.5f, f32 Height = 1.0f, s32 Segments = 20, bool HasCap = true);
00090 SP_EXPORT void createCylinder (video::MeshBuffer &Surface, f32 Radius = 0.5f, f32 Height = 1.0f, s32 Segments = 20, bool HasCap = true);
00091
00092 SP_EXPORT void createSphere (video::MeshBuffer &Surface, f32 Radius = 0.5f, s32 Segments = 10);
00093 SP_EXPORT void createIcoSphere (video::MeshBuffer &Surface, f32 Radius = 0.5f, s32 Segments = 3);
00094 SP_EXPORT void createTorus (video::MeshBuffer &Surface, f32 RadiusOuter = 0.5f, f32 RadiusInner = 0.25f, s32 Segments = 10);
00095 SP_EXPORT void createTorusknot (video::MeshBuffer &Surface, f32 RadiusOuter = 0.5f, f32 RadiusInner = 0.25f, s32 Segments = 10);
00096 SP_EXPORT void createSpiral (video::MeshBuffer &Surface, f32 RadiusOuter = 0.5f, f32 RadiusInner = 0.25f, f32 TwirlDegree = 360.0f, f32 TwirlDistance = 1.0f, s32 Segments = 10, bool HasCap = true);
00097 SP_EXPORT void createPipe (video::MeshBuffer &Surface, f32 RadiusOuter = 0.5f, f32 RadiusInner = 0.25f, f32 Height = 1.0f, s32 Segments = 20, bool HasCap = true);
00098 SP_EXPORT void createPlane (video::MeshBuffer &Surface, s32 SegmentsVert, s32 SegmentsHorz);
00099 SP_EXPORT void createDisk (video::MeshBuffer &Surface, f32 RadiusOuter = 0.5f, f32 RadiusInner = 0.25f, s32 Segments = 20, bool HasHole = true);
00100 SP_EXPORT void createCuboctahedron (video::MeshBuffer &Surface);
00101 SP_EXPORT void createTetrahedron (video::MeshBuffer &Surface);
00102 SP_EXPORT void createOctahedron (video::MeshBuffer &Surface);
00103 SP_EXPORT void createDodecahedron (video::MeshBuffer &Surface);
00104 SP_EXPORT void createIcosahedron (video::MeshBuffer &Surface);
00105 SP_EXPORT void createTeapot (video::MeshBuffer &Surface);
00106
00107 SP_EXPORT void createWireCube(scene::Mesh &MeshObj, f32 Radius = 0.5f);
00108
00116 SP_EXPORT void createSkyBox(scene::Mesh &MeshObj, video::Texture* (&TextureList)[6], f32 Radius);
00117
00118 inline void createCube(video::MeshBuffer &Surface, f32 Radius = 0.5f, s32 Segments = 1)
00119 {
00120 createCube(Surface, Radius, Segments, Segments);
00121 }
00122
00123 inline void createPlane(video::MeshBuffer &Surface, s32 Segments = 1)
00124 {
00125 createPlane(Surface, Segments, Segments);
00126 }
00127
00128
00129
00130
00131 }
00132
00133 #if 1 //!!!
00134
00140 class SP_EXPORT BasicMeshGenerator
00141 {
00142
00143 public:
00144
00145 BasicMeshGenerator();
00146 ~BasicMeshGenerator();
00147
00148
00149
00154 void createSuperShape(Mesh* Object, const f32 ValueList[12], const s32 Segments = 20);
00155
00161 void getSuperShapeModel(const ESuperShapeModels Type, f32 ValueList[12]);
00162
00169 Mesh* createBezierPatch(
00170 const dim::vector3df AnchorPoints[4][4], const s32 Segments = 10, bool isFrontFace = true
00171 );
00172
00178 void createBezierPatchFace(
00179 Mesh* Mesh, const u32 Surface,
00180 const dim::vector3df AnchorPoints[4][4], const s32 Segments = 10, bool isFrontFace = true
00181 );
00182
00189 Mesh* createHeightField(const video::Texture* TexHeightMap, const s32 Segments);
00190
00191 private:
00192
00193
00194
00195 #ifdef SP_COMPILE_WITH_PRIMITIVE_SUPERSHAPE
00196 void createSuperShapeSurface(const f32 ValueList[12], const s32 Segments);
00197 f32 computeSuperShapeNextFrame(f32 m, f32 n1, f32 n2, f32 n3, f32 a, f32 b, f32 phi);
00198 #endif
00199
00200
00201
00202 Mesh* Mesh_;
00203 video::MeshBuffer* Surface_;
00204
00205 SMeshConstruct BuildConstruct_;
00206
00207 };
00208
00209 #endif
00210
00211
00212 }
00213
00214 }
00215
00216
00217 #endif
00218
00219
00220
00221