PixelLightAPI  .
MeshLoaderPLXml.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: MeshLoaderPLXml.h                              *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLMESH_MESHLOADER_PLXML_H__
00024 #define __PLMESH_MESHLOADER_PLXML_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLRenderer/Renderer/VertexBuffer.h>
00032 #include "PLMesh/Loader/MeshFile.h"
00033 #include "PLMesh/Loader/MeshLoader.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Forward declarations                                  ]
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 //[ Namespace                                             ]
00057 //[-------------------------------------------------------]
00058 namespace PLMesh {
00059 
00060 
00061 //[-------------------------------------------------------]
00062 //[ Classes                                               ]
00063 //[-------------------------------------------------------]
00064 /**
00065 *  @brief
00066 *    Mesh loader implementation for the PixelLight mesh XML file format
00067 */
00068 class MeshLoaderPLXml : public MeshLoader {
00069 
00070 
00071     //[-------------------------------------------------------]
00072     //[ RTTI interface                                        ]
00073     //[-------------------------------------------------------]
00074     pl_class(PLMESH_RTTI_EXPORT, MeshLoaderPLXml, "PLMesh", PLMesh::MeshLoader, "Mesh loader implementation for the PixelLight mesh XML file format")
00075         // Properties
00076         pl_properties
00077             pl_property("Formats",  "xmesh,XMESH")
00078             pl_property("Load",     "1")
00079             pl_property("Save",     "1")
00080         pl_properties_end
00081         // Constructors
00082         pl_constructor_0(DefaultConstructor,    "Default constructor",  "")
00083         // Methods
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     //[ Public RTTI methods                                   ]
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     //[ Public functions                                      ]
00101     //[-------------------------------------------------------]
00102     public:
00103         /**
00104         *  @brief
00105         *    Default constructor
00106         */
00107         PLMESH_API MeshLoaderPLXml();
00108 
00109         /**
00110         *  @brief
00111         *    Destructor
00112         */
00113         PLMESH_API virtual ~MeshLoaderPLXml();
00114 
00115 
00116     //[-------------------------------------------------------]
00117     //[ File loading                                          ]
00118     //[-------------------------------------------------------]
00119     private:
00120         // File loading
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     //[ File saving                                           ]
00144     //[-------------------------------------------------------]
00145     private:
00146         // File saving
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 // [TODO] Update this
00161 //      bool WriteAnimations(const Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
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 //[ Namespace                                             ]
00171 //[-------------------------------------------------------]
00172 } // PLMesh
00173 
00174 
00175 #endif // __PLMESH_MESHLOADER_PLXML_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:58
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported