Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# msLib.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002  *
    00003  * MilkShape 3D Model Import/Export API
    00004  *
    00005  * May 10 2000, Mete Ciragan, chUmbaLum sOft
    00006  *
    00007  **********************************************************************/
    00008
    00009 #ifndef __MSLIB_H__
    00010 #define __MSLIB_H__
    00011
    00012
    00013
    00014 #ifdef MSLIB_EXPORTS
    00015 #define MSLIB_API __declspec(dllexport)
    00016 #else
    00017 #define MSLIB_API __declspec(dllimport)
    00018 #endif /* MSLIB_EXPORTS */
    00019
    00020
    00021
    00022 #ifdef WIN32
    00023 #include <pshpack1.h>
    00024 #endif /* WIN32 */
    00025
    00026
    00027
    00028 #ifdef __cplusplus
    00029 extern "C" {
    00030 #endif /* __cplusplus */
    00031
    00032
    00033
    00034 /**********************************************************************
    00035  *
    00036  * Constants
    00037  *
    00038  **********************************************************************/
    00039
    00040 #define MS_MAX_NAME             32
    00041 #define MS_MAX_PATH             256
    00042
    00043
    00044
    00045 /**********************************************************************
    00046  *
    00047  * Types
    00048  *
    00049  **********************************************************************/
    00050
    00051 #ifndef byte
    00052 typedef unsigned char byte;
    00053 #endif /* byte */
    00054
    00055 #ifndef word
    00056 typedef unsigned short word;
    00057 #endif /* word */
    00058
    00059 typedef float   msVec4[4];
    00060 typedef float   msVec3[3];
    00061 typedef float   msVec2[2];
    00062
    00063 /* msFlag */
    00064 typedef enum {
    00065     eSelected = 1, eSelected2 = 2, eHidden = 4, eDirty = 8, eAveraged = 16, eUnused = 32
    00066 } msFlag;
    00067
    00068 /* msVertex */
    00069 typedef struct msVertex
    00070 {
    00071     byte        nFlags;
    00072     msVec3      Vertex;
    00073     float       u, v;
    00074     char        nBoneIndex;
    00075 } msVertex;
    00076
    00077 /* msTriangle */
    00078 typedef struct
    00079 {
    00080     word        nFlags;
    00081     word        nVertexIndices[3];
    00082     word        nNormalIndices[3];
    00083     msVec3      Normal;
    00084     byte        nSmoothingGroup;
    00085 } msTriangle;
    00086
    00087 /* msMesh */
    00088 typedef struct msMesh
    00089 {
    00090     byte        nFlags;
    00091     char        szName[MS_MAX_NAME];
    00092     char        nMaterialIndex;
    00093
    00094     word        nNumVertices;
    00095     word        nNumAllocedVertices;
    00096     msVertex*   pVertices;
    00097
    00098     word        nNumNormals;
    00099     word        nNumAllocedNormals;
    00100     msVec3*     pNormals;
    00101
    00102     word        nNumTriangles;
    00103     word        nNumAllocedTriangles;
    00104     msTriangle* pTriangles;
    00105 } msMesh;
    00106
    00107 /* msMaterial */
    00108 typedef struct msMaterial
    00109 {
    00110     int         nFlags;
    00111     char        szName[MS_MAX_NAME];
    00112     msVec4      Ambient;
    00113     msVec4      Diffuse;
    00114     msVec4      Specular;
    00115     msVec4      Emissive;
    00116     float       fShininess;
    00117     float       fTransparency;
    00118     char        szDiffuseTexture[MS_MAX_PATH];
    00119     char        szAlphaTexture[MS_MAX_PATH];
    00120     int         nName;
    00121 } msMaterial;
    00122
    00123 /* msPositionKey */
    00124 typedef struct msPositionKey
    00125 {
    00126     float       fTime;
    00127     msVec3      Position;
    00128 } msPositionKey;
    00129
    00130 /* msRotationKey */
    00131 typedef struct msRotationKey
    00132 {
    00133     float   fTime;
    00134     msVec3  Rotation;
    00135 } msRotationKey;
    00136
    00137 /* msBone */
    00138 typedef struct msBone
    00139 {
    00140     int             nFlags;
    00141     char            szName[MS_MAX_NAME];
    00142     char            szParentName[MS_MAX_NAME];
    00143     msVec3          Position;
    00144     msVec3          Rotation;
    00145
    00146     int             nNumPositionKeys;
    00147     int             nNumAllocedPositionKeys;
    00148     msPositionKey*  pPositionKeys;
    00149
    00150     int             nNumRotationKeys;
    00151     int             nNumAllocedRotationKeys;
    00152     msRotationKey*  pRotationKeys;
    00153 } msBone;
    00154
    00155 /* msModel */
    00156 typedef struct msModel
    00157 {
    00158     int         nNumMeshes;
    00159     int         nNumAllocedMeshes;
    00160     msMesh*     pMeshes;
    00161
    00162     int         nNumMaterials;
    00163     int         nNumAllocedMaterials;
    00164     msMaterial* pMaterials;
    00165
    00166     int         nNumBones;
    00167     int         nNumAllocedBones;
    00168     msBone*     pBones;
    00169
    00170     int         nFrame;
    00171     int         nTotalFrames;
    00172
    00173     msVec3      Position;
    00174     msVec3      Rotation;
    00175 } msModel;
    00176
    00177
    00178
    00179 /**********************************************************************
    00180  *
    00181  * MilkShape 3D Interface
    00182  *
    00183  **********************************************************************/
    00184
    00185 /**********************************************************************
    00186  * msModel
    00187  **********************************************************************/
    00188
    00189 MSLIB_API void          msModel_Destroy (msModel *pModel);
    00190
    00191 MSLIB_API int           msModel_GetMeshCount (msModel *pModel);
    00192 MSLIB_API int           msModel_AddMesh (msModel *pModel);
    00193 MSLIB_API msMesh*       msModel_GetMeshAt (msModel *pModel, int nIndex);
    00194 MSLIB_API int           msModel_FindMeshByName (msModel *pModel, const char *szName);
    00195
    00196 MSLIB_API int           msModel_GetMaterialCount (msModel *pModel);
    00197 MSLIB_API int           msModel_AddMaterial (msModel *pModel);
    00198 MSLIB_API msMaterial*   msModel_GetMaterialAt (msModel *pModel, int nIndex);
    00199 MSLIB_API int           msModel_FindMaterialByName (msModel *pModel, const char *szName);
    00200
    00201 MSLIB_API int           msModel_GetBoneCount (msModel *pModel);
    00202 MSLIB_API int           msModel_AddBone (msModel *pModel);
    00203 MSLIB_API msBone*       msModel_GetBoneAt (msModel *pModel, int nIndex);
    00204 MSLIB_API int           msModel_FindBoneByName (msModel *pModel, const char *szName);
    00205
    00206 MSLIB_API int           msModel_SetFrame (msModel *pModel, int nFrame);
    00207 MSLIB_API int           msModel_GetFrame (msModel *pModel);
    00208 MSLIB_API int           msModel_SetTotalFrames (msModel *pModel, int nTotalFrames);
    00209 MSLIB_API int           msModel_GetTotalFrames (msModel *pModel);
    00210 MSLIB_API void          msModel_SetPosition (msModel *pModel, msVec3 Position);
    00211 MSLIB_API void          msModel_GetPosition (msModel *pModel, msVec3 Position);
    00212 MSLIB_API void          msModel_SetRotation (msModel *pModel, msVec3 Rotation);
    00213 MSLIB_API void          msModel_GetRotation (msModel *pModel, msVec3 Rotation);
    00214
    00215 /**********************************************************************
    00216  * msMesh
    00217  **********************************************************************/
    00218
    00219 MSLIB_API void          msMesh_Destroy (msMesh *pMesh);
    00220 MSLIB_API void          msMesh_SetFlags (msMesh *pMesh, byte nFlags);
    00221 MSLIB_API byte          msMesh_GetFlags (msMesh *pMesh);
    00222 MSLIB_API void          msMesh_SetName (msMesh *pMesh, const char *szName);
    00223 MSLIB_API void          msMesh_GetName (msMesh *pMesh, char *szName, int nMaxLength);
    00224 MSLIB_API void          msMesh_SetMaterialIndex (msMesh *pMesh, int nIndex);
    00225 MSLIB_API int           msMesh_GetMaterialIndex (msMesh *pMesh);
    00226
    00227 MSLIB_API int           msMesh_GetVertexCount (msMesh *pMesh);
    00228 MSLIB_API int           msMesh_AddVertex (msMesh *pMesh);
    00229 MSLIB_API msVertex*     msMesh_GetVertexAt (msMesh *pMesh, int nIndex);
    00230 MSLIB_API msVertex*     msMesh_GetInterpolatedVertexAt (msMesh *pMesh, int nIndex); // NOT YET IMPLEMENTED
    00231
    00232 MSLIB_API int           msMesh_GetTriangleCount (msMesh *pMesh);
    00233 MSLIB_API int           msMesh_AddTriangle (msMesh *pMesh);
    00234 MSLIB_API msTriangle*   msMesh_GetTriangleAt (msMesh *pMesh, int nIndex);
    00235
    00236 MSLIB_API int           msMesh_GetVertexNormalCount (msMesh *pMesh);
    00237 MSLIB_API int           msMesh_AddVertexNormal (msMesh *pMesh);
    00238 MSLIB_API void          msMesh_SetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal);
    00239 MSLIB_API void          msMesh_GetVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal);
    00240 MSLIB_API void          msMesh_GetInterpolatedVertexNormalAt (msMesh *pMesh, int nIndex, msVec3 Normal); // NOT YET IMPLEMENTED
    00241
    00242 /**********************************************************************
    00243  * msTriangle
    00244  **********************************************************************/
    00245
    00246 MSLIB_API void          msTriangle_SetFlags (msTriangle* pTriangle, word nFlags);
    00247 MSLIB_API word          msTriangle_GetFlags (msTriangle* pTriangle);
    00248 MSLIB_API void          msTriangle_SetVertexIndices (msTriangle *pTriangle, word nIndices[]);
    00249 MSLIB_API void          msTriangle_GetVertexIndices (msTriangle *pTriangle, word nIndices[]);
    00250 MSLIB_API void          msTriangle_SetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]);
    00251 MSLIB_API void          msTriangle_GetNormalIndices (msTriangle *pTriangle, word nNormalIndices[]);
    00252 MSLIB_API void          msTriangle_SetSmoothingGroup (msTriangle *pTriangle, byte nSmoothingGroup);
    00253 MSLIB_API byte          msTriangle_GetSmoothingGroup (msTriangle *pTriangle);
    00254
    00255 /**********************************************************************
    00256  * msVertex
    00257  **********************************************************************/
    00258
    00259 MSLIB_API void          msVertex_SetFlags (msVertex* pVertex, byte nFlags);
    00260 MSLIB_API byte          msVertex_GetFlags (msVertex* pVertex);
    00261 MSLIB_API void          msVertex_SetVertex (msVertex* pVertex, msVec3 Vertex);
    00262 MSLIB_API void          msVertex_GetVertex (msVertex* pVertex, msVec3 Vertex);
    00263 MSLIB_API void          msVertex_SetTexCoords (msVertex* pVertex, msVec2 st);
    00264 MSLIB_API void          msVertex_GetTexCoords (msVertex* pVertex, msVec2 st);
    00265 MSLIB_API int           msVertex_SetBoneIndex (msVertex* pVertex, int nBoneIndex);
    00266 MSLIB_API int           msVertex_GetBoneIndex (msVertex* pVertex);
    00267
    00268 /**********************************************************************
    00269  * msMaterial
    00270  **********************************************************************/
    00271
    00272 MSLIB_API void          msMaterial_SetName (msMaterial *pMaterial, const char *szName);
    00273 MSLIB_API void          msMaterial_GetName (msMaterial *pMaterial, char *szName, int nMaxLength);
    00274 MSLIB_API void          msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient);
    00275 MSLIB_API void          msMaterial_SetAmbient (msMaterial *pMaterial, msVec4 Ambient);
    00276 MSLIB_API void          msMaterial_GetAmbient (msMaterial *pMaterial, msVec4 Ambient);
    00277 MSLIB_API void          msMaterial_SetDiffuse (msMaterial *pMaterial, msVec4 Diffuse);
    00278 MSLIB_API void          msMaterial_GetDiffuse (msMaterial *pMaterial, msVec4 Diffuse);
    00279 MSLIB_API void          msMaterial_SetSpecular (msMaterial *pMaterial, msVec4 Specular);
    00280 MSLIB_API void          msMaterial_GetSpecular (msMaterial *pMaterial, msVec4 Specular);
    00281 MSLIB_API void          msMaterial_SetEmissive (msMaterial *pMaterial, msVec4 Emissive);
    00282 MSLIB_API void          msMaterial_GetEmissive (msMaterial *pMaterial, msVec4 Emissive);
    00283 MSLIB_API void          msMaterial_SetShininess (msMaterial *pMaterial, float fShininess);
    00284 MSLIB_API float         msMaterial_GetShininess (msMaterial *pMaterial);
    00285 MSLIB_API void          msMaterial_SetTransparency (msMaterial *pMaterial, float fTransparency);
    00286 MSLIB_API float         msMaterial_GetTransparency (msMaterial *pMaterial);
    00287 MSLIB_API void          msMaterial_SetDiffuseTexture (msMaterial *pMaterial, const char *szDiffuseTexture);
    00288 MSLIB_API void          msMaterial_GetDiffuseTexture (msMaterial *pMaterial, char *szDiffuseTexture, int nMaxLength);
    00289 MSLIB_API void          msMaterial_SetAlphaTexture (msMaterial *pMaterial, const char *szAlphaTexture);
    00290 MSLIB_API void          msMaterial_GetAlphaTexture (msMaterial *pMaterial, char *szAlphaTexture, int nMaxLength);
    00291
    00292 /**********************************************************************
    00293  * msBone
    00294  **********************************************************************/
    00295
    00296 MSLIB_API void          msBone_Destroy (msBone *pBone);
    00297 MSLIB_API void          msBone_SetFlags (msBone *pBone, int nFlags);
    00298 MSLIB_API int           msBone_GetFlags (msBone *pBone);
    00299 MSLIB_API void          msBone_SetName (msBone *pBone, const char *szName);
    00300 MSLIB_API void          msBone_GetName (msBone *pBone, char *szName, int nMaxLength);
    00301 MSLIB_API void          msBone_SetParentName (msBone *pBone, const char *szParentName);
    00302 MSLIB_API void          msBone_GetParentName (msBone *pBone, char *szParentName, int nMaxLength);
    00303 MSLIB_API void          msBone_SetPosition (msBone *pBone, msVec3 Position);
    00304 MSLIB_API void          msBone_GetPosition (msBone *pBone, msVec3 Position);
    00305 MSLIB_API void          msBone_GetInterpolatedPosition (msBone *pBone, msVec3 Position); // NOT YET IMPLEMENTED
    00306 MSLIB_API void          msBone_SetRotation (msBone *pBone, msVec3 Rotation);
    00307 MSLIB_API void          msBone_GetRotation (msBone *pBone, msVec3 Rotation);
    00308 MSLIB_API void          msBone_GetInterpolatedRotation (msBone *pBone, msVec3 Rotation); // NOT YET IMPLEMENTED
    00309
    00310 MSLIB_API int           msBone_GetPositionKeyCount (msBone *pBone);
    00311 MSLIB_API int           msBone_AddPositionKey (msBone *pBone, float fTime, msVec3 Position);
    00312 MSLIB_API msPositionKey* msBone_GetPositionKeyAt (msBone *pBone, int nIndex);
    00313
    00314 MSLIB_API int           msBone_GetRotationKeyCount (msBone *pBone);
    00315 MSLIB_API int           msBone_AddRotationKey (msBone *pBone, float fTime, msVec3 Rotation);
    00316 MSLIB_API msRotationKey* msBone_GetRotationKeyAt (msBone *pBone, int nIndex);
    00317
    00318
    00319
    00320 #ifdef __cplusplus
    00321 }
    00322 #endif /* __cplusplus */
    00323
    00324
    00325
    00326 #ifdef WIN32
    00327 #include <poppack.h>
    00328 #endif /* WIN32 */
    00329
    00330
    00331
    00332 #endif /* __MSLIB_H__ */