PixelLightAPI  .
MeshLoaderPL.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: MeshLoaderPL.h                                 *
00003  *
00004  *  Copyright (C) 2002-2012 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_PL_H__
00024 #define __PLMESH_MESHLOADER_PL_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 binary (Little-Endian) file format
00067 */
00068 class MeshLoaderPL : public MeshLoader {
00069 
00070 
00071     //[-------------------------------------------------------]
00072     //[ RTTI interface                                        ]
00073     //[-------------------------------------------------------]
00074     pl_class(PLMESH_RTTI_EXPORT, MeshLoaderPL, "PLMesh", PLMesh::MeshLoader, "Mesh loader implementation for the PixelLight mesh binary (Little-Endian) file format")
00075         // Properties
00076         pl_properties
00077             pl_property("Formats",  "mesh,MESH")
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 MeshLoaderPL();
00108 
00109         /**
00110         *  @brief
00111         *    Destructor
00112         */
00113         PLMESH_API virtual ~MeshLoaderPL();
00114 
00115 
00116     //[-------------------------------------------------------]
00117     //[ File loading                                          ]
00118     //[-------------------------------------------------------]
00119     private:
00120         // File loading
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         // Tools
00139         MeshFile::Chunk ReadChunk(PLCore::File &cFile) const;
00140 
00141 
00142     //[-------------------------------------------------------]
00143     //[ File saving                                           ]
00144     //[-------------------------------------------------------]
00145     private:
00146         // File saving
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 // [TODO] Update this
00161 //      bool WriteAnimations(const Mesh &cMesh, PLCore::File &cFile, PLCore::Stack<MeshFile::Chunk> &cChunkStack) const;
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         // Tools
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 //[ Namespace                                             ]
00175 //[-------------------------------------------------------]
00176 } // PLMesh
00177 
00178 
00179 #endif // __PLMESH_MESHLOADER_PL_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:57
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported