Skip to content

Commit

Permalink
XMLConverter: replace tinyxml by pugixml
Browse files Browse the repository at this point in the history
the former is unmaintained and has an arcane API
  • Loading branch information
paroj committed Jun 25, 2019
1 parent 68b9ae2 commit 3381033
Show file tree
Hide file tree
Showing 13 changed files with 645 additions and 6,620 deletions.
26 changes: 4 additions & 22 deletions Tools/XMLConverter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,13 @@ set(SOURCE_FILES
src/OgreXMLSkeletonSerializer.cpp
)

# If TinyXML is not found on the system use the embedded version.
if(NOT TINYXML_FOUND)
list(APPEND SOURCE_FILES
src/tinystr.cpp
src/tinyxml.cpp
src/tinyxmlerror.cpp
src/tinyxmlparser.cpp)
# allow override by cmake
find_package(pugixml)

list(APPEND HEADER_FILES
include/tinystr.h
include/tinyxml.h)

set(TINYXML_INCLUDE_DIR "")
set(TINYXML_LIBRARIES "")
endif(NOT TINYXML_FOUND)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${TINYXML_INCLUDE_DIR})
add_definitions(-DTIXML_USE_STL)

if(UNIX)
add_definitions(-Wno-shadow -Wno-implicit-fallthrough) # inside tinyxml sources
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_executable(OgreXMLConverter ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(OgreXMLConverter ${OGRE_LIBRARIES} ${TINYXML_LIBRARIES} ${OGRE_MeshLodGenerator_LIBRARIES})
target_link_libraries(OgreXMLConverter ${OGRE_LIBRARIES} pugixml ${OGRE_MeshLodGenerator_LIBRARIES})

if (APPLE)
set_target_properties(OgreXMLConverter PROPERTIES
Expand Down
64 changes: 31 additions & 33 deletions Tools/XMLConverter/include/OgreXMLMeshSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,48 +63,46 @@ namespace Ogre {
void exportMesh(const Mesh* pMesh, const String& filename);

protected:
// State for export
TiXmlDocument* mXMLDoc;
// State for import
Mesh* mMesh;
VertexElementType mColourElementType;

// Internal methods
void writeMesh(const Mesh* pMesh);
void writeSubMesh(TiXmlElement* mSubmeshesNode, const SubMesh* s);
void writeGeometry(TiXmlElement* mParentNode, const VertexData* pData);
void writeSkeletonLink(TiXmlElement* mMeshNode, const String& skelName);
void writeBoneAssignment(TiXmlElement* mBoneAssignNode, const VertexBoneAssignment* assign);
void writeTextureAliases(TiXmlElement* mSubmeshesNode, const SubMesh* s);
void writeLodInfo(TiXmlElement* mMeshNode, const Mesh* pMesh);
void writeLodUsageManual(TiXmlElement* usageNode, unsigned short levelNum,
void writeMesh(const Mesh* pMesh, pugi::xml_node& rootNode);
void writeSubMesh(pugi::xml_node& mSubmeshesNode, const SubMesh* s);
void writeGeometry(pugi::xml_node& mParentNode, const VertexData* pData);
void writeSkeletonLink(pugi::xml_node& mMeshNode, const String& skelName);
void writeBoneAssignment(pugi::xml_node& mBoneAssignNode, const VertexBoneAssignment* assign);
void writeTextureAliases(pugi::xml_node& mSubmeshesNode, const SubMesh* s);
void writeLodInfo(pugi::xml_node& mMeshNode, const Mesh* pMesh);
void writeLodUsageManual(pugi::xml_node& usageNode, unsigned short levelNum,
const MeshLodUsage& usage);
void writeLodUsageGenerated(TiXmlElement* usageNode, unsigned short levelNum,
void writeLodUsageGenerated(pugi::xml_node& usageNode, unsigned short levelNum,
const MeshLodUsage& usage, const Mesh* pMesh);
void writeSubMeshNames(TiXmlElement* mMeshNode, const Mesh* m);
void writePoses(TiXmlElement* meshNode, const Mesh* m);
void writeAnimations(TiXmlElement* meshNode, const Mesh* m);
void writeMorphKeyFrames(TiXmlElement* trackNode, const VertexAnimationTrack* track);
void writePoseKeyFrames(TiXmlElement* trackNode, const VertexAnimationTrack* track);
void writeExtremes(TiXmlElement* mMeshNode, const Mesh* m);
void writeSubMeshNames(pugi::xml_node& mMeshNode, const Mesh* m);
void writePoses(pugi::xml_node& meshNode, const Mesh* m);
void writeAnimations(pugi::xml_node& meshNode, const Mesh* m);
void writeMorphKeyFrames(pugi::xml_node& trackNode, const VertexAnimationTrack* track);
void writePoseKeyFrames(pugi::xml_node& trackNode, const VertexAnimationTrack* track);
void writeExtremes(pugi::xml_node& mMeshNode, const Mesh* m);

void readSubMeshes(TiXmlElement* mSubmeshesNode);
void readGeometry(TiXmlElement* mGeometryNode, VertexData* pData);
void readSkeletonLink(TiXmlElement* mSkelNode);
void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode);
void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode, SubMesh* sm);
void readTextureAliases(TiXmlElement* mTextureAliasesNode, SubMesh* sm);
void readLodInfo(TiXmlElement* lodNode);
void readLodUsageManual(TiXmlElement* manualNode, unsigned short index);
void readLodUsageGenerated(TiXmlElement* genNode, unsigned short index);
void readSubMeshNames(TiXmlElement* mMeshNamesNode, Mesh* sm);
void readPoses(TiXmlElement* posesNode, Mesh *m);
void readAnimations(TiXmlElement* mAnimationsNode, Mesh *m);
void readTracks(TiXmlElement* tracksNode, Mesh *m, Animation* anim);
void readMorphKeyFrames(TiXmlElement* keyframesNode, VertexAnimationTrack* track,
void readSubMeshes(pugi::xml_node& mSubmeshesNode);
void readGeometry(pugi::xml_node& mGeometryNode, VertexData* pData);
void readSkeletonLink(pugi::xml_node& mSkelNode);
void readBoneAssignments(pugi::xml_node& mBoneAssignmentsNode);
void readBoneAssignments(pugi::xml_node& mBoneAssignmentsNode, SubMesh* sm);
void readTextureAliases(pugi::xml_node& mTextureAliasesNode, SubMesh* sm);
void readLodInfo(pugi::xml_node& lodNode);
void readLodUsageManual(pugi::xml_node& manualNode, unsigned short index);
void readLodUsageGenerated(pugi::xml_node& genNode, unsigned short index);
void readSubMeshNames(pugi::xml_node& mMeshNamesNode, Mesh* sm);
void readPoses(pugi::xml_node& posesNode, Mesh *m);
void readAnimations(pugi::xml_node& mAnimationsNode, Mesh *m);
void readTracks(pugi::xml_node& tracksNode, Mesh *m, Animation* anim);
void readMorphKeyFrames(pugi::xml_node& keyframesNode, VertexAnimationTrack* track,
size_t vertexCount);
void readPoseKeyFrames(TiXmlElement* keyframesNode, VertexAnimationTrack* track);
void readExtremes(TiXmlElement* extremesNode, Mesh *m);
void readPoseKeyFrames(pugi::xml_node& keyframesNode, VertexAnimationTrack* track);
void readExtremes(pugi::xml_node& extremesNode, Mesh *m);
};
}

Expand Down
2 changes: 1 addition & 1 deletion Tools/XMLConverter/include/OgreXMLPrerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ THE SOFTWARE.
#include "OgrePrerequisites.h"

// Include tinyxml headers
#include "tinyxml.h"
#include <pugixml.hpp>


#endif
29 changes: 13 additions & 16 deletions Tools/XMLConverter/include/OgreXMLSkeletonSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,22 @@ namespace Ogre {
void exportSkeleton(const Skeleton* pSkeleton, const String& filename);

private:
// State for export
TiXmlDocument* mXMLDoc;

void writeSkeleton(const Skeleton* pSkel);
void writeBone(TiXmlElement* bonesElement, const Bone* pBone);
void writeBoneParent(TiXmlElement* boneHierarchyNode, String boneName , String parentName);
void writeAnimation(TiXmlElement* animsNode, const Animation* anim);
void writeAnimationTrack(TiXmlElement* tracksNode,
void writeSkeleton(const Skeleton* pSkel, pugi::xml_node& root);
void writeBone(pugi::xml_node& bonesElement, const Bone* pBone);
void writeBoneParent(pugi::xml_node& boneHierarchyNode, String boneName , String parentName);
void writeAnimation(pugi::xml_node& animsNode, const Animation* anim);
void writeAnimationTrack(pugi::xml_node& tracksNode,
const NodeAnimationTrack* track);
void writeKeyFrame(TiXmlElement* keysNode, const TransformKeyFrame* key);
void writeSkeletonAnimationLink(TiXmlElement* linksNode,
void writeKeyFrame(pugi::xml_node& keysNode, const TransformKeyFrame* key);
void writeSkeletonAnimationLink(pugi::xml_node& linksNode,
const LinkedSkeletonAnimationSource& link);

void readBones(Skeleton* skel, TiXmlElement* mBonesNode);
void readBones2(Skeleton* skel, TiXmlElement* mBonesNode);
void createHierarchy(Skeleton* skel, TiXmlElement* mHierNode);
void readKeyFrames(NodeAnimationTrack* track, TiXmlElement* mKeyfNode);
void readAnimations(Skeleton* skel, TiXmlElement* mAnimNode) ;
void readSkeletonAnimationLinks(Skeleton* skel, TiXmlElement* linksNode);
void readBones(Skeleton* skel, pugi::xml_node& mBonesNode);
void readBones2(Skeleton* skel, pugi::xml_node& mBonesNode);
void createHierarchy(Skeleton* skel, pugi::xml_node& mHierNode);
void readKeyFrames(NodeAnimationTrack* track, const pugi::xml_node& mKeyfNode);
void readAnimations(Skeleton* skel, pugi::xml_node& mAnimNode) ;
void readSkeletonAnimationLinks(Skeleton* skel, pugi::xml_node& linksNode);

};

Expand Down
Loading

0 comments on commit 3381033

Please sign in to comment.