Ogre: fix xml migration.
parent
d6892b3f58
commit
9234fee35e
|
@ -131,7 +131,6 @@ bool OgreXmlSerializer::ReadAttribute<bool>(XmlNode &xmlNode, const char *name)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Mesh XML constants
|
||||
|
||||
// <mesh>
|
||||
|
@ -226,17 +225,26 @@ MeshXml *OgreXmlSerializer::ImportMesh(XmlParser *parser) {
|
|||
|
||||
void OgreXmlSerializer::ReadMesh(MeshXml *mesh) {
|
||||
XmlNode root = mParser->getRootNode();
|
||||
if (nullptr == root || std::string(nnMesh) != root.name()) {
|
||||
if (nullptr == root) {
|
||||
throw DeadlyImportError("Root node is <" + std::string(root.name()) + "> expecting <mesh>");
|
||||
}
|
||||
|
||||
for (XmlNode currentNode : root.children()) {
|
||||
XmlNode startNode = root.child(nnMesh);
|
||||
if (startNode.empty()) {
|
||||
throw DeadlyImportError("Root node is <" + std::string(root.name()) + "> expecting <mesh>");
|
||||
}
|
||||
for (XmlNode currentNode : startNode.children()) {
|
||||
const std::string currentName = currentNode.name();
|
||||
if (currentName == nnSharedGeometry) {
|
||||
mesh->sharedVertexData = new VertexDataXml();
|
||||
ReadGeometry(currentNode, mesh->sharedVertexData);
|
||||
} else if (currentName == nnSubMesh) {
|
||||
ReadSubMesh(currentNode, mesh);
|
||||
} else if (currentName == nnSubMeshes) {
|
||||
for (XmlNode &subMeshesNode : currentNode.children()) {
|
||||
const std::string ¤tSMName = subMeshesNode.name();
|
||||
if (currentSMName == nnSubMesh) {
|
||||
ReadSubMesh(subMeshesNode, mesh);
|
||||
}
|
||||
}
|
||||
} else if (currentName == nnBoneAssignments) {
|
||||
ReadBoneAssignments(currentNode, mesh->sharedVertexData);
|
||||
} else if (currentName == nnSkeletonLink) {
|
||||
|
@ -289,35 +297,37 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(XmlNode &node, VertexDataXml *d
|
|||
}
|
||||
}
|
||||
|
||||
for (XmlNode currentNode : node.children()) {
|
||||
const std::string ¤tName = currentNode.name();
|
||||
for (XmlNode currentNode : node.children("vertex")) {
|
||||
for (XmlNode vertexNode : currentNode.children()) {
|
||||
const std::string ¤tName = vertexNode.name();
|
||||
if (positions && currentName == nnPosition) {
|
||||
aiVector3D pos;
|
||||
pos.x = ReadAttribute<float>(currentNode, anX);
|
||||
pos.y = ReadAttribute<float>(currentNode, anY);
|
||||
pos.z = ReadAttribute<float>(currentNode, anZ);
|
||||
pos.x = ReadAttribute<float>(vertexNode, anX);
|
||||
pos.y = ReadAttribute<float>(vertexNode, anY);
|
||||
pos.z = ReadAttribute<float>(vertexNode, anZ);
|
||||
dest->positions.push_back(pos);
|
||||
} else if (normals && currentName == nnNormal) {
|
||||
aiVector3D normal;
|
||||
normal.x = ReadAttribute<float>(currentNode, anX);
|
||||
normal.y = ReadAttribute<float>(currentNode, anY);
|
||||
normal.z = ReadAttribute<float>(currentNode, anZ);
|
||||
normal.x = ReadAttribute<float>(vertexNode, anX);
|
||||
normal.y = ReadAttribute<float>(vertexNode, anY);
|
||||
normal.z = ReadAttribute<float>(vertexNode, anZ);
|
||||
dest->normals.push_back(normal);
|
||||
} else if (tangents && currentName == nnTangent) {
|
||||
aiVector3D tangent;
|
||||
tangent.x = ReadAttribute<float>(currentNode, anX);
|
||||
tangent.y = ReadAttribute<float>(currentNode, anY);
|
||||
tangent.z = ReadAttribute<float>(currentNode, anZ);
|
||||
tangent.x = ReadAttribute<float>(vertexNode, anX);
|
||||
tangent.y = ReadAttribute<float>(vertexNode, anY);
|
||||
tangent.z = ReadAttribute<float>(vertexNode, anZ);
|
||||
dest->tangents.push_back(tangent);
|
||||
} else if (uvs > 0 && currentName == nnTexCoord) {
|
||||
for (auto &curUvs : dest->uvs) {
|
||||
aiVector3D uv;
|
||||
uv.x = ReadAttribute<float>(currentNode, "u");
|
||||
uv.y = (ReadAttribute<float>(currentNode, "v") * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||
uv.x = ReadAttribute<float>(vertexNode, "u");
|
||||
uv.y = (ReadAttribute<float>(vertexNode, "v") * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||
curUvs.push_back(uv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity checks
|
||||
if (dest->positions.size() != dest->count) {
|
||||
|
@ -371,7 +381,7 @@ void OgreXmlSerializer::ReadSubMesh(XmlNode &node, MeshXml *mesh) {
|
|||
submesh->indexData->faceCount = ReadAttribute<uint32_t>(currentNode, anCount);
|
||||
submesh->indexData->faces.reserve(submesh->indexData->faceCount);
|
||||
for (XmlNode currentChildNode : currentNode.children()) {
|
||||
const std::string ¤tChildName = currentNode.name();
|
||||
const std::string ¤tChildName = currentChildNode.name();
|
||||
if (currentChildName == nnFace) {
|
||||
aiFace face;
|
||||
face.mNumIndices = 3;
|
||||
|
@ -384,6 +394,7 @@ void OgreXmlSerializer::ReadSubMesh(XmlNode &node, MeshXml *mesh) {
|
|||
ASSIMP_LOG_WARN("Submesh <face> has quads with <v4>, only triangles are supported at the moment!");
|
||||
quadWarned = true;
|
||||
}
|
||||
submesh->indexData->faces.push_back(face);
|
||||
}
|
||||
}
|
||||
if (submesh->indexData->faces.size() == submesh->indexData->faceCount) {
|
||||
|
@ -591,7 +602,6 @@ void OgreXmlSerializer::ReadAnimationTracks(XmlNode &node, Animation *dest) {
|
|||
throw DeadlyImportError("No <keyframes> found in <track> ", dest->name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -631,9 +641,7 @@ void OgreXmlSerializer::ReadAnimationKeyFrames(XmlNode &node, Animation *anim, V
|
|||
keyframe.scale.x = ReadAttribute<float>(currentChildNode, anX);
|
||||
keyframe.scale.y = ReadAttribute<float>(currentChildNode, anY);
|
||||
keyframe.scale.z = ReadAttribute<float>(currentChildNode, anZ);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
dest->transformKeyFrames.push_back(keyframe);
|
||||
|
|
|
@ -47,15 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_X3D_IMPORTER_H
|
||||
#define INCLUDED_AI_X3D_IMPORTER_H
|
||||
|
||||
|
||||
// Header files, Assimp.
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/ProgressHandler.hpp>
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/BaseImporter.h>
|
||||
#include <assimp/XmlParser.h>
|
||||
#include <assimp/importerdesc.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/ProgressHandler.hpp>
|
||||
|
||||
#include <list>
|
||||
|
||||
|
@ -102,8 +101,6 @@ inline void LogInfo(const std::string &message) {
|
|||
DefaultLogger::get()->info(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// \class X3DImporter
|
||||
/// Class that holding scene graph which include: groups, geometry, metadata etc.
|
||||
///
|
||||
|
@ -289,16 +286,11 @@ struct X3DNodeElementBase {
|
|||
X3DElemType Type;
|
||||
};
|
||||
|
||||
class X3DImporter : public BaseImporter
|
||||
{
|
||||
class X3DImporter : public BaseImporter {
|
||||
public:
|
||||
std::list<X3DNodeElementBase *> NodeElement_List; ///< All elements of scene graph.
|
||||
|
||||
public:
|
||||
/***********************************************/
|
||||
/****************** Functions ******************/
|
||||
/***********************************************/
|
||||
|
||||
/// Default constructor.
|
||||
X3DImporter();
|
||||
|
||||
|
|
Loading…
Reference in New Issue