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_PLXML_H__
00024 #define __PLMESH_MESHLOADER_PLXML_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 MeshLoaderPLXml : public MeshLoader {
00069
00070
00071
00072
00073
00074 pl_class(PLMESH_RTTI_EXPORT, MeshLoaderPLXml, "PLMesh", PLMesh::MeshLoader, "Mesh loader implementation for the PixelLight mesh XML file format")
00075
00076 pl_properties
00077 pl_property("Formats", "xmesh,XMESH")
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 MeshLoaderPLXml();
00108
00109
00110
00111
00112
00113 PLMESH_API virtual ~MeshLoaderPLXml();
00114
00115
00116
00117
00118
00119 private:
00120
00121 bool LoadV1(Mesh &cMesh, const PLCore::XmlElement &cMeshElement, bool bStatic) const;
00122 bool ReadMaterials(Mesh &cMesh, const PLCore::XmlElement &cMaterialsElement) const;
00123 bool ReadLODLevels(Mesh &cMesh, const PLCore::XmlElement &cLODLevelsElement, bool bStatic) const;
00124 bool ReadLODLevel(MeshLODLevel &cLODLevel, const PLCore::XmlElement &cLODLevelElement, bool bStatic) const;
00125 bool ReadIndexBuffer(PLRenderer::IndexBuffer &cIndexBuffer, const PLCore::XmlElement &cIndexBufferElement, bool bStatic) const;
00126 bool ReadGeometry(Geometry &cGeometry, const PLCore::XmlElement &cGeometryElement) const;
00127 bool ReadMorphTargets(Mesh &cMesh, const PLCore::XmlElement &cMorphTargetsElement, bool bStatic) const;
00128 bool ReadMorphTarget(MeshMorphTarget &cMorphTarget, const PLCore::XmlElement &cMorphTargetElement, bool bStatic) const;
00129 bool ReadVertexBuffer(PLRenderer::VertexBuffer &cVertexBuffer, PLCore::uint32 nIndex, const PLCore::XmlElement &cVertexBufferElement, bool bStatic) const;
00130 bool ReadVertexAttribute(PLRenderer::VertexBuffer &cVertexBuffer, const PLCore::XmlElement &cVertexAttributeElement) const;
00131 bool ReadWeights(Mesh &cMesh, const PLCore::XmlElement &cWeightsElement) const;
00132 bool ReadVertexWeightsContainer(Mesh &cMesh, const PLCore::XmlElement &cVertexWeightsContainerElement) const;
00133 bool ReadSkeletons(Mesh &cMesh, const PLCore::XmlElement &cSkeletonsElement) const;
00134 bool ReadSkeleton(Mesh &cMesh, const PLCore::XmlElement &cSkeletonElement) const;
00135 bool ReadAnchorPoints(Mesh &cMesh, const PLCore::XmlElement &cAnchorPointsElement) const;
00136 bool ReadAnimations(PLCore::File &cFile) const;
00137 bool ReadMorphTargetAnimations(Mesh &cMesh, const PLCore::XmlElement &cMorphTargetAnimationsElement) const;
00138 bool ReadMorphTargetAnimation(Mesh &cMesh, const PLCore::XmlElement &cMorphTargetElement) const;
00139 bool ReadMeshBoundingBox(Mesh &cMesh, const PLCore::XmlElement &cBoundingBoxElement) const;
00140
00141
00142
00143
00144
00145 private:
00146
00147 bool WriteMeshFile(Mesh &cMesh, PLCore::XmlElement &cMeshElement) const;
00148 bool WriteMaterials(const Mesh &cMesh, PLCore::XmlElement &cMeshElement) const;
00149 bool WriteMesh(Mesh &cMesh, PLCore::XmlElement &cMeshElement) const;
00150 bool WriteLODLevel(MeshLODLevel &cLODLevel, PLCore::uint32 nID, PLCore::XmlElement &cLODLevelsElement) const;
00151 bool WriteIndexBuffer(PLRenderer::IndexBuffer &cIndexBuffer, PLCore::XmlElement &cLODLevelElement) const;
00152 bool WriteGeometry(const Geometry &cGeometry, PLCore::uint32 nID, PLCore::XmlElement &cGeometriesElement) const;
00153 bool WriteWeight(const Weight &cWeight, PLCore::uint32 nID, PLCore::XmlElement &cWeightsElement) const;
00154 bool WriteVertexWeights(VertexWeights &cVertexWeights, PLCore::uint32 nID, PLCore::XmlElement &cVertexWeightsElement) const;
00155 bool WriteMorphTarget(MeshMorphTarget &cMorphTarget, PLCore::uint32 nID, PLCore::XmlElement &cMorphTargetsElement) const;
00156 bool WriteVertexBuffer(PLRenderer::VertexBuffer &cVertexBuffer, PLCore::uint32 nID, PLCore::XmlElement &pVertexBuffersElement) const;
00157 bool WriteVertexAttribute(const PLRenderer::VertexBuffer::Attribute &cVertexAttribute, PLCore::uint32 nID, PLCore::XmlElement &cVertexAttributesElement) const;
00158 bool WriteSkeleton(Skeleton &cSkeleton, PLCore::uint32 nID, PLCore::XmlElement &cSkeletonsElement) const;
00159 bool WriteAnchorPoints(Mesh &cMesh, PLCore::XmlElement &cMeshElement) const;
00160
00161
00162 bool WriteMorphTargetAnimation(Mesh &cMesh, PLCore::uint32 nAnimation, PLCore::XmlElement &cMorphTargetAnimationsElement) const;
00163 bool WriteMeshBoundingBox(const Mesh &cMesh, PLCore::XmlElement &cMeshElement) const;
00164
00165
00166 };
00167
00168
00169
00170
00171
00172 }
00173
00174
00175 #endif // __PLMESH_MESHLOADER_PLXML_H__