Merge branch 'master' into master

pull/4490/head
Kim Kulling 2022-04-24 18:17:33 +02:00 committed by GitHub
commit d14bff5a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 12 deletions

View File

@ -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 &currentChildNode : currentNode.children()) { for (XmlNode &currentChildNode : 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 &currentChildNode : currentNode.children()) { for (XmlNode &currentChildNode : 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 &currentChildNode : currentNode.children()) { for (XmlNode &currentChildNode : 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 &currentChildChildNode : currentNode.children()) { for (XmlNode &currentChildChildNode : currentChildNode.children()) {
const std::string currentChildChildName = currentNode.name(); 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 &currentChildNode : currentNode.children()) { for (XmlNode &currentChildNode : currentNode.children()) {
const std::string currentChildName = currentNode.name(); const std::string currentChildName = currentChildNode.name();
if (currentChildName == nnRotation) { 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 &currentChildChildName = currentChildChildNode.name(); const std::string &currentChildChildName = currentChildChildNode.name();

View File

@ -10,7 +10,7 @@ endif()
set(draco_root "${CMAKE_CURRENT_SOURCE_DIR}") set(draco_root "${CMAKE_CURRENT_SOURCE_DIR}")
set(draco_src_root "${draco_root}/src/draco") set(draco_src_root "${draco_root}/src/draco")
set(draco_build "${CMAKE_BINARY_DIR}") set(draco_build "${Assimp_BINARY_DIR}")
if("${draco_root}" STREQUAL "${draco_build}") if("${draco_root}" STREQUAL "${draco_build}")
message( message(