Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_MESHLOADER_MS3D_H__
00009 #define __SP_MESHLOADER_MS3D_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_MESHLOADER_MS3D
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 <ios>
00023 #include <vector>
00024 #include <string>
00025 #include <fstream>
00026
00027
00028 namespace sp
00029 {
00030 namespace scene
00031 {
00032
00033
00034 class SP_EXPORT MeshLoaderMS3D : public MeshLoader
00035 {
00036
00037 public:
00038
00039 MeshLoaderMS3D();
00040 ~MeshLoaderMS3D();
00041
00042 Mesh* loadMesh(const io::stringc &Filename, const io::stringc &TexturePath);
00043
00044 private:
00045
00046
00047
00048 struct SMeshMS3D
00049 {
00050 s32 MaterialIndex;
00051 s32 CountOfTriangles;
00052 s32* pTriangleIndices;
00053 };
00054
00055 struct SMaterialMS3D
00056 {
00057 f32 Ambient[4], Diffuse[4], Specular[4], Emissive[4];
00058 f32 Shininess;
00059 f32 Transparency;
00060 video::Texture* hTexture;
00061 c8* TextureFilename;
00062 };
00063
00064 struct STriangleMS3D
00065 {
00066 f32 VertexNormals[3][3];
00067 f32 TexCoordU[3];
00068 f32 TexCoordV[3];
00069 s32 Vertices[3];
00070 };
00071
00072 struct SVertexMS3D
00073 {
00074 s8 BoneID;
00075 dim::vector3df Position;
00076 };
00077
00078
00079
00080 struct SKeyframeMS3D
00081 {
00082 s32 JointIndex;
00083 f32 Time;
00084 dim::vector3df Vector;
00085 };
00086
00087 struct SJointMS3D
00088 {
00089 io::stringc Name;
00090 s32 Index, Parent;
00091
00092 dim::vector3df Rotation, Translation;
00093
00094 std::vector<SKeyframeMS3D> RotationKeyframes;
00095 std::vector<SKeyframeMS3D> TranslationKeyframes;
00096 };
00097
00098 struct SJointNameListRecMS3D
00099 {
00100 s32 JointIndex;
00101 const char* Name;
00102 };
00103
00104
00105
00106 bool loadModelData(io::stringc Filename);
00107 void buildAnimation();
00108 Mesh* buildModel();
00109
00110 void addJointKeyframe(
00111 const s32 JointIndex, SJointMS3D &Joint, void* KeyframeBuffer, bool isTypeRotation
00112 );
00113 void fillBoneWeights(
00114 const s32 JointIndex, std::vector<SVertexGroup> &VertexGroups
00115 );
00116
00117 bool setNextBufferPos(const u8* &BufferPtr, s32 NextPos);
00118
00119 dim::matrix4f getAnimRotation(dim::vector3df Rotation);
00120
00121
00122
00123 inline video::color getArrayColor(f32 Clr[4])
00124 {
00125 video::color Result;
00126 Result.setFloatArray(Clr);
00127 return Result;
00128 }
00129
00130
00131
00132
00133 s32 CountOfMeshes_;
00134 SMeshMS3D* pMeshes_;
00135
00136
00137 s32 CountOfMaterials_;
00138 SMaterialMS3D* pMaterials_;
00139
00140
00141 s32 CountOfTriangles_;
00142 STriangleMS3D* pTriangles_;
00143
00144
00145 s32 CountOfVertcies_;
00146 SVertexMS3D* pVertices_;
00147
00148
00149 s32 CountOfJoints_;
00150 SJointMS3D* pJoints_;
00151 SJointNameListRecMS3D* pNameList_;
00152
00153 f64 TotalTime_;
00154
00155 f32 TotalFrames_, FPS_;
00156
00157 s32 FileSize_;
00158 u8* pBuffer_;
00159
00160 };
00161
00162
00163 }
00164
00165 }
00166
00167
00168 #endif
00169
00170 #endif
00171
00172
00173
00174