|
@@ -248,6 +248,7 @@ void OgreXmlSerializer::ReadMesh(MeshXml *mesh) {
|
|
} else if (currentName == nnBoneAssignments) {
|
|
} else if (currentName == nnBoneAssignments) {
|
|
ReadBoneAssignments(currentNode, mesh->sharedVertexData);
|
|
ReadBoneAssignments(currentNode, mesh->sharedVertexData);
|
|
} else if (currentName == nnSkeletonLink) {
|
|
} else if (currentName == nnSkeletonLink) {
|
|
|
|
+ mesh->skeletonRef = currentNode.attribute("name").as_string();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -488,6 +489,15 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *me
|
|
Skeleton *skeleton = new Skeleton();
|
|
Skeleton *skeleton = new Skeleton();
|
|
OgreXmlSerializer serializer(xmlParser.get());
|
|
OgreXmlSerializer serializer(xmlParser.get());
|
|
XmlNode root = xmlParser->getRootNode();
|
|
XmlNode root = xmlParser->getRootNode();
|
|
|
|
+ if (std::string(root.name()) != nnSkeleton) {
|
|
|
|
+ printf("\nSkeleton is not a valid root: %s\n", root.name());
|
|
|
|
+ for (auto &a : root.children()) {
|
|
|
|
+ if (std::string(a.name()) == nnSkeleton) {
|
|
|
|
+ root = a;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
serializer.ReadSkeleton(root, skeleton);
|
|
serializer.ReadSkeleton(root, skeleton);
|
|
mesh->skeleton = skeleton;
|
|
mesh->skeleton = skeleton;
|
|
return true;
|
|
return true;
|
|
@@ -537,7 +547,7 @@ XmlParserPtr OgreXmlSerializer::OpenXmlParser(Assimp::IOSystem *pIOHandler, cons
|
|
}
|
|
}
|
|
|
|
|
|
void OgreXmlSerializer::ReadSkeleton(XmlNode &node, Skeleton *skeleton) {
|
|
void OgreXmlSerializer::ReadSkeleton(XmlNode &node, Skeleton *skeleton) {
|
|
- if (node.name() != nnSkeleton) {
|
|
|
|
|
|
+ if (std::string(node.name()) != nnSkeleton) {
|
|
throw DeadlyImportError("Root node is <" + std::string(node.name()) + "> expecting <skeleton>");
|
|
throw DeadlyImportError("Root node is <" + std::string(node.name()) + "> expecting <skeleton>");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -574,14 +584,14 @@ void OgreXmlSerializer::ReadAnimations(XmlNode &node, Skeleton *skeleton) {
|
|
anim->name = ReadAttribute<std::string>(currentNode, "name");
|
|
anim->name = ReadAttribute<std::string>(currentNode, "name");
|
|
anim->length = ReadAttribute<float>(currentNode, "length");
|
|
anim->length = ReadAttribute<float>(currentNode, "length");
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
- const std::string currentChildName = currentNode.name();
|
|
|
|
|
|
+ const std::string currentChildName = currentChildNode.name();
|
|
if (currentChildName == nnTracks) {
|
|
if (currentChildName == nnTracks) {
|
|
ReadAnimationTracks(currentChildNode, anim);
|
|
ReadAnimationTracks(currentChildNode, anim);
|
|
- skeleton->animations.push_back(anim);
|
|
|
|
} else {
|
|
} else {
|
|
throw DeadlyImportError("No <tracks> found in <animation> ", anim->name);
|
|
throw DeadlyImportError("No <tracks> found in <animation> ", anim->name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ skeleton->animations.push_back(anim);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -594,14 +604,14 @@ void OgreXmlSerializer::ReadAnimationTracks(XmlNode &node, Animation *dest) {
|
|
track.type = VertexAnimationTrack::VAT_TRANSFORM;
|
|
track.type = VertexAnimationTrack::VAT_TRANSFORM;
|
|
track.boneName = ReadAttribute<std::string>(currentNode, "bone");
|
|
track.boneName = ReadAttribute<std::string>(currentNode, "bone");
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
- const std::string currentChildName = currentNode.name();
|
|
|
|
|
|
+ const std::string currentChildName = currentChildNode.name();
|
|
if (currentChildName == nnKeyFrames) {
|
|
if (currentChildName == nnKeyFrames) {
|
|
ReadAnimationKeyFrames(currentChildNode, dest, &track);
|
|
ReadAnimationKeyFrames(currentChildNode, dest, &track);
|
|
- dest->tracks.push_back(track);
|
|
|
|
} else {
|
|
} else {
|
|
throw DeadlyImportError("No <keyframes> found in <track> ", dest->name);
|
|
throw DeadlyImportError("No <keyframes> found in <track> ", dest->name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ dest->tracks.push_back(track);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -614,15 +624,15 @@ void OgreXmlSerializer::ReadAnimationKeyFrames(XmlNode &node, Animation *anim, V
|
|
if (currentName == nnKeyFrame) {
|
|
if (currentName == nnKeyFrame) {
|
|
keyframe.timePos = ReadAttribute<float>(currentNode, "time");
|
|
keyframe.timePos = ReadAttribute<float>(currentNode, "time");
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
- const std::string currentChildName = currentNode.name();
|
|
|
|
|
|
+ const std::string currentChildName = currentChildNode.name();
|
|
if (currentChildName == nnTranslate) {
|
|
if (currentChildName == nnTranslate) {
|
|
keyframe.position.x = ReadAttribute<float>(currentChildNode, anX);
|
|
keyframe.position.x = ReadAttribute<float>(currentChildNode, anX);
|
|
keyframe.position.y = ReadAttribute<float>(currentChildNode, anY);
|
|
keyframe.position.y = ReadAttribute<float>(currentChildNode, anY);
|
|
keyframe.position.z = ReadAttribute<float>(currentChildNode, anZ);
|
|
keyframe.position.z = ReadAttribute<float>(currentChildNode, anZ);
|
|
} else if (currentChildName == nnRotate) {
|
|
} else if (currentChildName == nnRotate) {
|
|
float angle = ReadAttribute<float>(currentChildNode, "angle");
|
|
float angle = ReadAttribute<float>(currentChildNode, "angle");
|
|
- for (XmlNode ¤tChildChildNode : currentNode.children()) {
|
|
|
|
- const std::string currentChildChildName = currentNode.name();
|
|
|
|
|
|
+ for (XmlNode ¤tChildChildNode : currentChildNode.children()) {
|
|
|
|
+ const std::string currentChildChildName = currentChildChildNode.name();
|
|
if (currentChildChildName == nnAxis) {
|
|
if (currentChildChildName == nnAxis) {
|
|
aiVector3D axis;
|
|
aiVector3D axis;
|
|
axis.x = ReadAttribute<float>(currentChildChildNode, anX);
|
|
axis.x = ReadAttribute<float>(currentChildChildNode, anX);
|
|
@@ -695,12 +705,12 @@ void OgreXmlSerializer::ReadBones(XmlNode &node, Skeleton *skeleton) {
|
|
bone->id = ReadAttribute<uint16_t>(currentNode, "id");
|
|
bone->id = ReadAttribute<uint16_t>(currentNode, "id");
|
|
bone->name = ReadAttribute<std::string>(currentNode, "name");
|
|
bone->name = ReadAttribute<std::string>(currentNode, "name");
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
for (XmlNode ¤tChildNode : currentNode.children()) {
|
|
- const std::string currentChildName = currentNode.name();
|
|
|
|
- if (currentChildName == nnRotation) {
|
|
|
|
|
|
+ const std::string currentChildName = currentChildNode.name();
|
|
|
|
+ if (currentChildName == nnPosition) {
|
|
bone->position.x = ReadAttribute<float>(currentChildNode, anX);
|
|
bone->position.x = ReadAttribute<float>(currentChildNode, anX);
|
|
bone->position.y = ReadAttribute<float>(currentChildNode, anY);
|
|
bone->position.y = ReadAttribute<float>(currentChildNode, anY);
|
|
bone->position.z = ReadAttribute<float>(currentChildNode, anZ);
|
|
bone->position.z = ReadAttribute<float>(currentChildNode, anZ);
|
|
- } else if (currentChildName == nnScale) {
|
|
|
|
|
|
+ } else if (currentChildName == nnRotation) {
|
|
float angle = ReadAttribute<float>(currentChildNode, "angle");
|
|
float angle = ReadAttribute<float>(currentChildNode, "angle");
|
|
for (XmlNode currentChildChildNode : currentChildNode.children()) {
|
|
for (XmlNode currentChildChildNode : currentChildNode.children()) {
|
|
const std::string ¤tChildChildName = currentChildChildNode.name();
|
|
const std::string ¤tChildChildName = currentChildChildNode.name();
|