Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_MESHLOADER_MD3_H__
00009 #define __SP_MESHLOADER_MD3_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_MESHLOADER_MD3
00015
00016
00017 #include "Base/spInputOutputLog.hpp"
00018 #include "Base/spDimension.hpp"
00019 #include "RenderSystem/spTextureBase.hpp"
00020 #include "FileFormats/Mesh/spMeshLoader.hpp"
00021
00022 #include <vector>
00023 #include <string>
00024
00025
00026 namespace sp
00027 {
00028 namespace scene
00029 {
00030
00031
00032 class SP_EXPORT MeshLoaderMD3 : public MeshLoader
00033 {
00034
00035 public:
00036
00037 MeshLoaderMD3();
00038 ~MeshLoaderMD3();
00039
00040 Mesh* loadMesh(const io::stringc &Filename, const io::stringc &TexturePath);
00041
00042 private:
00043
00044
00045
00046 struct SHeaderMD3
00047 {
00048 s32 ID;
00049 s32 Version;
00050
00051 c8 PathName[64];
00052
00053 s32 Flags;
00054
00055 s32 CountOfKeyframes;
00056 s32 CountOfTags;
00057 s32 CountOfSurfaces;
00058 s32 CountOfSkins;
00059
00060 s32 KeyframeOffset;
00061 s32 TagsOffset;
00062 s32 SurfaceOffset;
00063 s32 EndOfFileOffset;
00064 };
00065
00066 struct SVertexMD3
00067 {
00068 s16 Coord[3];
00069 u8 Normal[2];
00070 };
00071
00072 struct STexCoordMD3
00073 {
00074 f32 TexCoord[2];
00075 };
00076
00077 struct STriangleMD3
00078 {
00079 s32 Indices[3];
00080 };
00081
00082 struct SShaderMD3
00083 {
00084 c8 PathName[64];
00085 s32 ShaderIndex;
00086 };
00087
00088 struct SKeyFrameMD3
00089 {
00090 dim::vector3df MinBounds;
00091 dim::vector3df MaxBounds;
00092 dim::vector3df LocalOrigin;
00093 f32 Radius;
00094 c8 Name[16];
00095 };
00096
00097 struct STagMD3
00098 {
00099 c8 Name[64];
00100 dim::vector3df Origin;
00101 dim::vector3df RotationAxles[3];
00102 };
00103
00104 struct SSurfaceMD3
00105 {
00106 s32 ID;
00107
00108 c8 Name[64];
00109
00110 s32 Flags;
00111
00112 s32 CountOfFrames;
00113 s32 CountOfShaders;
00114 s32 CountOfVertices;
00115 s32 CountOfTriangles;
00116
00117 s32 TriangleOffset;
00118 s32 ShaderOffset;
00119 s32 TexCoordOffset;
00120 s32 VertexOffset;
00121 s32 EndOffset;
00122 };
00123
00124 struct SSurfaceKeyframes
00125 {
00126 video::MeshBuffer* Surface;
00127 std::vector< std::vector<SVertexKeyframe> > Keyframes;
00128 };
00129
00130
00131
00132 bool loadModelData();
00133 bool loadHeader();
00134 bool loadSurfaces();
00135 bool loadKeyframes();
00136
00137 void buildAnimation();
00138 Mesh* buildModel();
00139
00140 void interpolate(dim::vector3df* VerticesList);
00141
00142
00143
00144 SHeaderMD3 Header_;
00145
00146 std::vector<SSurfaceKeyframes> KeyframeList_;
00147
00148 };
00149
00150
00151 }
00152
00153 }
00154
00155
00156 #endif
00157
00158 #endif
00159
00160
00161
00162