Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mms3dpolygonmesh.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
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     //! maximum number of separate meshes
00062     #define MMS3DPM_ITEM_MAX 50
00063 
00064     //! mesh items
00065     MMS3DPM_ITEM pm_items[MMS3DPM_ITEM_MAX];
00066     int pm_items_cnt;
00067 
00068     //! vertex arrays used by mesh items
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     //! index arrays used by mesh items
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 /* MMS3DPOLYGONMESH_H_ */
00135 

Generated by doxygen