diff --git a/bone.cpp b/bone.cpp index 71c3308..5b7d999 100644 --- a/bone.cpp +++ b/bone.cpp @@ -32,7 +32,7 @@ namespace vb01{ Vector3 Bone::getModelSpacePos(){ Vector3 modelSpacePos = Vector3::VEC_ZERO; Bone *rootBone = skeleton->getRootBone(); - vector boneHierarchy = getAncestors(); + vector boneHierarchy = getAncestors(rootBone); while(!boneHierarchy.empty()){ int id = boneHierarchy.size() - 1; diff --git a/script.py b/script.py index c2862b4..6488704 100644 --- a/script.py +++ b/script.py @@ -41,7 +41,16 @@ def exportData(ob): file.write('\n' + bone.name + ': ' + ('None' if bone.parent is None else bone.parent.name) + " " + str(bone.length) + " " + str(head.x) + " " + str(head.y) + " " + str(head.z) + " " + str(xAxis.x) + " " + str(xAxis.y) + " " + str(xAxis.z) + " " + str(yAxis.x) + " " + str(yAxis.y) + " " + str(yAxis.z) + " " + ikTarget + ' ' + str(chainLength) + ' ') if numAnims > 0: - file.write("\nanimations: " + str(numAnims)) + numGroups = 0 + for nlaStrip in ob.animation_data.nla_tracks[0].strips: + animName = nlaStrip.name + action = bpy.data.actions[animName] + for group in action.groups: + numGroups += 1; + + + file.write('\nanimations: ' + str(numAnims)) + file.write('\ngroups: ' + str(numGroups)) for nlaStrip in ob.animation_data.nla_tracks[0].strips: animName = nlaStrip.name action = bpy.data.actions[animName] @@ -57,12 +66,12 @@ def exportData(ob): start = nlaStrip.frame_start end = nlaStrip.frame_end - file.write(animName + ' ' + group.name + ' ') + file.write(animName + ' ' + group.name + ' ' + str(len(group.channels)) + ' ') for channel in group.channels: numKeyframes = len(channel.keyframe_points) channelType = getChannelType(channel) - file.write(str(numKeyframes) + ' ' + channelType + ' ') + file.write(channelType + ' ') file.write('\n') diff --git a/vbModelReader.cpp b/vbModelReader.cpp index c9d2e53..21cd93a 100644 --- a/vbModelReader.cpp +++ b/vbModelReader.cpp @@ -25,19 +25,19 @@ namespace vb01{ vector data; for(it = skeletonBracketIds.begin(); it != skeletonBracketIds.end(); ++it){ int key = it->first; - readFile(path, data, key, skeletonBracketIds[key]); + readFile(path, data, key + 1, skeletonBracketIds[key]); skeletons.push_back(readSkeleton(data)); data.clear(); } for(it = meshBracketIds.begin(); it != meshBracketIds.end(); ++it){ int key = it->first; - readFile(path, data, key, meshBracketIds[key]); + readFile(path, data, key + 1, meshBracketIds[key]); buildMesh(data); data.clear(); } for(it = lightBracketIds.begin(); it != lightBracketIds.end(); ++it){ int key = it->first; - readFile(path, data, key, lightBracketIds[key]); + readFile(path, data, key + 1, lightBracketIds[key]); readLights(data); data.clear(); } @@ -222,13 +222,15 @@ namespace vb01{ string data[3]; getLineData(line, data, 3); + int boneStartLine = 6; int numBones = atoi(data[1].c_str()); - line = skeletonData[6 + numBones].substr(getCharId(skeletonData[6 + numBones], ':') + 2); + + line = skeletonData[boneStartLine + numBones].substr(getCharId(skeletonData[boneStartLine + numBones], ':') + 2); int numAnimations = atoi(line.c_str()); - line = skeletonData[7 + numBones].substr(getCharId(skeletonData[7 + numBones], ':') + 2); + + line = skeletonData[boneStartLine + numBones + 1].substr(getCharId(skeletonData[boneStartLine + numBones + 1], ':') + 2); int numKeyframeGroups = atoi(line.c_str()); - int boneStartLine = 6; int animationStartLine = boneStartLine + numBones + 2; int keyframeGroupStartLine = animationStartLine + numAnimations; int keyframeStartLine = keyframeGroupStartLine + numKeyframeGroups; diff --git a/vbModelReaderTest.cpp b/vbModelReaderTest.cpp index dcb9b7f..1badf7b 100644 --- a/vbModelReaderTest.cpp +++ b/vbModelReaderTest.cpp @@ -48,7 +48,7 @@ namespace vb01{ skeletonData.push_back(b.name + ": " + b.parent + " " + headStr + xAxisStr + yAxisStr + b.ikTarget + " " + to_string(b.ikChainLength) + " "); } skeletonData.push_back("animations: 1 "); - skeletonData.push_back("channels: 2 "); + skeletonData.push_back("groups: 2 "); skeletonData.push_back("animation: Action "); skeletonData.push_back("Action bipod.L 7 pos_x pos_y pos_z rot_w rot_x rot_y rot_z "); skeletonData.push_back("Action bipod.R 6 pos_x pos_y pos_z rot_w rot_x rot_y "); @@ -144,12 +144,10 @@ namespace vb01{ CPPUNIT_ASSERT(skeleton->getBone(i)->getName() == bones[i].name); vb01::Bone *parent = (vb01::Bone*)skeleton->getBone(i)->getParent(); - /* if(parent->getName() != "") CPPUNIT_ASSERT(parent->getName() == bones[i].parent); else CPPUNIT_ASSERT(bones[i].parent == "-"); - */ } AnimationController *controller = skeleton->getAnimationController(); Animation *animation = controller->getAnimation("Action");