added 3dengfx into the repo, probably not the correct version for this
[summerhack] / src / 3dengfx / libs / lib3ds / mesh.h
1 /* -*- c -*- */
2 #ifndef INCLUDED_LIB3DS_MESH_H
3 #define INCLUDED_LIB3DS_MESH_H
4 /*
5  * The 3D Studio File Format Library
6  * Copyright (C) 1996-2001 by J.E. Hoffmann <je-h@gmx.net>
7  * All rights reserved.
8  *
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.
13  *
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.
18  *
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.
22  *
23  * $Id: mesh.h,v 1.16 2004/12/31 16:17:15 reed Exp $
24  */
25
26 #ifndef INCLUDED_LIB3DS_TYPES_H
27 #include <lib3ds/types.h>
28 #endif
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*!
35  * Triangular mesh point
36  * \ingroup mesh
37  */
38 typedef struct _Lib3dsPoint {
39     Lib3dsVector pos;
40 } Lib3dsPoint;
41
42 /*!
43  * Triangular mesh face
44  * \ingroup mesh
45  * \sa Lib3dsFaceFlag
46  */
47 struct _Lib3dsFace {
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 */
53     Lib3dsVector normal;
54 };
55
56
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 */
59 typedef enum {
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*/
71 } Lib3dsFaceFlag;
72
73 /*!
74  * Triangular mesh box mapping settings
75  * \ingroup mesh
76  */
77 struct _Lib3dsBoxMap {
78     char front[64];
79     char back[64];
80     char left[64];
81     char right[64];
82     char top[64];
83     char bottom[64];
84 };
85
86 /*!
87  * Lib3dsMapData maptype
88  * \ingroup tracks
89  */
90 typedef enum {
91   LIB3DS_MAP_NONE        =0xFFFF,
92   LIB3DS_MAP_PLANAR      =0,
93   LIB3DS_MAP_CYLINDRICAL =1,
94   LIB3DS_MAP_SPHERICAL   =2
95 } Lib3dsMapType;
96
97 /*!
98  * Triangular mesh texture mapping data
99  * \ingroup mesh
100  */
101 struct _Lib3dsMapData {
102     Lib3dsWord maptype;
103     Lib3dsVector pos;
104     Lib3dsMatrix matrix;
105     Lib3dsFloat scale;
106     Lib3dsFloat tile[2];
107     Lib3dsFloat planar_size[2];
108     Lib3dsFloat cylinder_height;
109 };
110
111 /*!
112  * Triangular mesh object
113  * \ingroup mesh
114  */
115 struct _Lib3dsMesh {
116     Lib3dsUserData user;        /*! Arbitrary user data */
117     Lib3dsMesh *next;
118     char name[64];              /*! Mesh name */
119     Lib3dsByte color;
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;
131 }; 
132
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);
148
149 #ifdef __cplusplus
150 }
151 #endif
152 #endif
153