2 #ifndef INCLUDED_LIB3DS_MESH_H
3 #define INCLUDED_LIB3DS_MESH_H
5 * The 3D Studio File Format Library
6 * Copyright (C) 1996-2001 by J.E. Hoffmann <je-h@gmx.net>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 * License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * $Id: mesh.h,v 1.16 2004/12/31 16:17:15 reed Exp $
26 #ifndef INCLUDED_LIB3DS_TYPES_H
27 #include <lib3ds/types.h>
35 * Triangular mesh point
38 typedef struct _Lib3dsPoint {
43 * Triangular mesh face
48 Lib3dsUserData user; /*! Arbitrary user data */
49 char material[64]; /*! Material name */
50 Lib3dsWord points[3]; /*! Indices into mesh points list */
51 Lib3dsWord flags; /*! See Lib3dsFaceFlag, below */
52 Lib3dsDword smoothing; /*! Bitmask; each bit identifies a group */
57 /*! Meaning of _Lib3dsFace::flags. ABC are points of the current face (A: is
58 1st vertex, B is 2nd vertex, C is 3rd vertex */
60 LIB3DS_FACE_FLAG_VIS_AC = 0x1, /*!< Bit 0: Edge visibility AC */
61 LIB3DS_FACE_FLAG_VIS_BC = 0x2, /*!< Bit 1: Edge visibility BC */
62 LIB3DS_FACE_FLAG_VIS_AB = 0x4, /*!< Bit 2: Edge visibility AB */
63 LIB3DS_FACE_FLAG_WRAP_U = 0x8, /*!< Bit 3: Face is at tex U wrap seam */
64 LIB3DS_FACE_FLAG_WRAP_V = 0x10, /*!< Bit 4: Face is at tex V wrap seam */
65 LIB3DS_FACE_FLAG_UNK7 = 0x80, /* Bit 5-8: Unused ? */
66 LIB3DS_FACE_FLAG_UNK10 = 0x400, /* Bit 9-10: Random ? */
67 /* Bit 11-12: Unused ? */
68 LIB3DS_FACE_FLAG_SELECT_3 = (1<<13), /*!< Bit 13: Selection of the face in selection 3*/
69 LIB3DS_FACE_FLAG_SELECT_2 = (1<<14), /*!< Bit 14: Selection of the face in selection 2*/
70 LIB3DS_FACE_FLAG_SELECT_1 = (1<<15) /*!< Bit 15: Selection of the face in selection 1*/
74 * Triangular mesh box mapping settings
77 struct _Lib3dsBoxMap {
87 * Lib3dsMapData maptype
91 LIB3DS_MAP_NONE =0xFFFF,
93 LIB3DS_MAP_CYLINDRICAL =1,
94 LIB3DS_MAP_SPHERICAL =2
98 * Triangular mesh texture mapping data
101 struct _Lib3dsMapData {
107 Lib3dsFloat planar_size[2];
108 Lib3dsFloat cylinder_height;
112 * Triangular mesh object
116 Lib3dsUserData user; /*! Arbitrary user data */
118 char name[64]; /*! Mesh name */
120 Lib3dsMatrix matrix; /*! Transformation matrix for mesh data */
121 Lib3dsDword points; /*! Number of points in point list */
122 Lib3dsPoint *pointL; /*! Point list */
123 Lib3dsDword flags; /*! Number of flags in per-point flags list */
124 Lib3dsWord *flagL; /*! Per-point flags list */
125 Lib3dsDword texels; /*! Number of U-V texel coordinates */
126 Lib3dsTexel *texelL; /*! U-V texel coordinates */
127 Lib3dsDword faces; /*! Number of faces in face list */
128 Lib3dsFace *faceL; /*! Face list */
129 Lib3dsBoxMap box_map;
130 Lib3dsMapData map_data;
133 extern LIB3DSAPI Lib3dsMesh* lib3ds_mesh_new(const char *name);
134 extern LIB3DSAPI void lib3ds_mesh_free(Lib3dsMesh *mesh);
135 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_new_point_list(Lib3dsMesh *mesh, Lib3dsDword points);
136 extern LIB3DSAPI void lib3ds_mesh_free_point_list(Lib3dsMesh *mesh);
137 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_new_flag_list(Lib3dsMesh *mesh, Lib3dsDword flags);
138 extern LIB3DSAPI void lib3ds_mesh_free_flag_list(Lib3dsMesh *mesh);
139 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_new_texel_list(Lib3dsMesh *mesh, Lib3dsDword texels);
140 extern LIB3DSAPI void lib3ds_mesh_free_texel_list(Lib3dsMesh *mesh);
141 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_new_face_list(Lib3dsMesh *mesh, Lib3dsDword flags);
142 extern LIB3DSAPI void lib3ds_mesh_free_face_list(Lib3dsMesh *mesh);
143 extern LIB3DSAPI void lib3ds_mesh_bounding_box(Lib3dsMesh *mesh, Lib3dsVector min, Lib3dsVector max);
144 extern LIB3DSAPI void lib3ds_mesh_calculate_normals(Lib3dsMesh *mesh, Lib3dsVector *normalL);
145 extern LIB3DSAPI void lib3ds_mesh_dump(Lib3dsMesh *mesh);
146 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_read(Lib3dsMesh *mesh, Lib3dsIo *io);
147 extern LIB3DSAPI Lib3dsBool lib3ds_mesh_write(Lib3dsMesh *mesh, Lib3dsIo *io);