Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_MESHLOADER_SPM_H__
00009 #define __SP_MESHLOADER_SPM_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_MESHLOADER_SPM
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 static const s32 SPM_MAGIC_NUMBER = *((s32*)"SPMD");
00033 static const u16 SPM_VERSION_MIN_NR = 0x2000;
00034 static const u16 SPM_VERSION_NUMBER = 0x2100;
00035
00036 enum EModelSPMChunkFlags
00037 {
00038 MDLSPM_CHUNK_NONE = 0x0000,
00039
00040
00041 MDLSPM_CHUNK_GOURAUDSHADING = 0x0008,
00042 MDLSPM_CHUNK_NODE_ANIM = 0x0010,
00043 MDLSPM_CHUNK_MORPHTARGET_ANIM = 0x0020,
00044 MDLSPM_CHUNK_SKELETAL_ANIM = 0x0040,
00045
00046
00047 MDLSPM_CHUNK_INDEX32BIT = 0x0001,
00048 MDLSPM_CHUNK_VERTEXCOLOR = 0x0002,
00049 MDLSPM_CHUNK_VERTEXFOG = 0x0004,
00050 MDLSPM_CHUNK_VERTEXNORMAL = 0x0008,
00051
00052
00053 MDLSPM_CHUNK_TEXTUREINTERN = 0x0010,
00054 MDLSPM_CHUNK_TEXTUREMATRIX = 0x0020,
00055 };
00056
00057
00058 class SP_EXPORT MeshLoaderSPM : public MeshLoader
00059 {
00060
00061 public:
00062
00063 MeshLoaderSPM();
00064 ~MeshLoaderSPM();
00065
00066 Mesh* loadMesh(const io::stringc &Filename, const io::stringc &TexturePath);
00067
00068 private:
00069
00070
00071
00072 struct SVertexWeightSPM
00073 {
00074 SVertexWeightSPM() :
00075 Surface (0 ),
00076 Index (0 ),
00077 Weight (0.0f )
00078 {
00079 }
00080 ~SVertexWeightSPM()
00081 {
00082 }
00083
00084
00085 u32 Surface;
00086 u32 Index;
00087 f32 Weight;
00088 };
00089
00090 struct SKeyframeSPM
00091 {
00092 SKeyframeSPM() :
00093 Frame(0)
00094 {
00095 }
00096 ~SKeyframeSPM()
00097 {
00098 }
00099
00100
00101 u32 Frame;
00102 dim::vector3df Position;
00103 dim::quaternion Rotation;
00104 dim::vector3df Scale;
00105 };
00106
00107 struct SJointSPM
00108 {
00109 SJointSPM() :
00110 Parent (-1 ),
00111 JointObject (0 )
00112 {
00113 }
00114 ~SJointSPM()
00115 {
00116 }
00117
00118
00119 io::stringc Name;
00120 s32 Parent;
00121
00122 dim::vector3df Position;
00123 dim::quaternion Rotation;
00124 dim::vector3df Scale;
00125
00126 scene::AnimationJoint* JointObject;
00127 std::list<SVertexWeightSPM> VertexWeights;
00128 std::list<SKeyframeSPM> Keyframes;
00129 };
00130
00131
00132
00133 bool readHeader();
00134
00135 void readChunkObject();
00136 void readChunkSubMesh(Mesh* SubMesh);
00137 void readChunkSurface();
00138 void readChunkVertex(u32 Index);
00139 void readChunkTriangle(u32 Index);
00140 void readChunkTexture();
00141
00142 void readChunkAnimationNode();
00143 void readChunkAnimationMorphTarget();
00144 void readChunkAnimationSkeletal();
00145 void readChunkAnimationJoint(SJointSPM &Joint);
00146
00147
00148
00149 Mesh* CurMesh_;
00150
00151 u16 FormatVersion_;
00152
00153 bool has32BitIndices_;
00154 bool hasVertexColors_;
00155 bool hasVertexFogCoords_;
00156 bool hasVertexNormals_;
00157
00158 u8 TexCoordsDimensions_[MAX_COUNT_OF_TEXTURES];
00159 video::color DefaultVertexColor_;
00160 f32 DefaultVertexFogCoord_;
00161
00162 u8 TexLayerCount_;
00163
00164 std::vector<SJointSPM> Joints_;
00165
00166 };
00167
00168
00169 }
00170
00171 }
00172
00173
00174 #endif
00175
00176 #endif
00177
00178
00179
00180