[692] | 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, eUnused = 32
|
---|
| 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 | /* msTriangle */
|
---|
| 78 | typedef struct
|
---|
| 79 | {
|
---|
| 80 | word nFlags;
|
---|
| 81 | word nVertexIndices[3];
|
---|
| 82 | word nNormalIndices[3];
|
---|
| 83 | msVec3 Normal;
|
---|
| 84 | byte nSmoothingGroup;
|
---|
| 85 | } msTriangle;
|
---|
| 86 |
|
---|
| 87 | /* msMesh */
|
---|
| 88 | typedef struct msMesh
|
---|
| 89 | {
|
---|
| 90 | byte nFlags;
|
---|
| 91 | char szName[MS_MAX_NAME];
|
---|
| 92 | char nMaterialIndex;
|
---|
| 93 |
|
---|
| 94 | word nNumVertices;
|
---|
| 95 | word nNumAllocedVertices;
|
---|
| 96 | msVertex* pVertices;
|
---|
| 97 |
|
---|
| 98 | word nNumNormals;
|
---|
| 99 | word nNumAllocedNormals;
|
---|
| 100 | msVec3* pNormals;
|
---|
| 101 |
|
---|
| 102 | word nNumTriangles;
|
---|
| 103 | word nNumAllocedTriangles;
|
---|
| 104 | msTriangle* pTriangles;
|
---|
| 105 | } msMesh;
|
---|
| 106 |
|
---|
| 107 | /* msMaterial */
|
---|
| 108 | typedef struct msMaterial
|
---|
| 109 | {
|
---|
| 110 | int nFlags;
|
---|
| 111 | char szName[MS_MAX_NAME];
|
---|
| 112 | msVec4 Ambient;
|
---|
| 113 | msVec4 Diffuse;
|
---|
| 114 | msVec4 Specular;
|
---|
| 115 | msVec4 Emissive;
|
---|
| 116 | float fShininess;
|
---|
| 117 | float fTransparency;
|
---|
| 118 | char szDiffuseTexture[MS_MAX_PATH];
|
---|
| 119 | char szAlphaTexture[MS_MAX_PATH];
|
---|
| 120 | int nName;
|
---|
| 121 | } msMaterial;
|
---|
| 122 |
|
---|
| 123 | /* msPositionKey */
|
---|
| 124 | typedef struct msPositionKey
|
---|
| 125 | {
|
---|
| 126 | float fTime;
|
---|
| 127 | msVec3 Position;
|
---|
| 128 | } msPositionKey;
|
---|
| 129 |
|
---|
| 130 | /* msRotationKey */
|
---|
| 131 | typedef struct msRotationKey
|
---|
| 132 | {
|
---|
| 133 | float fTime;
|
---|
| 134 | msVec3 Rotation;
|
---|
| 135 | } msRotationKey;
|
---|
| 136 |
|
---|
| 137 | /* msBone */
|
---|
| 138 | typedef struct msBone
|
---|
| 139 | {
|
---|
| 140 | int nFlags;
|
---|
| 141 | char szName[MS_MAX_NAME];
|
---|
| 142 | char szParentName[MS_MAX_NAME];
|
---|
| 143 | msVec3 Position;
|
---|
| 144 | msVec3 Rotation;
|
---|
| 145 |
|
---|
| 146 | int nNumPositionKeys;
|
---|
| 147 | int nNumAllocedPositionKeys;
|
---|
| 148 | msPositionKey* pPositionKeys;
|
---|
| 149 |
|
---|
| 150 | int nNumRotationKeys;
|
---|
| 151 | int nNumAllocedRotationKeys;
|
---|
| 152 | msRotationKey* pRotationKeys;
|
---|
| 153 | } msBone;
|
---|
| 154 |
|
---|
| 155 | /* msModel */
|
---|
| 156 | typedef struct msModel
|
---|
| 157 | {
|
---|
| 158 | int nNumMeshes;
|
---|
| 159 | int nNumAllocedMeshes;
|
---|
| 160 | msMesh* pMeshes;
|
---|
| 161 |
|
---|
| 162 | int nNumMaterials;
|
---|
| 163 | int nNumAllocedMaterials;
|
---|
| 164 | msMaterial* pMaterials;
|
---|
| 165 |
|
---|
| 166 | int nNumBones;
|
---|
| 167 | int nNumAllocedBones;
|
---|
| 168 | msBone* pBones;
|
---|
| 169 |
|
---|
| 170 | int nFrame;
|
---|
| 171 | int nTotalFrames;
|
---|
| 172 |
|
---|
| 173 | msVec3 Position;
|
---|
| 174 | msVec3 Rotation;
|
---|
| 175 | } msModel;
|
---|
| 176 |
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | /**********************************************************************
|
---|
| 180 | *
|
---|
| 181 | * MilkShape 3D Interface
|
---|
| 182 | *
|
---|
| 183 | **********************************************************************/
|
---|
| 184 |
|
---|
| 185 | /**********************************************************************
|
---|
| 186 | * msModel
|
---|
| 187 | **********************************************************************/
|
---|
| 188 |
|
---|
| 189 | MSLIB_API void msModel_Destroy (msModel *pModel);
|
---|
| 190 |
|
---|
| 191 | MSLIB_API int msModel_GetMeshCount (msModel *pModel);
|
---|
| 192 | MSLIB_API int msModel_AddMesh (msModel *pModel);
|
---|
| 193 | MSLIB_API msMesh* msModel_GetMeshAt (msModel *pModel, int nIndex);
|
---|
| 194 | MSLIB_API int msModel_FindMeshByName (msModel *pModel, const char *szName);
|
---|
| 195 |
|
---|
| 196 | MSLIB_API int msModel_GetMaterialCount (msModel *pModel);
|
---|
| 197 | MSLIB_API int msModel_AddMaterial (msModel *pModel);
|
---|
| 198 | MSLIB_API msMaterial* msModel_GetMaterialAt (msModel *pModel, int nIndex);
|
---|
| 199 | MSLIB_API int msModel_FindMaterialByName (msModel *pModel, const char *szName);
|
---|
| 200 |
|
---|
| 201 | MSLIB_API int msModel_GetBoneCount (msModel *pModel);
|
---|
| 202 | MSLIB_API int msModel_AddBone (msModel *pModel);
|
---|
| 203 | MSLIB_API msBone* msModel_GetBoneAt (msModel *pModel, int nIndex);
|
---|
| 204 | MSLIB_API int msModel_FindBoneByName (msModel *pModel, const char *szName);
|
---|
| 205 |
|
---|
| 206 | MSLIB_API int msModel_SetFrame (msModel *pModel, int nFrame);
|
---|
| 207 | MSLIB_API int msModel_GetFrame (msModel *pModel);
|
---|
| 208 | MSLIB_API int msModel_SetTotalFrames (msModel *pModel, int nTotalFrames);
|
---|
| 209 | MSLIB_API int msModel_GetTotalFrames (msModel *pModel);
|
---|
| 210 | MSLIB_API void msModel_SetPosition (msModel *pModel, msVec3 Position);
|
---|
| 211 | MSLIB_API void msModel_GetPosition (msModel *pModel, msVec3 Position);
|
---|
| 212 | MSLIB_API void msModel_SetRotation (msModel *pModel, msVec3 Rotation);
|
---|
| 213 | MSLIB_API void msModel_GetRotation (msModel *pModel, msVec3 Rotation);
|
---|
| 214 |
|
---|
| 215 | /**********************************************************************
|
---|
| 216 | * msMesh
|
---|
| 217 | **********************************************************************/
|
---|
| 218 |
|
---|
| 219 | MSLIB_API void msMesh_Destroy (msMesh *pMesh);
|
---|
| 220 | MSLIB_API void msMesh_SetFlags (msMesh *pMesh, byte nFlags);
|
---|
| 221 | MSLIB_API byte msMesh_GetFlags (msMesh *pMesh);
|
---|
| 222 | MSLIB_API void msMesh_SetName (msMesh *pMesh, const char *szName);
|
---|
| 223 | MSLIB_API void msMesh_GetName (msMesh *pMesh, char *szName, int nMaxLength);
|
---|
| 224 | MSLIB_API void msMesh_SetMaterialIndex (msMesh *pMesh, int nIndex);
|
---|
| 225 | MSLIB_API int msMesh_GetMaterialIndex (msMesh *pMesh);
|
---|
| 226 |
|
---|
| 227 | MSLIB_API int msMesh_GetVertexCount (msMesh *pMesh);
|
---|
| 228 | MSLIB_API int msMesh_AddVertex (msMesh *pMesh);
|
---|
| 229 | MSLIB_API msVertex* msMesh_GetVertexAt (msMesh *pMesh, int nIndex);
|
---|
| 230 | MSLIB_API msVertex* msMesh_GetInterpolatedVertexAt (msMesh *pMesh, int nIndex); // NOT YET IMPLEMENTED
|
---|
| 231 |
|
---|
| 232 | MSLIB_API int msMesh_GetTriangleCount (msMesh *pMesh);
|
---|
| 233 | MSLIB_API int msMesh_AddTriangle (msMesh *pMesh);
|
---|
| 234 | MSLIB_API msTriangle* msMesh_GetTriangleAt (msMesh *pMesh, int nIndex);
|
---|
| 235 |
|
---|
| 236 | MSLIB_API int msMesh_GetVertexNormalCount (msMesh *pMesh);
|
---|
| 237 | MSLIB_API int msMesh_AddVertexNormal (msMesh *pMesh);
|
---|
| 238 | MSLIB_API void msMesh_SetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal);
|
---|
| 239 | MSLIB_API void msMesh_GetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal);
|
---|
| 240 | MSLIB_API void msMesh_GetInterpolatedVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal); // NOT YET IMPLEMENTED
|
---|
| 241 |
|
---|
| 242 | /**********************************************************************
|
---|
| 243 | * msTriangle
|
---|
| 244 | **********************************************************************/
|
---|
| 245 |
|
---|
| 246 | MSLIB_API void msTriangle_SetFlags (msTriangle* pTriangle, word nFlags);
|
---|
| 247 | MSLIB_API word msTriangle_GetFlags (msTriangle* pTriangle);
|
---|
| 248 | MSLIB_API void msTriangle_SetVertexIndices (msTriangle *pTriangle, word nIndices[]);
|
---|
| 249 | MSLIB_API void msTriangle_GetVertexIndices (msTriangle *pTriangle, word nIndices[]);
|
---|
| 250 | MSLIB_API void msTriangle_SetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]);
|
---|
| 251 | MSLIB_API void msTriangle_GetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]);
|
---|
| 252 | MSLIB_API void msTriangle_SetSmoothingGroup (msTriangle *pTriangle, byte nSmoothingGroup);
|
---|
| 253 | MSLIB_API byte msTriangle_GetSmoothingGroup (msTriangle *pTriangle);
|
---|
| 254 |
|
---|
| 255 | /**********************************************************************
|
---|
| 256 | * msVertex
|
---|
| 257 | **********************************************************************/
|
---|
| 258 |
|
---|
| 259 | MSLIB_API void msVertex_SetFlags (msVertex* pVertex, byte nFlags);
|
---|
| 260 | MSLIB_API byte msVertex_GetFlags (msVertex* pVertex);
|
---|
| 261 | MSLIB_API void msVertex_SetVertex (msVertex* pVertex, msVec3 Vertex);
|
---|
| 262 | MSLIB_API void msVertex_GetVertex (msVertex* pVertex, msVec3 Vertex);
|
---|
| 263 | MSLIB_API void msVertex_SetTexCoords (msVertex* pVertex, msVec2 st);
|
---|
| 264 | MSLIB_API void msVertex_GetTexCoords (msVertex* pVertex, msVec2 st);
|
---|
| 265 | MSLIB_API int msVertex_SetBoneIndex (msVertex* pVertex, int nBoneIndex);
|
---|
| 266 | MSLIB_API int msVertex_GetBoneIndex (msVertex* pVertex);
|
---|
| 267 |
|
---|
| 268 | /**********************************************************************
|
---|
| 269 | * msMaterial
|
---|
| 270 | **********************************************************************/
|
---|
| 271 |
|
---|
| 272 | MSLIB_API void msMaterial_SetName (msMaterial *pMaterial, const char *szName);
|
---|
| 273 | MSLIB_API void msMaterial_GetName (msMaterial *pMaterial, char *szName, int nMaxLength);
|
---|
| 274 | MSLIB_API void msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient);
|
---|
| 275 | MSLIB_API void msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient);
|
---|
| 276 | MSLIB_API void msMaterial_GetAmbient (msMaterial *pMaterial, msVec4 Ambient);
|
---|
| 277 | MSLIB_API void msMaterial_SetDiffuse (msMaterial *pMaterial, msVec4 Diffuse);
|
---|
| 278 | MSLIB_API void msMaterial_GetDiffuse (msMaterial *pMaterial, msVec4 Diffuse);
|
---|
| 279 | MSLIB_API void msMaterial_SetSpecular (msMaterial *pMaterial, msVec4 Specular);
|
---|
| 280 | MSLIB_API void msMaterial_GetSpecular (msMaterial *pMaterial, msVec4 Specular);
|
---|
| 281 | MSLIB_API void msMaterial_SetEmissive (msMaterial *pMaterial, msVec4 Emissive);
|
---|
| 282 | MSLIB_API void msMaterial_GetEmissive (msMaterial *pMaterial, msVec4 Emissive);
|
---|
| 283 | MSLIB_API void msMaterial_SetShininess (msMaterial *pMaterial, float fShininess);
|
---|
| 284 | MSLIB_API float msMaterial_GetShininess (msMaterial *pMaterial);
|
---|
| 285 | MSLIB_API void msMaterial_SetTransparency (msMaterial *pMaterial, float fTransparency);
|
---|
| 286 | MSLIB_API float msMaterial_GetTransparency (msMaterial *pMaterial);
|
---|
| 287 | MSLIB_API void msMaterial_SetDiffuseTexture (msMaterial *pMaterial, const char *szDiffuseTexture);
|
---|
| 288 | MSLIB_API void msMaterial_GetDiffuseTexture (msMaterial *pMaterial, char *szDiffuseTexture, int nMaxLength);
|
---|
| 289 | MSLIB_API void msMaterial_SetAlphaTexture (msMaterial *pMaterial, const char *szAlphaTexture);
|
---|
| 290 | MSLIB_API void msMaterial_GetAlphaTexture (msMaterial *pMaterial, char *szAlphaTexture, int nMaxLength);
|
---|
| 291 |
|
---|
| 292 | /**********************************************************************
|
---|
| 293 | * msBone
|
---|
| 294 | **********************************************************************/
|
---|
| 295 |
|
---|
| 296 | MSLIB_API void msBone_Destroy (msBone *pBone);
|
---|
| 297 | MSLIB_API void msBone_SetFlags (msBone *pBone, int nFlags);
|
---|
| 298 | MSLIB_API int msBone_GetFlags (msBone *pBone);
|
---|
| 299 | MSLIB_API void msBone_SetName (msBone *pBone, const char *szName);
|
---|
| 300 | MSLIB_API void msBone_GetName (msBone *pBone, char *szName, int nMaxLength);
|
---|
| 301 | MSLIB_API void msBone_SetParentName (msBone *pBone, const char *szParentName);
|
---|
| 302 | MSLIB_API void msBone_GetParentName (msBone *pBone, char *szParentName, int nMaxLength);
|
---|
| 303 | MSLIB_API void msBone_SetPosition (msBone *pBone, msVec3 Position);
|
---|
| 304 | MSLIB_API void msBone_GetPosition (msBone *pBone, msVec3 Position);
|
---|
| 305 | MSLIB_API void msBone_GetInterpolatedPosition (msBone *pBone, msVec3 Position); // NOT YET IMPLEMENTED
|
---|
| 306 | MSLIB_API void msBone_SetRotation (msBone *pBone, msVec3 Rotation);
|
---|
| 307 | MSLIB_API void msBone_GetRotation (msBone *pBone, msVec3 Rotation);
|
---|
| 308 | MSLIB_API void msBone_GetInterpolatedRotation (msBone *pBone, msVec3 Rotation); // NOT YET IMPLEMENTED
|
---|
| 309 |
|
---|
| 310 | MSLIB_API int msBone_GetPositionKeyCount (msBone *pBone);
|
---|
| 311 | MSLIB_API int msBone_AddPositionKey (msBone *pBone, float fTime, msVec3 Position);
|
---|
| 312 | MSLIB_API msPositionKey* msBone_GetPositionKeyAt (msBone *pBone, int nIndex);
|
---|
| 313 |
|
---|
| 314 | MSLIB_API int msBone_GetRotationKeyCount (msBone *pBone);
|
---|
| 315 | MSLIB_API int msBone_AddRotationKey (msBone *pBone, float fTime, msVec3 Rotation);
|
---|
| 316 | MSLIB_API msRotationKey* msBone_GetRotationKeyAt (msBone *pBone, int nIndex);
|
---|
| 317 |
|
---|
| 318 |
|
---|
| 319 |
|
---|
| 320 | #ifdef __cplusplus
|
---|
| 321 | }
|
---|
| 322 | #endif /* __cplusplus */
|
---|
| 323 |
|
---|
| 324 |
|
---|
| 325 |
|
---|
| 326 | #ifdef WIN32
|
---|
| 327 | #include <poppack.h>
|
---|
| 328 | #endif /* WIN32 */
|
---|
| 329 |
|
---|
| 330 |
|
---|
| 331 |
|
---|
| 332 | #endif /* __MSLIB_H__ */ |
---|