1 | /********************************************************************** |
---|
2 | * |
---|
3 | * MilkShape 3D Model Import/Export API |
---|
4 | * |
---|
5 | * May 10 2000, Mete Ciragan, chUmbaLum sOft |
---|
6 | * |
---|
7 | **********************************************************************/ |
---|
8 | |
---|
9 | #ifndef __MSLIB_H__ |
---|
10 | #define __MSLIB_H__ |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | #ifdef MSLIB_EXPORTS |
---|
15 | #define MSLIB_API __declspec(dllexport) |
---|
16 | #else |
---|
17 | #define MSLIB_API __declspec(dllimport) |
---|
18 | #endif /* MSLIB_EXPORTS */ |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | #ifdef WIN32 |
---|
23 | #include <pshpack1.h> |
---|
24 | #endif /* WIN32 */ |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif /* __cplusplus */ |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | /********************************************************************** |
---|
35 | * |
---|
36 | * Constants |
---|
37 | * |
---|
38 | **********************************************************************/ |
---|
39 | |
---|
40 | #define MS_MAX_NAME 32 |
---|
41 | #define MS_MAX_PATH 256 |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | /********************************************************************** |
---|
46 | * |
---|
47 | * Types |
---|
48 | * |
---|
49 | **********************************************************************/ |
---|
50 | |
---|
51 | #ifndef byte |
---|
52 | typedef unsigned char byte; |
---|
53 | #endif /* byte */ |
---|
54 | |
---|
55 | #ifndef word |
---|
56 | typedef unsigned short word; |
---|
57 | #endif /* word */ |
---|
58 | |
---|
59 | typedef float msVec4[4]; |
---|
60 | typedef float msVec3[3]; |
---|
61 | typedef float msVec2[2]; |
---|
62 | |
---|
63 | /* msFlag */ |
---|
64 | typedef enum { |
---|
65 | eSelected = 1, eSelected2 = 2, eHidden = 4, eDirty = 8, eAveraged = 16, eKeepVertex = 32, eSphereMap = 0x80, eHasAlpha = 0x40 |
---|
66 | } msFlag; |
---|
67 | |
---|
68 | /* msVertex */ |
---|
69 | typedef struct msVertex |
---|
70 | { |
---|
71 | byte nFlags; |
---|
72 | msVec3 Vertex; |
---|
73 | float u, v; |
---|
74 | char nBoneIndex; |
---|
75 | } msVertex; |
---|
76 | |
---|
77 | /* msVertexEx */ |
---|
78 | typedef struct msVertexEx |
---|
79 | { |
---|
80 | char nBoneIndices[3]; |
---|
81 | byte nBoneWeights[3]; |
---|
82 | } msVertexEx; |
---|
83 | |
---|
84 | /* msTriangle */ |
---|
85 | typedef struct msTriangle |
---|
86 | { |
---|
87 | word nFlags; |
---|
88 | word nVertexIndices[3]; |
---|
89 | word nNormalIndices[3]; |
---|
90 | msVec3 Normal; |
---|
91 | byte nSmoothingGroup; |
---|
92 | } msTriangle; |
---|
93 | |
---|
94 | /* msTriangleEx */ |
---|
95 | typedef struct msTriangleEx |
---|
96 | { |
---|
97 | msVec3 Normals[3]; |
---|
98 | msVec2 TexCoords[3]; |
---|
99 | } msTriangleEx; |
---|
100 | |
---|
101 | /* msMesh */ |
---|
102 | typedef struct msMesh |
---|
103 | { |
---|
104 | byte nFlags; |
---|
105 | char szName[MS_MAX_NAME]; |
---|
106 | char nMaterialIndex; |
---|
107 | |
---|
108 | word nNumVertices; |
---|
109 | word nNumAllocedVertices; |
---|
110 | msVertex* pVertices; |
---|
111 | |
---|
112 | word nNumNormals; |
---|
113 | word nNumAllocedNormals; |
---|
114 | msVec3* pNormals; |
---|
115 | |
---|
116 | word nNumTriangles; |
---|
117 | word nNumAllocedTriangles; |
---|
118 | msTriangle* pTriangles; |
---|
119 | |
---|
120 | char* pszComment; |
---|
121 | msVertexEx *pVertexExs; |
---|
122 | msTriangleEx *pTriangleExs; |
---|
123 | } msMesh; |
---|
124 | |
---|
125 | /* msMaterial */ |
---|
126 | typedef struct msMaterial |
---|
127 | { |
---|
128 | int nFlags; |
---|
129 | char szName[MS_MAX_NAME]; |
---|
130 | msVec4 Ambient; |
---|
131 | msVec4 Diffuse; |
---|
132 | msVec4 Specular; |
---|
133 | msVec4 Emissive; |
---|
134 | float fShininess; |
---|
135 | float fTransparency; |
---|
136 | char szDiffuseTexture[MS_MAX_PATH]; |
---|
137 | char szAlphaTexture[MS_MAX_PATH]; |
---|
138 | int nName; |
---|
139 | char* pszComment; |
---|
140 | } msMaterial; |
---|
141 | |
---|
142 | /* msPositionKey */ |
---|
143 | typedef struct msPositionKey |
---|
144 | { |
---|
145 | float fTime; |
---|
146 | msVec3 Position; |
---|
147 | } msPositionKey; |
---|
148 | |
---|
149 | /* msRotationKey */ |
---|
150 | typedef struct msRotationKey |
---|
151 | { |
---|
152 | float fTime; |
---|
153 | msVec3 Rotation; |
---|
154 | } msRotationKey; |
---|
155 | |
---|
156 | /* msBone */ |
---|
157 | typedef struct msBone |
---|
158 | { |
---|
159 | int nFlags; |
---|
160 | char szName[MS_MAX_NAME]; |
---|
161 | char szParentName[MS_MAX_NAME]; |
---|
162 | msVec3 Position; |
---|
163 | msVec3 Rotation; |
---|
164 | |
---|
165 | int nNumPositionKeys; |
---|
166 | int nNumAllocedPositionKeys; |
---|
167 | msPositionKey* pPositionKeys; |
---|
168 | |
---|
169 | int nNumRotationKeys; |
---|
170 | int nNumAllocedRotationKeys; |
---|
171 | msRotationKey* pRotationKeys; |
---|
172 | char* pszComment; |
---|
173 | } msBone; |
---|
174 | |
---|
175 | /* msModel */ |
---|
176 | typedef struct msModel |
---|
177 | { |
---|
178 | int nNumMeshes; |
---|
179 | int nNumAllocedMeshes; |
---|
180 | msMesh* pMeshes; |
---|
181 | |
---|
182 | int nNumMaterials; |
---|
183 | int nNumAllocedMaterials; |
---|
184 | msMaterial* pMaterials; |
---|
185 | |
---|
186 | int nNumBones; |
---|
187 | int nNumAllocedBones; |
---|
188 | msBone* pBones; |
---|
189 | |
---|
190 | int nFrame; |
---|
191 | int nTotalFrames; |
---|
192 | |
---|
193 | msVec3 Position; |
---|
194 | msVec3 Rotation; |
---|
195 | |
---|
196 | msVec3 CameraPosition; |
---|
197 | msVec2 CameraRotationXY; |
---|
198 | |
---|
199 | char* pszComment; |
---|
200 | } msModel; |
---|
201 | |
---|
202 | |
---|
203 | |
---|
204 | /********************************************************************** |
---|
205 | * |
---|
206 | * MilkShape 3D Interface |
---|
207 | * |
---|
208 | **********************************************************************/ |
---|
209 | |
---|
210 | /********************************************************************** |
---|
211 | * msModel |
---|
212 | **********************************************************************/ |
---|
213 | |
---|
214 | MSLIB_API void msModel_Destroy (msModel *pModel); |
---|
215 | |
---|
216 | MSLIB_API int msModel_GetMeshCount (msModel *pModel); |
---|
217 | MSLIB_API int msModel_AddMesh (msModel *pModel); |
---|
218 | MSLIB_API msMesh* msModel_GetMeshAt (msModel *pModel, int nIndex); |
---|
219 | MSLIB_API int msModel_FindMeshByName (msModel *pModel, const char *szName); |
---|
220 | |
---|
221 | MSLIB_API int msModel_GetMaterialCount (msModel *pModel); |
---|
222 | MSLIB_API int msModel_AddMaterial (msModel *pModel); |
---|
223 | MSLIB_API msMaterial* msModel_GetMaterialAt (msModel *pModel, int nIndex); |
---|
224 | MSLIB_API int msModel_FindMaterialByName (msModel *pModel, const char *szName); |
---|
225 | |
---|
226 | MSLIB_API int msModel_GetBoneCount (msModel *pModel); |
---|
227 | MSLIB_API int msModel_AddBone (msModel *pModel); |
---|
228 | MSLIB_API msBone* msModel_GetBoneAt (msModel *pModel, int nIndex); |
---|
229 | MSLIB_API int msModel_FindBoneByName (msModel *pModel, const char *szName); |
---|
230 | |
---|
231 | MSLIB_API int msModel_SetFrame (msModel *pModel, int nFrame); |
---|
232 | MSLIB_API int msModel_GetFrame (msModel *pModel); |
---|
233 | MSLIB_API int msModel_SetTotalFrames (msModel *pModel, int nTotalFrames); |
---|
234 | MSLIB_API int msModel_GetTotalFrames (msModel *pModel); |
---|
235 | MSLIB_API void msModel_SetPosition (msModel *pModel, msVec3 Position); |
---|
236 | MSLIB_API void msModel_GetPosition (msModel *pModel, msVec3 Position); |
---|
237 | MSLIB_API void msModel_SetRotation (msModel *pModel, msVec3 Rotation); |
---|
238 | MSLIB_API void msModel_GetRotation (msModel *pModel, msVec3 Rotation); |
---|
239 | MSLIB_API void msModel_SetCamera (msModel *pModel, msVec3 Position, msVec2 RotationXY); |
---|
240 | MSLIB_API void msModel_GetCamera (msModel *pModel, msVec3 Position, msVec2 RotationXY); |
---|
241 | MSLIB_API void msModel_SetComment (msModel *pModel, const char *pszComment); |
---|
242 | MSLIB_API int msModel_GetComment (msModel *pModel, char *pszComment, int nMaxCommentLength); |
---|
243 | |
---|
244 | /********************************************************************** |
---|
245 | * msMesh |
---|
246 | **********************************************************************/ |
---|
247 | |
---|
248 | MSLIB_API void msMesh_Destroy (msMesh *pMesh); |
---|
249 | MSLIB_API void msMesh_SetFlags (msMesh *pMesh, byte nFlags); |
---|
250 | MSLIB_API byte msMesh_GetFlags (msMesh *pMesh); |
---|
251 | MSLIB_API void msMesh_SetName (msMesh *pMesh, const char *szName); |
---|
252 | MSLIB_API void msMesh_GetName (msMesh *pMesh, char *szName, int nMaxLength); |
---|
253 | MSLIB_API void msMesh_SetMaterialIndex (msMesh *pMesh, int nIndex); |
---|
254 | MSLIB_API int msMesh_GetMaterialIndex (msMesh *pMesh); |
---|
255 | |
---|
256 | MSLIB_API int msMesh_GetVertexCount (msMesh *pMesh); |
---|
257 | MSLIB_API int msMesh_AddVertex (msMesh *pMesh); |
---|
258 | MSLIB_API msVertex* msMesh_GetVertexAt (msMesh *pMesh, int nIndex); |
---|
259 | MSLIB_API msVertexEx* msMesh_GetVertexExAt (msMesh *pMesh, int nIndex); |
---|
260 | MSLIB_API msVertex* msMesh_GetInterpolatedVertexAt (msMesh *pMesh, int nIndex); // NOT YET IMPLEMENTED |
---|
261 | |
---|
262 | MSLIB_API int msMesh_GetTriangleCount (msMesh *pMesh); |
---|
263 | MSLIB_API int msMesh_AddTriangle (msMesh *pMesh); |
---|
264 | MSLIB_API msTriangle* msMesh_GetTriangleAt (msMesh *pMesh, int nIndex); |
---|
265 | MSLIB_API msTriangleEx* msMesh_GetTriangleExAt (msMesh *pMesh, int nIndex); |
---|
266 | |
---|
267 | MSLIB_API int msMesh_GetVertexNormalCount (msMesh *pMesh); |
---|
268 | MSLIB_API int msMesh_AddVertexNormal (msMesh *pMesh); |
---|
269 | MSLIB_API void msMesh_SetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal); |
---|
270 | MSLIB_API void msMesh_GetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal); |
---|
271 | MSLIB_API void msMesh_GetInterpolatedVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal); // NOT YET IMPLEMENTED |
---|
272 | MSLIB_API void msMesh_SetComment (msMesh *pMesh, const char *pszComment); |
---|
273 | MSLIB_API int msMesh_GetComment (msMesh *pMesh, char *pszComment, int nMaxCommentLength); |
---|
274 | |
---|
275 | /********************************************************************** |
---|
276 | * msTriangle |
---|
277 | **********************************************************************/ |
---|
278 | |
---|
279 | MSLIB_API void msTriangle_SetFlags (msTriangle* pTriangle, word nFlags); |
---|
280 | MSLIB_API word msTriangle_GetFlags (msTriangle* pTriangle); |
---|
281 | MSLIB_API void msTriangle_SetVertexIndices (msTriangle *pTriangle, word nIndices[]); |
---|
282 | MSLIB_API void msTriangle_GetVertexIndices (msTriangle *pTriangle, word nIndices[]); |
---|
283 | MSLIB_API void msTriangle_SetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]); |
---|
284 | MSLIB_API void msTriangle_GetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]); |
---|
285 | MSLIB_API void msTriangle_SetSmoothingGroup (msTriangle *pTriangle, byte nSmoothingGroup); |
---|
286 | MSLIB_API byte msTriangle_GetSmoothingGroup (msTriangle *pTriangle); |
---|
287 | |
---|
288 | /********************************************************************** |
---|
289 | * msTriangleEx |
---|
290 | **********************************************************************/ |
---|
291 | MSLIB_API void msTriangleEx_SetNormal (msTriangleEx *pTriangle, int nIndex, msVec3 Normal); |
---|
292 | MSLIB_API void msTriangleEx_GetNormal (msTriangleEx *pTriangle, int nIndex, msVec3 Normal); |
---|
293 | MSLIB_API void msTriangleEx_SetTexCoord (msTriangleEx *pTriangle, int nIndex, msVec2 TexCoord); |
---|
294 | MSLIB_API void msTriangleEx_GetTexCoord (msTriangleEx *pTriangle, int nIndex, msVec2 TexCoord); |
---|
295 | |
---|
296 | /********************************************************************** |
---|
297 | * msVertex |
---|
298 | **********************************************************************/ |
---|
299 | |
---|
300 | MSLIB_API void msVertex_SetFlags (msVertex* pVertex, byte nFlags); |
---|
301 | MSLIB_API byte msVertex_GetFlags (msVertex* pVertex); |
---|
302 | MSLIB_API void msVertex_SetVertex (msVertex* pVertex, msVec3 Vertex); |
---|
303 | MSLIB_API void msVertex_GetVertex (msVertex* pVertex, msVec3 Vertex); |
---|
304 | MSLIB_API void msVertex_SetTexCoords (msVertex* pVertex, msVec2 st); |
---|
305 | MSLIB_API void msVertex_GetTexCoords (msVertex* pVertex, msVec2 st); |
---|
306 | MSLIB_API int msVertex_SetBoneIndex (msVertex* pVertex, int nBoneIndex); |
---|
307 | MSLIB_API int msVertex_GetBoneIndex (msVertex* pVertex); |
---|
308 | |
---|
309 | /********************************************************************** |
---|
310 | * msVertexEx |
---|
311 | **********************************************************************/ |
---|
312 | |
---|
313 | MSLIB_API int msVertexEx_SetBoneIndices (msVertexEx* pVertex, int nIndex, int nBoneIndex); |
---|
314 | MSLIB_API int msVertexEx_GetBoneIndices (msVertexEx* pVertex, int nIndex); |
---|
315 | MSLIB_API int msVertexEx_SetBoneWeights (msVertexEx* pVertex, int nIndex, int nWeight); |
---|
316 | MSLIB_API int msVertexEx_GetBoneWeights (msVertexEx* pVertex, int nIndex); |
---|
317 | |
---|
318 | /********************************************************************** |
---|
319 | * msMaterial |
---|
320 | **********************************************************************/ |
---|
321 | |
---|
322 | MSLIB_API void msMaterial_SetFlags (msMaterial *pMaterial, int nFlags); |
---|
323 | MSLIB_API int msMaterial_GetFlags (msMaterial *pMaterial); |
---|
324 | MSLIB_API void msMaterial_SetName (msMaterial *pMaterial, const char *szName); |
---|
325 | MSLIB_API void msMaterial_GetName (msMaterial *pMaterial, char *szName, int nMaxLength); |
---|
326 | MSLIB_API void msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient); |
---|
327 | MSLIB_API void msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient); |
---|
328 | MSLIB_API void msMaterial_GetAmbient (msMaterial *pMaterial, msVec4 Ambient); |
---|
329 | MSLIB_API void msMaterial_SetDiffuse (msMaterial *pMaterial, msVec4 Diffuse); |
---|
330 | MSLIB_API void msMaterial_GetDiffuse (msMaterial *pMaterial, msVec4 Diffuse); |
---|
331 | MSLIB_API void msMaterial_SetSpecular (msMaterial *pMaterial, msVec4 Specular); |
---|
332 | MSLIB_API void msMaterial_GetSpecular (msMaterial *pMaterial, msVec4 Specular); |
---|
333 | MSLIB_API void msMaterial_SetEmissive (msMaterial *pMaterial, msVec4 Emissive); |
---|
334 | MSLIB_API void msMaterial_GetEmissive (msMaterial *pMaterial, msVec4 Emissive); |
---|
335 | MSLIB_API void msMaterial_SetShininess (msMaterial *pMaterial, float fShininess); |
---|
336 | MSLIB_API float msMaterial_GetShininess (msMaterial *pMaterial); |
---|
337 | MSLIB_API void msMaterial_SetTransparency (msMaterial *pMaterial, float fTransparency); |
---|
338 | MSLIB_API float msMaterial_GetTransparency (msMaterial *pMaterial); |
---|
339 | MSLIB_API void msMaterial_SetDiffuseTexture (msMaterial *pMaterial, const char *szDiffuseTexture); |
---|
340 | MSLIB_API void msMaterial_GetDiffuseTexture (msMaterial *pMaterial, char *szDiffuseTexture, int nMaxLength); |
---|
341 | MSLIB_API void msMaterial_SetAlphaTexture (msMaterial *pMaterial, const char *szAlphaTexture); |
---|
342 | MSLIB_API void msMaterial_GetAlphaTexture (msMaterial *pMaterial, char *szAlphaTexture, int nMaxLength); |
---|
343 | MSLIB_API void msMaterial_SetComment (msMaterial *pMaterial, const char *pszComment); |
---|
344 | MSLIB_API int msMaterial_GetComment (msMaterial *pMaterial, char *pszComment, int nMaxCommentLength); |
---|
345 | |
---|
346 | /********************************************************************** |
---|
347 | * msBone |
---|
348 | **********************************************************************/ |
---|
349 | |
---|
350 | MSLIB_API void msBone_Destroy (msBone *pBone); |
---|
351 | MSLIB_API void msBone_SetFlags (msBone *pBone, int nFlags); |
---|
352 | MSLIB_API int msBone_GetFlags (msBone *pBone); |
---|
353 | MSLIB_API void msBone_SetName (msBone *pBone, const char *szName); |
---|
354 | MSLIB_API void msBone_GetName (msBone *pBone, char *szName, int nMaxLength); |
---|
355 | MSLIB_API void msBone_SetParentName (msBone *pBone, const char *szParentName); |
---|
356 | MSLIB_API void msBone_GetParentName (msBone *pBone, char *szParentName, int nMaxLength); |
---|
357 | MSLIB_API void msBone_SetPosition (msBone *pBone, msVec3 Position); |
---|
358 | MSLIB_API void msBone_GetPosition (msBone *pBone, msVec3 Position); |
---|
359 | MSLIB_API void msBone_GetInterpolatedPosition (msBone *pBone, msVec3 Position); // NOT YET IMPLEMENTED |
---|
360 | MSLIB_API void msBone_SetRotation (msBone *pBone, msVec3 Rotation); |
---|
361 | MSLIB_API void msBone_GetRotation (msBone *pBone, msVec3 Rotation); |
---|
362 | MSLIB_API void msBone_GetInterpolatedRotation (msBone *pBone, msVec3 Rotation); // NOT YET IMPLEMENTED |
---|
363 | |
---|
364 | MSLIB_API int msBone_GetPositionKeyCount (msBone *pBone); |
---|
365 | MSLIB_API int msBone_AddPositionKey (msBone *pBone, float fTime, msVec3 Position); |
---|
366 | MSLIB_API msPositionKey* msBone_GetPositionKeyAt (msBone *pBone, int nIndex); |
---|
367 | |
---|
368 | MSLIB_API int msBone_GetRotationKeyCount (msBone *pBone); |
---|
369 | MSLIB_API int msBone_AddRotationKey (msBone *pBone, float fTime, msVec3 Rotation); |
---|
370 | MSLIB_API msRotationKey* msBone_GetRotationKeyAt (msBone *pBone, int nIndex); |
---|
371 | MSLIB_API void msBone_SetComment (msBone *pBone, const char *pszComment); |
---|
372 | MSLIB_API int msBone_GetComment (msBone *pBone, char *pszComment, int nMaxCommentLength); |
---|
373 | |
---|
374 | |
---|
375 | |
---|
376 | #ifdef __cplusplus |
---|
377 | } |
---|
378 | #endif /* __cplusplus */ |
---|
379 | |
---|
380 | |
---|
381 | |
---|
382 | #ifdef WIN32 |
---|
383 | #include <poppack.h> |
---|
384 | #endif /* WIN32 */ |
---|
385 | |
---|
386 | |
---|
387 | |
---|
388 | #endif /* __MSLIB_H__ */ |
---|