-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AnimationImporter.cs #16
Comments
Hi just realized that its the Max who adds this extra Animation tag layer per bone... and therefore it was not working right... |
Hello Niittis! Thanks for reporting this issue. But I'm a bit confused: Shouldn't The typical animation I was expecting looks like the following example:
If your COLLADA files differ greatly I would like to see the relevant code fragment, if you don't mind. |
The problem lies on the way 3DMax exports the animations. <library_animations>
*<animation id="Bip01_R_Forearm-anim" name="Bip01_R_Forearm">
<animation>
<source id="Bip01_R_Forearm-Matrix-animation-input">
<source id="Bip01_R_Forearm-Matrix-animation-output-transform">
<source id="Bip01_R_Forearm-Interpolations">
<sampler id="Bip01_R_Forearm-Matrix-animation-transform">
<channel source="#Bip01_R_Forearm-Matrix-animation-transform" target="Bip01_R_Forearm/matrix"/>
* </animation>
*</animation>
*<animation id="Bip01_L_Forearm-anim" name="Bip01_L_Forearm">
* <animation>
<source id="Bip01_L_Forearm-Matrix-animation-input">
<source id="Bip01_L_Forearm-Matrix-animation-output-transform">
<source id="Bip01_L_Forearm-Interpolations">
<sampler id="Bip01_L_Forearm-Matrix-animation-transform">
<channel source="#Bip01_L_Forearm-Matrix-animation-transform" target="Bip01_L_Forearm/matrix"/>
* </animation>
</animation> The structure is more nested in 3DMax, however if the lines marked with "*" would be removed the result should be the same. There was a piece of code in AnimationImporter.cs trying to Merge the animations, but it did not work. // Try to merge all animations (must be extended to consider animation clips)
// NOTE: Didn't work for Maya animations, something's still of with them
if (animations.Count > 1 )//&& false)
{
try
{
var animation = MergeAnimations(animations);
animations.Clear();
animations.Add(animation);
}
catch (Exception)
{
// didn't work, ignore
}
} I am thinking of trying to identify the case before parsing and then move/feed the inner animation nodes to the first sibling, that should end up into expected syntax and therefore could be handled like the others. |
During the XML reorganizer testing I started to think that the XmlNode xmlChannel = xmlAnimation.SelectSingleNode("//channel");
if (xmlChannel == null)
{
throw new Exception("Animation '" + xmlAnimation.Attributes["id"].Value +
"' does not contain a channel:" + xmlAnimation.ChildNodes.Count);
}
string target = xmlChannel.Attributes["target"].Value;
return joints.ContainsKey(ExtractNodeIdFromTarget(target)); It should check if even one of the channels uses existing joints before ignoring the whole animation Something like this: // If any of the channels affects the joints, this is a valid animation.
XmlNodeList xmlChannels = xmlAnimation.SelectNodes("//channel");
if (xmlChannels == null)
{
throw new Exception("Animation '" + xmlAnimation.Attributes["id"].Value +
"' does not contain a channel:" + xmlAnimation.ChildNodes.Count);
}
foreach ( XmlNode xmlChannel in xmlChannels)
{
string target = xmlChannel.Attributes["target"].Value;
if (joints.ContainsKey(ExtractNodeIdFromTarget(target)))
{
return true;
}
}
return false; |
Yes you are right, I guess I assumed that was always only one channel present in an animation, just as I assumed that animations wouldn't be nested, because my test models met these assumptions. However, obviously and as stated in the specification animation elements can actually be nested and more than one channel (or none at all) can be present. It's both a blessing and a curse that there are so many different ways to represent essentially the same data in COLLADA. My importer is a very non-generic implementation that just presumes the most simple cases. By the way I always used the option "bake animation" in the FBX/DAE exporter of 3ds max, which could possibly help you here, too, because this should merge everything into one simple animation. As for multiple channels, I don't know if they are also joined by "baking" the animation, but your altered code would fix that particular issue anyway. I just commited the equivalently changed method to github in hopes that it doesn't break anything (my test cases still worked, but who knows). |
Hi
In the Titles file function:
static bool DoesAnimationAffectJoints(Dictionary<string, Joint> joints, XmlNode xmlAnimation)
Lines:
XmlNode xmlChannel = xmlAnimation.SelectSingleNode("//channel");
----- 8<----------------
string target = xmlChannel.Attributes["target"].Value;
Seems always to ALWAYS inspect the first animations channels target, instead of the parameters one..
It started to work more nicely with following line:
XmlNode xmlChannel = xmlAnimation.SelectSingleNode("animation/channel");
Does this make any sense... ?
I found this when Animators Max spitted out some animated joints without any frames.
Best,
Niittis
ps. Thanks for nice piece of Code.
The text was updated successfully, but these errors were encountered: