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
00029
00030
00031
00032
00033 #ifndef MMS3DPOLYGONMESH_H_
00034 #define MMS3DPOLYGONMESH_H_
00035
00036 #include "mmstools/mmstypes.h"
00037
00038 class MMS3DPolygonMesh {
00039 private:
00040
00041 typedef enum {
00042 MMS3DPM_TYPE_PRIMITIVES = 0,
00043 MMS3DPM_TYPE_RECTANGLE,
00044 MMS3DPM_TYPE_SPHERE,
00045 MMS3DPM_TYPE_TORUS,
00046 MMS3DPM_TYPE_CYLINDER
00047 } MMS3DPM_TYPE;
00048
00049 typedef float MMS3DPM_MESHID[8];
00050
00051 typedef struct {
00052 MMS3DPM_TYPE type;
00053 MMS3DPM_MESHID identifier;
00054 int vertices;
00055 int normals;
00056 int texcoords;
00057 int indices;
00058 } MMS3DPM_ITEM;
00059
00060
00061
00062 #define MMS3DPM_ITEM_MAX 50
00063
00064
00065 MMS3DPM_ITEM pm_items[MMS3DPM_ITEM_MAX];
00066 int pm_items_cnt;
00067
00068
00069 MMS_VERTEX_ARRAY vabuf[MMS3DPM_ITEM_MAX * 3];
00070 MMS_VERTEX_ARRAY *varrays[MMS3DPM_ITEM_MAX * 3 + 1];
00071 int varrays_cnt;
00072
00073
00074 MMS_INDEX_ARRAY iabuf[MMS3DPM_ITEM_MAX];
00075 MMS_INDEX_ARRAY *iarrays[MMS3DPM_ITEM_MAX + 1];
00076 int iarrays_cnt;
00077
00078
00079 void genRectangle(float width, float height,
00080 MMS_VERTEX_ARRAY *vertices,
00081 MMS_VERTEX_ARRAY *normals,
00082 MMS_VERTEX_ARRAY *texcoords,
00083 MMS_INDEX_ARRAY *indices);
00084
00085 void genSphere(int numSlices, float radius,
00086 MMS_VERTEX_ARRAY *vertices,
00087 MMS_VERTEX_ARRAY *normals,
00088 MMS_VERTEX_ARRAY *texcoords,
00089 MMS_INDEX_ARRAY *indices);
00090
00091 void genTorus(int numwraps, int numperwrap, float majorradius, float minorradius,
00092 MMS_VERTEX_ARRAY *vertices,
00093 MMS_VERTEX_ARRAY *normals,
00094 MMS_VERTEX_ARRAY *texcoords,
00095 MMS_INDEX_ARRAY *indices);
00096
00097 void genCylinder(int numSlices, float height, float radius,
00098 MMS_VERTEX_ARRAY *vertices,
00099 MMS_VERTEX_ARRAY *normals,
00100 MMS_VERTEX_ARRAY *texcoords,
00101 MMS_INDEX_ARRAY *indices);
00102
00103
00104 int findPMItem(MMS3DPM_TYPE type, MMS3DPM_MESHID identifier, int *vertices, int *normals, int *texcoords, int *indices);
00105
00106 int newPMItem(MMS3DPM_TYPE type, MMS3DPM_MESHID identifier, int *vertices, int *normals, int *texcoords, int *indices);
00107
00108 int newPMItem(MMS3DPM_TYPE type, MMS3DPM_MESHID identifier,
00109 MMS_VERTEX_ARRAY *vertices, MMS_VERTEX_ARRAY *normals,
00110 MMS_VERTEX_ARRAY *texcoords, MMS_INDEX_ARRAY *indices);
00111
00112 public:
00113
00114 MMS3DPolygonMesh();
00115
00116 void getArrays(MMS_VERTEX_ARRAY ***varrays, MMS_INDEX_ARRAY ***iarrays);
00117
00118 bool setPrimitives(string id, MMS_VERTEX_ARRAY *vertices, MMS_VERTEX_ARRAY *normals,
00119 MMS_VERTEX_ARRAY *texcoords, MMS_INDEX_ARRAY *indices);
00120
00121 bool getPrimitives(string id, int *vertices, int *normals, int *texcoords, int *indices);
00122
00123 bool genRectangle(float width, float height, int *vertices, int *normals, int *texcoords, int *indices);
00124
00125 bool genSphere(int numSlices, float radius, int *vertices, int *normals, int *texcoords, int *indices);
00126
00127 bool genTorus(int numwraps, int numperwrap, float majorradius, float minorradius,
00128 int *vertices, int *normals, int *texcoords, int *indices);
00129
00130 bool genCylinder(int numSlices, float height, float radius,
00131 int *vertices, int *normals, int *texcoords, int *indices);
00132 };
00133
00134 #endif
00135