Problem importing Model w/ XML file

Topics: User Forum
Feb 27, 2007 at 5:18 PM
I get this error:
System.Collections.Generic.KeyNotFoundException was unhandled

On this line in LoadGraphicsContent:
IdleTorso = new AnimationController(this, MechTorsoAnimator.Animations["idle"]);

I can view the Model fine in the DirectX Viewer and I have the default dwarfmodel project working fine, so the problem seems to be with my xml file. It doesn't seem to be getting read in properly (if at all).

Model filename is "mechguns.x"
XML filename is "mechgunsanimation.xml", and here's it's contents:
<animation>
	<name>AnimationSet0</name>
	<tickspersecond>30.0</tickspersecond>
	<animationsubset>
		<name>idle</name>
		<startframe>0</startframe>
		<endframe>1</endframe>
	</animationsubset>
	<animationsubset>
	<name>walk</name>
		<startframe>1</startframe>
		<endframe>60</endframe>
	</animationsubset>
	<animationsubset>
	<name>run</name>
		<startframe>61</startframe>
		<endframe>100</endframe>
	</animationsubset>
</animation>
Coordinator
Feb 27, 2007 at 5:54 PM
Edited Feb 27, 2007 at 5:58 PM
Only think I can think of is that AnimationSet0 isn't the name of the animation in the file. If you want to send me the file via email (david_astle@hotmail.com), I can take a look.

This brings up a good point though - most people who are using the xml method of splitting up the animation are using modeling programs that can only export one animation per model. So, the name should be optional.

This feature will be included in the next release that I'll post up later today or tomorrow.
Feb 27, 2007 at 7:38 PM

dastle wrote:
Only think I can think of is that AnimationSet0 isn't the name of the animation in the file.


Ya that was the problem. It exported it as "Anim-1".
Mar 27, 2007 at 12:32 PM
Hi, I'm having the same problem, I'm getting the same error at the same place. However as far as I can tell the animation is named "AnimationSet0" in both the XML and .X file.

Heres the line where I get the error:
idle = new AnimationController(this,
dwarfAnimator.Animations"walk");




This is from the XML file:
<animation>
<name>AnimationSet0</name>
<tickspersecond>15.0</tickspersecond>
<animationsubset>
<name>walk</name>
<startframe>1</startframe>
<endframe>14</endframe>
</animationsubset>



And this is a cut from the .X file:
AnimationSet AnimationSet0
{
Animation
{
AnimationKey
{
4;
2;
0; 16; 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000;;,
107640; 16; 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000;;;
}
{ Scene_Root }


Anyone know what I'm doing wrong?
Mar 27, 2007 at 1:22 PM
Hi, Sorted it, Forgot to set importer and processor when I changed the animations over :-D
Apr 8, 2007 at 11:47 PM
Hi. I get the error "Object reference not set to an instance of an object." For this line "idle = new AnimationController(this, dwarfAnimator.Animations"idle0");" in the tutorial. Does anyone know how I can fix this. Thanks a lot.
Coordinator
Apr 9, 2007 at 2:49 AM
Have you added the XML file to your project and rebuilt the solution?
Apr 9, 2007 at 5:32 AM
Edited Apr 9, 2007 at 5:40 AM
yes i have. Does the XML file need to be set TRUE for XNA Framework Content? Thanks.
Coordinator
Apr 9, 2007 at 8:05 AM
No, that doesn't matter. The important thing is that the model and the xml file are in the same directory. I just tell people to add it to their project because it ensures that it is in the same directory any model they add to their project.

This is strange - does idle = new AnimationController(this, dwarfAnimator.Animations0);
work? I.E., is it working when you only index the first element in dwarfAnimator.Animations?
By rebuild the solution, I mean select "rebuild all." Don't know if I was clear on that.
Apr 9, 2007 at 3:27 PM
Thanks for responding. No it doesn't change anything I still get the error. I can view the dwarf model prior to the Idle Animation step. But I could not view it in Direct X viewer from the beginning, I don't know if that makes a difference. Not sure what I'm doing wrong.
Coordinator
Apr 9, 2007 at 9:15 PM
Edited Apr 9, 2007 at 9:16 PM
Try using the solution I posted in the using custom effects section:
http://www.codeplex.com/animationcomponents/Project/FileDownload.aspx?DownloadId=10040
Apr 10, 2007 at 2:57 PM
Great! That works for me. The code looks a bit different from that of the tutorial. So I will take a look @ it and try to replicate it. Also what solution do you recommend for Alias Maya or Motionbuilder for generating XML files with .X or FBX files repectively. Thanks again!
Coordinator
Apr 10, 2007 at 3:49 PM
Well, here is the solution for the first tutorial, which I just posted today. You probably want to look at this instead:
http://www.codeplex.com/animationcomponents/Project/FileDownload.aspx?DownloadId=10136
Coordinator
Apr 11, 2007 at 12:25 PM
"Also what solution do you recommend for Alias Maya or Motionbuilder for generating XML files with .X or FBX files repectively."

If you are lucky enough to be able to export multiple animations in one file, none is needed. Otherwise, you have to make them by hand, or just create a separate model for each animation and combine the animations at runtime or at build time by subclassing AnimatedModelProcessor.
Aug 10, 2007 at 1:22 AM
I'm having a very related but different issue that may in fact be what some other people are also experiencing, but with some more depth.

I have my file, exported via Maya, ApacheHelicopter.fbx. I created the ApacheHelicopteranimation.xml file, just as follows:

<animation>
<name>Take 001</name>
<tickspersecond>15.0</tickspersecond>
<animationsubset>
<name>Off</name>
<startframe>1</startframe>
<endframe>2</endframe>
</animationsubset>
<animationsubset>
<name>Idle</name>
<startframe>510</startframe>
<endframe>540</endframe>
</animationsubset>
<animationsubset>
<name>ChargeUp</name>
<startframe>1</startframe>
<endframe>500</endframe>
</animationsubset>
</animation>

However, during runtime, I attempt the following line of code:

this.ApacheOff = new AnimationController(this, this.ApacheAnimator.Animations"Off");

I get a KeyNotFoundException, just like a lot of other posts here. Stepping through my code, I noticed something peculiar that is not present with the Animated Dwarf example, there is only 1 animation, and it's called "Take 001". The array (or arraylist, or whatever...) holding all the animations has 1 element. So, it is taking the animation name, not the animation subset name. This is being reversed, and I don't know if its because I'm using .fbx, but other people seem to be able to load their .fbx files just fine.

I compiled and stepped through the Dwarf example, and there are 24 some-odd number of animations. and the array is properly filled with each one. Comparing the xml files and project setups, everything seems to be the same.

I'm beginning to wonder if it is the version of Maya I'm using to export my models. I have "Maya®, Version 7.0, 200507192211 07/19/2005"

Thank you for this, this is a great tool. It helps people (like me) take things to a whole new level without having to think nearly as much about implementing animations. You guys are allowing the rest of us to think more about other aspects of our games. Thus we are allowed to put more time, and therefore quality, into other parts of our code. I'm sure you all know that, but that's my rant of appreciation, so appreciate it! (kidding...)

Thanks, guys.
Grorange
Aug 10, 2007 at 2:24 AM
http://www.codeplex.com/animationcomponents/Thread/View.aspx?ThreadId=7279

I swear I got to page 10 or so before posting my question, but I kept reading. And found this post. I realized that putting the name of the "Take" in there screwed up the whole thing. I simply took it out and I got what I was looking for.

Thanks,
Grorange