00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLMESH_MESHLOADER_PL_H__
00024 #define __PLMESH_MESHLOADER_PL_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include <PLRenderer/Renderer/VertexBuffer.h>
00032 #include "PLMesh/Loader/MeshFile.h"
00033 #include "PLMesh/Loader/MeshLoader.h"
00034
00035
00036
00037
00038
00039 namespace PLCore {
00040 template <class AType> class Stack;
00041 }
00042 namespace PLRenderer {
00043 class IndexBuffer;
00044 }
00045 namespace PLMesh {
00046 class Weight;
00047 class Skeleton;
00048 class Geometry;
00049 class MeshLODLevel;
00050 class VertexWeights;
00051 class MeshMorphTarget;
00052 }
00053
00054
00055
00056
00057
00058 namespace PLMesh {
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class MeshLoaderPL : public MeshLoader {
00069
00070
00071
00072
00073
00074 pl_class(PLMESH_RTTI_EXPORT, MeshLoaderPL, "PLMesh", PLMesh::MeshLoader, "Mesh loader implementation for the PixelLight mesh binary (Little-Endian) file format")
00075
00076 pl_properties
00077 pl_property("Formats", "mesh,MESH")
00078 pl_property("Load", "1")
00079 pl_property("Save", "1")
00080 pl_properties_end
00081
00082 pl_constructor_0(DefaultConstructor, "Default constructor", "")
00083
00084 pl_method_2(Load, pl_ret_type(bool), Mesh&, PLCore::File&, "Load method. The loaded mesh is static.", "")
00085 pl_method_3(LoadParams, pl_ret_type(bool), Mesh&, PLCore::File&, bool, "Load method. Parameters: First 'bool' parameter determines whether or not the mesh is static.", "")
00086 pl_method_2(Save, pl_ret_type(bool), Mesh&, PLCore::File&, "Save method", "")
00087 pl_class_end
00088
00089
00090
00091
00092
00093 public:
00094 PLMESH_API bool Load(Mesh &cMesh, PLCore::File &cFile);
00095 PLMESH_API bool LoadParams(Mesh &cMesh, PLCore::File &cFile, bool bStatic);
00096 PLMESH_API bool Save(Mesh &cMesh, PLCore::File &cFile);
00097
00098
00099
00100
00101
00102 public:
00103
00104
00105
00106
00107 PLMESH_API MeshLoaderPL();
00108
00109
00110
00111
00112
00113 PLMESH_API virtual ~MeshLoaderPL();
00114
00115
00116
00117
00118
00119 private:
00120
00121 bool ReadMeshFile(Mesh &cMesh, PLCore::File &cFile, MeshFile::Chunk &cChunk, bool bStatic) const;
00122 bool ReadMaterials(Mesh &cMesh, PLCore::File &cFile) const;
00123 bool ReadMesh(Mesh &cMesh, PLCore::File &cFile, bool bStatic) const;
00124 bool ReadLODLevel(PLCore::File &cFile, MeshLODLevel &cLODLevel, bool bStatic) const;
00125 bool ReadIndexBuffer(PLCore::File &cFile, PLRenderer::IndexBuffer &cIndexBuffer, bool bStatic) const;
00126 bool ReadGeometry(PLCore::File &cFile, Geometry &cGeometry) const;
00127 bool ReadWeight(PLCore::File &cFile, Weight &cWeight) const;
00128 bool ReadVertexWeights(PLCore::File &cFile, VertexWeights &cVertexWeights) const;
00129 bool ReadMorphTarget(PLCore::File &cFile, MeshMorphTarget &cMorphTarget, bool bStatic) const;
00130 bool ReadVertexBuffer(PLCore::File &cFile, PLRenderer::VertexBuffer &cVertexBuffer, PLCore::uint32 nIndex, bool bStatic) const;
00131 bool ReadVertexAttribute(PLCore::File &cFile, PLRenderer::VertexBuffer &cVertexBuffer) const;
00132 bool ReadSkeleton(Mesh &cMesh, PLCore::File &cFile) const;
00133 bool ReadAnchorPoints(Mesh &cMesh, PLCore::File &cFile) const;
00134 bool ReadAnimations(PLCore::File &cFile) const;
00135 bool ReadMorphTargetAnimation(Mesh &cMesh, PLCore::File &cFile) const;
00136 bool ReadMeshBoundingBox(Mesh &cMesh, PLCore::File &cFile) const;
00137
00138
00139 MeshFile::Chunk ReadChunk(PLCore::File &cFile) const;
00140
00141
00142
00143
00144
00145 private:
00146
00147 bool WriteMeshFile(Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00148 bool WriteMaterials(const Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00149 bool WriteMesh(Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00150 bool WriteLODLevel(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, MeshLODLevel &cLODLevel) const;
00151 bool WriteIndexBuffer(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, PLRenderer::IndexBuffer &cIndexBuffer) const;
00152 bool WriteGeometry(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, const Geometry &cGeometry) const;
00153 bool WriteWeight(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, const Weight &cWeight) const;
00154 bool WriteVertexWeights(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, VertexWeights &cVertexWeights) const;
00155 bool WriteMorphTarget(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, MeshMorphTarget &cMorphTarget) const;
00156 bool WriteVertexBuffer(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, PLRenderer::VertexBuffer &cVertexBuffer) const;
00157 bool WriteVertexAttribute(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, const PLRenderer::VertexBuffer::Attribute &cVertexAttribute) const;
00158 bool WriteSkeleton(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, Skeleton &cSkeleton) const;
00159 bool WriteAnchorPoints(Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00160
00161
00162 bool WriteMorphTargetAnimation(Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, PLCore::uint32 nAnimation) const;
00163 bool WriteMeshBoundingBox(const Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00164
00165
00166 bool BeginChunk(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack, PLCore::uint32 nType) const;
00167 bool EndChunk(PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
00168
00169
00170 };
00171
00172
00173
00174
00175
00176 }
00177
00178
00179 #endif // __PLMESH_MESHLOADER_PL_H__