XFile_Defines.h

00001 
00002 struct Header
00003 {
00004         WORD MajorVersion;
00005         WORD MinorVersion;
00006         DWORD flags;
00007 };
00008 
00009 struct Vector
00010 {
00011 public:
00012         Vector(FLOAT X=0.0f,FLOAT Y =0.0f, FLOAT Z=0.0f){x = X; y=Y;z=Z;}
00013         FLOAT x;
00014         FLOAT y;
00015         FLOAT z;
00016 };
00017 
00018 struct Coords2d
00019 {
00020 public:
00021         Coords2d(FLOAT U = 0.0f, FLOAT V = 0.0f){u = U; v = V;};
00022         FLOAT u;
00023         FLOAT v;
00024 };
00025 
00026 struct Quaternion
00027 {
00028         FLOAT s;
00029         Vector v;
00030 };
00031 
00032 #ifdef _WIN32
00033 
00034 struct Matrix4x4
00035 {
00036 public:
00037         Matrix4x4(FLOAT _11 = 1.0f,FLOAT _12 = 0.0f,FLOAT _13 = 0.0f,FLOAT _14 = 0.0f,
00038                 FLOAT _21 = 0.0f,FLOAT _22 = 1.0f,FLOAT _23 = 0.0f,FLOAT _24 = 0.0f,
00039                 FLOAT _31 = 0.0f,FLOAT _32 = 0.0f,FLOAT _33 = 1.0f,FLOAT _34 = 0.0f,
00040                 FLOAT _41 = 0.0f,FLOAT _42 = 0.0f,FLOAT _43 = 0.0f,FLOAT _44 = 1.0f)
00041         {
00042                 x1 = _11; x2 = _12; x3 = _13; x4 = _14;
00043                 x5 = _21; x6 = _22; x7 = _23; x8 = _24;
00044                 x9 = _31; x10= _32; x11= _33; x12= _34;
00045                 x13= _41; x14= _42; x15= _43; x16= _44;
00046         }
00047         FLOAT x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16;
00048 };
00049 #else
00050 #include "ps2matrix4x4.h"
00051 #endif
00052 
00053 struct ColorRGBA
00054 {
00055 public:
00056         ColorRGBA(FLOAT r = 1.0f,FLOAT g = 1.0f,FLOAT b = 1.0f,FLOAT a = 1.0f)
00057         {
00058                 red = r;
00059                 green = g;
00060                 blue = b;
00061                 alpha = a;
00062         }
00063         FLOAT red;
00064         FLOAT green;
00065         FLOAT blue;
00066         FLOAT alpha;
00067 };
00068 
00069 struct ColorRGB
00070 {
00071 public:
00072         ColorRGB(FLOAT r = 1.0f,FLOAT g = 1.0f,FLOAT b = 1.0f)
00073         {
00074                 red = r;
00075                 green = g;
00076                 blue = b;
00077         }
00078         FLOAT red;
00079         FLOAT green;
00080         FLOAT blue;
00081 };
00082 
00083 struct IndexedColor
00084 {
00085         DWORD index;
00086         ColorRGBA color;
00087 };
00088 
00089 struct Boolean
00090 {
00091         DWORD truefalse;
00092 };
00093 
00094 struct Boolean2d
00095 {
00096         DWORD truefalse[2];
00097 };
00098 
00099 struct TextureFilename
00100 {
00101 public:
00102         TextureFilename()
00103         {
00104 
00105         }
00106         string szString;        // Null terminated string 
00107 };
00108 
00109 
00110 struct EffectParamDword
00111 {
00112 public:
00113         string ParamName;
00114         DWORD value;
00115 };
00116 
00117 struct EffectParamFloats
00118 {
00119 public:
00120         string ParamName;
00121         DWORD nFloats;
00122         FLOAT* Floats;
00123 };
00124 
00125 struct EffectParamString
00126 {
00127 public:
00128         string ParamName;
00129         string value;
00130 };
00131 
00132 struct EffectInstance
00133 {
00134 public:
00135         string EffectFilename;
00136 
00137         vector<EffectParamFloats*> floatParams;
00138         vector<EffectParamString*> stringPrarams;
00139         vector<EffectParamDword*> dwordParams;
00140 };
00141 
00142 
00143 struct Material
00144 {
00145 public: 
00146         Material()
00147         {
00148                 name = NULL;
00149                 nTexturesFileNames = 0;
00150                 nEffectInstances = 0;
00151         }
00152 
00153         ColorRGBA faceColour;
00154         FLOAT power;
00155         ColorRGB specularColour;
00156         ColorRGB emissiveColour;
00157         LPCSTR name;
00158 
00159         DWORD nTexturesFileNames;
00160         vector<TextureFilename*> textureFileNames;
00161 
00162         DWORD nEffectInstances;
00163         vector<EffectInstance*> effectInstances;
00164 };
00165 
00166 
00167 struct MeshFace 
00168 { 
00169         DWORD numFaceVertexIndices;
00170         DWORD* faceVertexIndices; // Array of DWORDS the size of numFaceVertexIndices
00171 };
00172 
00173 struct MeshFaceWraps 
00174 { 
00175         DWORD nFaceWrapValues;
00176         Boolean2d faceWrapValues; // Array of DWORDS the size of numFaceVertexIndices
00177 };
00178 
00179 struct MeshTextureCoords
00180 {
00181         DWORD nTextCoords; 
00182         Coords2d* textCoords; // Array of Coords2d the size of nTextCoords
00183 };
00184 
00185 struct MeshNormals
00186 {
00187         DWORD nNormals; 
00188         Vector* normals; // Array of Coords2d the size of nTextCoords
00189         DWORD nFaceNormals;
00190         MeshFace* facenormals; // Array of MeshFace the size of nFaceNormals
00191 
00192 };
00193 
00194 struct MeshVertexColors
00195 {
00196         DWORD nVertexColors;
00197         IndexedColor* vertexColor;
00198 };
00199 
00200 struct MeshMaterialList
00201 {
00202         DWORD nMaterials;
00203         DWORD nFaceIndexes;
00204         DWORD* faceIndex;
00205         vector<Material*> materials;
00206 };
00207 
00208 struct Mesh
00209 {
00210         Mesh()
00211         {
00212                 nVertices = 0;
00213                 nFaces = 0;
00214                 faces = NULL;
00215                 normals = NULL;
00216                 textureCoords = NULL;
00217                 materialList = NULL;
00218                 pFrame = NULL;
00219                 radius = 0.0f;
00220                 minX = 0.0f;
00221                 minY = 0.0f;
00222                 minZ = 0.0f;
00223                 maxX = 0.0f;
00224                 maxY = 0.0f;
00225                 maxZ = 0.0f;
00226         }
00227 
00228         string Name;
00229         DWORD nVertices;
00230         Vector* vertices;
00231         DWORD nFaces;
00232         MeshFace* faces;
00233         MeshNormals* normals;
00234         MeshTextureCoords* textureCoords;
00235         MeshMaterialList* materialList;
00236         Frame* pFrame;
00237         float radius;
00238         float minX;
00239         float minY;
00240         float minZ;
00241         float maxX;
00242         float maxY;
00243         float maxZ;
00244 
00245 };
00246 
00247 struct FrameTransformMatrix
00248 {
00249 public:
00250 
00251         FrameTransformMatrix(FLOAT _11 = 1.0f,FLOAT _12 = 0.0f,FLOAT _13 = 0.0f,FLOAT _14 = 0.0f,
00252                 FLOAT _21 = 0.0f,FLOAT _22 = 1.0f,FLOAT _23 = 0.0f,FLOAT _24 = 0.0f,
00253                 FLOAT _31 = 0.0f,FLOAT _32 = 0.0f,FLOAT _33 = 1.0f,FLOAT _34 = 0.0f,
00254                 FLOAT _41 = 0.0f,FLOAT _42 = 0.0f,FLOAT _43 = 0.0f,FLOAT _44 = 1.0f)
00255         {
00256                 frameMatrix = Matrix4x4(_11,_12,_13,_14,_21,_22,_23,_24,_31,_32,_33,_34,_41,_42,_43,_44);
00257                 transformedMatrix = frameMatrix;
00258         }
00259         Matrix4x4 transformedMatrix;
00260         Matrix4x4 frameMatrix;
00261 };
00262 
00263 struct Frame
00264 {
00265 public:
00266 
00267         Frame()
00268         {
00269                 nMeshes = 0;
00270                 transform = NULL;
00271                 parentFrame = NULL;
00272         }
00273 
00274         string Name;
00275         DWORD nMeshes;          //Frame contains any number of Mesh's and a FrameTransformMatrix 
00276         vector<Mesh*> meshes;
00277         FrameTransformMatrix* transform;
00278 
00279         Frame* parentFrame;
00280         vector<Frame*> childFrames;
00281 };
00282 
00283 struct FloatKeys
00284 {
00285         FloatKeys()
00286         {
00287                 value = NULL;
00288                 nValues = 0;
00289         }
00290 
00291         ~FloatKeys()
00292         {
00293                 for(int i = nValues; i > -1; i--)
00294                 {
00295                         if(value[i])
00296                                 value[i] = 0;
00297                 }
00298 
00299                 delete value;
00300         }
00301 
00302         DWORD nValues;
00303         FLOAT* value;
00304 
00305         Matrix4x4 valueMatrix;
00306 };
00307 
00308 struct TimedFloatKeys
00309 {
00310         TimedFloatKeys()
00311         {
00312                 time = 0;
00313                 tfkeys = NULL;
00314         }
00315 
00316         DWORD time;
00317         FloatKeys* tfkeys;
00318 };
00319 
00320 
00321 struct AnimationKey
00322 {
00323         AnimationKey()
00324         {
00325                 keyType = 4;
00326                 nKeys = 0;
00327         }
00328         int keyType;                            // 0 = Rotation (Quaternion), 1 = Scale (Vector3), 2 = Translation (Vector3), 4 = Transform (Matrix)
00329         DWORD nKeys;
00330         vector<TimedFloatKeys*> keys;
00331 };
00332 
00333 struct AnimationOptions
00334 {
00335         AnimationOptions()
00336         {
00337                 opencloased = 0;
00338                 positionquality = 1;
00339         }
00340 
00341         ~AnimationOptions()
00342         {
00343                 opencloased = 0;
00344                 positionquality = 0;
00345         }
00346 
00347         DWORD opencloased;                      // 0 = don't loop, 1 = loop
00348         DWORD positionquality;          // 0 for spline positions 1 for liner positions
00349 
00350 };
00351 
00352 struct Animation                                // contains at least one AnimationKey, and optional AnimationOptions 
00353 {
00354         Animation()
00355         {
00356                 options = NULL;
00357                 nAnimationKeys = 0;
00358                 Name ="";
00359                 BoneName = "";
00360                 pBone = NULL;
00361         }
00362 
00363         ~Animation()
00364         {
00365                 options = NULL;
00366                 nAnimationKeys = 0;
00367                 Name ="";
00368                 BoneName = "";
00369                 pBone = NULL;
00370         }
00371 
00372         AnimationOptions* options;
00373         DWORD nAnimationKeys;           // has to be at least 1
00374         vector<AnimationKey*> AnimationKeys; 
00375         string Name;
00376         string BoneName;
00377         Frame* pBone;
00378 };
00379 
00380 
00381 struct AnimationSet                             // one or more Animation Objects 
00382 {
00383         AnimationSet()
00384         {
00385                 nAnimations = 0;
00386                 Length = 0;
00387                 Name = "";
00388         }
00389 
00390         DWORD nAnimations;                      // Has to be at least 1
00391         vector<Animation*> Animations;
00392         string Name;
00393         DWORD Length;
00394 }; 
00395 
00396 
00397 
00398 #define X_TEMPLATE                  0xFF              // template
00399 #define X_HEADER                    0x1               // Header
00400 #define X_VECTOR                    0x2               // Vector
00401 #define X_COORDS2D                  0x3               // Coords2d
00402 #define X_QUATERNION                0x4               // Quaternion
00403 #define X_MATRIX4X4                 0x5               // Matrix4x4
00404 #define X_COLORRGBA                 0x6               // ColorRGBA
00405 #define X_COLORRGB                  0x7               // ColorRGB
00406 #define X_INDEXEDCOLOR              0x8               // IndexedColor
00407 #define X_BOOLEAN                   0x9               // Boolean
00408 #define X_BOOLEAN2D                 0x10              // Boolean2d
00409 #define X_MATERIAL                  0x11              // Material
00410 #define X_TEXTUREFILENAME           0x12              // TextureFilename
00411 #define X_MESHFACE                  0x13              // MeshFace
00412 #define X_MESHFACEWRAPS             0x14              // MeshFaceWraps
00413 #define X_MESHTEXTURECOORDS         0x15              // MeshTextureCoords
00414 #define X_MESHNORMALS               0x16              // MeshNormals
00415 #define X_MESHVERTEXCOLORS          0x17              // MeshVertexColors
00416 #define X_MESHMATERIALLIST          0x18              // MeshMaterialList
00417 #define X_MESH                      0x19              // Mesh
00418 #define X_FRAMETRANSFORMMATRIX      0x20              // FrameTransformMatrix
00419 #define X_FRAME                     0x21              // Frame
00420 #define X_FLOATKEYS                 0x22              // FloatKeys
00421 #define X_TIMEDFLOATKEYS            0x23              // TimedFloatKeys
00422 #define X_ANIMATIONKEY              0x24              // AnimationKey
00423 #define X_ANIMATIONOPTIONS          0x25              // AnimationOptions
00424 #define X_ANIMATION                 0x26              // Animation
00425 #define X_ANIMATIONSET              0x27              // AnimationSet
00426 #define X_EFFECTINSTANCE                        0x28
00427 #define X_EFFECTPARAMFLOATS                     0x29 
00428 #define X_EFFECTPARAMSTRING                     0x30 
00429 #define X_EFFECTPARAMDWORD                      0x31
00430 #define X_SKINMESHHEADER                        0x32 
00431 #define X_SKINWEIGHTS                           0x33 
00432 #define X_VERTEXDUPLICATIONINDICES  0x34 
00433 #define X_UNSUPPORTED                           0x35
00434 
00435 struct stXDefines
00436 {
00437         int ID;
00438         char* str; 
00439 };
00440 
00441 const static stXDefines DirectX_FileTemplates[] =
00442 {
00443         {       X_UNSUPPORTED,                    "UNSUPPORTED"                           },
00444         {  X_TEMPLATE,                "template"                    },
00445         {  X_HEADER,                  "Header"                      },
00446         {  X_VECTOR,                  "Vector"                      },
00447         {  X_COORDS2D,                "Coords2d"                    },
00448         {  X_QUATERNION,              "Quaternion"                  },
00449         {  X_MATRIX4X4,               "Matrix4x4"                   },
00450         {  X_COLORRGBA,               "ColorRGBA"                   },
00451         {  X_COLORRGB,                "ColorRGB"                    },
00452         {  X_INDEXEDCOLOR,            "IndexedColor"                },
00453         {  X_BOOLEAN,                 "Boolean"                     },
00454         {  X_BOOLEAN2D,               "Boolean2d"                   },
00455         {  X_MATERIAL,                "Material"                    },
00456         {  X_TEXTUREFILENAME,         "TextureFilename"             },
00457         {  X_MESHFACE,                "MeshFace"                    },
00458         {  X_MESHFACEWRAPS,           "MeshFaceWraps"               },
00459         {  X_MESHTEXTURECOORDS,       "MeshTextureCoords"           },
00460         {  X_MESHNORMALS,             "MeshNormals"                 },
00461         {  X_MESHVERTEXCOLORS,        "MeshVertexColors"            },
00462         {  X_MESHMATERIALLIST,        "MeshMaterialList"            },
00463         {  X_MESH,                    "Mesh"                        },
00464         {  X_FRAMETRANSFORMMATRIX,    "FrameTransformMatrix"        },
00465         {  X_FRAME,                   "Frame"                       },
00466         {  X_FLOATKEYS,               "FloatKeys"                   },
00467         {  X_TIMEDFLOATKEYS,          "TimedFloatKeys"              },
00468         {  X_ANIMATIONKEY,            "AnimationKey"                },
00469         {  X_ANIMATIONOPTIONS,        "AnimationOptions"            },
00470         {  X_ANIMATION,               "Animation"                   },
00471         {  X_ANIMATIONSET,            "AnimationSet"                },
00472         {        X_EFFECTINSTANCE,                      "EffectInstance"                          },
00473         {        X_EFFECTPARAMFLOATS,           "EffectParamFloats"                       },
00474         {        X_EFFECTPARAMDWORD,            "EffectParamDWord"                        },
00475         {        X_EFFECTPARAMSTRING,           "EffectParamString"                       },
00476         {        X_EFFECTPARAMFLOATS,           "EffectFloats"                            },
00477         {        X_EFFECTPARAMDWORD,            "EffectDWord"                         },
00478         {        X_EFFECTPARAMSTRING,           "EffectString"                            },
00479         {        X_SKINMESHHEADER,                      "XSkinMeshHeader"                         },
00480         {        X_SKINWEIGHTS,                         "SkinWeights"                             },
00481         {        X_VERTEXDUPLICATIONINDICES,"VertexDuplicationIndices"    }
00482 
00483 };

Generated on Sun May 18 21:45:09 2008 for PS2X by  doxygen 1.5.4