1 /* -*- c -*- */
2 #ifndef INCLUDED_LIB3DS_TYPES_H
3 #define INCLUDED_LIB3DS_TYPES_H
4 /*
5  * The 3D Studio File Format Library
6  * Copyright (C) 1996-2007 by Jan Eric Kyprianidis <www.kyprianidis.com>
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: types.h,v 1.25 2007/06/21 08:36:41 jeh Exp $
24  */
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifdef _MSC_VER
30 #ifdef LIB3DS_EXPORTS
31 #define LIB3DSAPI __declspec(dllexport)
32 #else
33 #define LIB3DSAPI __declspec(dllimport)
34 #endif
35 #else
36 #define LIB3DSAPI
37 #endif
38 
39 #define LIB3DS_TRUE 1
40 #define LIB3DS_FALSE 0
41 
42 #ifdef _MSC_VER
43 typedef __int32 Lib3dsBool;
44 typedef unsigned __int8 Lib3dsByte;
45 typedef unsigned __int16 Lib3dsWord;
46 typedef unsigned __int32 Lib3dsDword;
47 typedef signed __int8 Lib3dsIntb;
48 typedef signed __int16 Lib3dsIntw;
49 typedef signed __int16 Lib3dsIntd;
50 #else
51 #include <stdint.h>
52 typedef int32_t Lib3dsBool;
53 typedef uint8_t Lib3dsByte;
54 typedef uint16_t Lib3dsWord;
55 typedef uint32_t Lib3dsDword;
56 typedef int8_t Lib3dsIntb;
57 typedef int16_t Lib3dsIntw;
58 typedef int32_t Lib3dsIntd;
59 #endif
60 
61 typedef float Lib3dsFloat;
62 typedef double Lib3dsDouble;
63 
64 typedef float Lib3dsVector[3];
65 typedef float Lib3dsTexel[2];
66 typedef float Lib3dsQuat[4];
67 typedef float Lib3dsMatrix[4][4];
68 typedef float Lib3dsRgb[3];
69 typedef float Lib3dsRgba[4];
70 
71 #define LIB3DS_EPSILON (1e-8)
72 #define LIB3DS_PI 3.14159265358979323846
73 #define LIB3DS_TWOPI (2.0*LIB3DS_PI)
74 #define LIB3DS_HALFPI (LIB3DS_PI/2.0)
75 #define LIB3DS_RAD_TO_DEG(x) ((180.0/LIB3DS_PI)*(x))
76 #define LIB3DS_DEG_TO_RAD(x) ((LIB3DS_PI/180.0)*(x))
77 
78 #include <stdio.h>
79 
80 #ifdef _DEBUG
81   #ifndef ASSERT
82   #include <assert.h>
83   #define ASSERT(__expr) assert(__expr)
84   #endif
85   #define LIB3DS_ERROR_LOG \
86     {printf("\t***LIB3DS_ERROR_LOG*** %s : %d\n", __FILE__, __LINE__);}
87 #else
88   #ifndef ASSERT
89   #define ASSERT(__expr)
90   #endif
91   #define LIB3DS_ERROR_LOG
92 #endif
93 
94 typedef struct Lib3dsIo Lib3dsIo;
95 typedef struct Lib3dsFile Lib3dsFile;
96 typedef struct Lib3dsBackground Lib3dsBackground;
97 typedef struct Lib3dsAtmosphere Lib3dsAtmosphere;
98 typedef struct Lib3dsShadow Lib3dsShadow;
99 typedef struct Lib3dsViewport Lib3dsViewport;
100 typedef struct Lib3dsMaterial Lib3dsMaterial;
101 typedef struct Lib3dsFace Lib3dsFace;
102 typedef struct Lib3dsBoxMap Lib3dsBoxMap;
103 typedef struct Lib3dsMapData Lib3dsMapData;
104 typedef struct Lib3dsMesh Lib3dsMesh;
105 typedef struct Lib3dsCamera Lib3dsCamera;
106 typedef struct Lib3dsLight Lib3dsLight;
107 typedef struct Lib3dsBoolKey Lib3dsBoolKey;
108 typedef struct Lib3dsBoolTrack Lib3dsBoolTrack;
109 typedef struct Lib3dsLin1Key Lib3dsLin1Key;
110 typedef struct Lib3dsLin1Track Lib3dsLin1Track;
111 typedef struct Lib3dsLin3Key Lib3dsLin3Key;
112 typedef struct Lib3dsLin3Track Lib3dsLin3Track;
113 typedef struct Lib3dsQuatKey Lib3dsQuatKey;
114 typedef struct Lib3dsQuatTrack Lib3dsQuatTrack;
115 typedef struct Lib3dsMorphKey Lib3dsMorphKey;
116 typedef struct Lib3dsMorphTrack Lib3dsMorphTrack;
117 
118 typedef enum Lib3dsNodeTypes {
119   LIB3DS_UNKNOWN_NODE =0,
120   LIB3DS_AMBIENT_NODE =1,
121   LIB3DS_OBJECT_NODE  =2,
122   LIB3DS_CAMERA_NODE  =3,
123   LIB3DS_TARGET_NODE  =4,
124   LIB3DS_LIGHT_NODE   =5,
125   LIB3DS_SPOT_NODE    =6
126 } Lib3dsNodeTypes;
127 
128 typedef struct Lib3dsNode Lib3dsNode;
129 
130 typedef enum Lib3dsObjectFlags {
131   LIB3DS_OBJECT_HIDDEN          =0x01,
132   LIB3DS_OBJECT_VIS_LOFTER      =0x02,
133   LIB3DS_OBJECT_DOESNT_CAST     =0x04,
134   LIB3DS_OBJECT_MATTE           =0x08,
135   LIB3DS_OBJECT_DONT_RCVSHADOW  =0x10,
136   LIB3DS_OBJECT_FAST            =0x20,
137   LIB3DS_OBJECT_FROZEN          =0x40
138 } Lib3dsObjectFlags;
139 
140 typedef union Lib3dsUserData {
141     void *p;
142     Lib3dsIntd i;
143     Lib3dsDword d;
144     Lib3dsFloat f;
145     Lib3dsMaterial *material;
146     Lib3dsMesh *mesh;
147     Lib3dsCamera *camera;
148     Lib3dsLight *light;
149     Lib3dsNode *node;
150 } Lib3dsUserData;
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 #endif
156