This project is read-only.

xen 2.0 animation error

Oct 18, 2010 at 5:46 PM

I'm getting this error
if (animationIndex == -1)
                throw new ArgumentException();
When I try to run my code after porting it to 2.0. Up till now, this is the first time I've seen this error. Any ideas what's causing it?

Oct 18, 2010 at 8:14 PM

Also, my models (.fbx format), are partially white, most of the t4exture is ok., but sections of a certain flesh-tone colour are completely white. I don't know if it helps, but the section not showing up is a solid colour, as opposed to the photo-texture that does. Both are combined into a single jpeg.

Nov 21, 2010 at 7:56 AM

Hey dirtysteve,

 

You posted this awhile back and I wanted to know if you ever found out your issue with the white textures.  I think I just opened a discussion that is basically this problem...  I believe the model importer for Xen2.0 doesn't work correctly for FBX files.

 

The animationIndex error you'd get is because the model importer doesn't import all FBX animations, causing your calls to set an animation to return -1.  Which then give you the above error.

I'm also having issues with the textures not working correctly.

 

I'm starting to look at it now and if I find a fix, I'll post it here and in my other post.

 

Thanks,

ilarion

 

Nov 23, 2010 at 8:54 AM

Hey dirtysteve,

 

I hope you found your issue.  I am using Blender and it appears it likes to export textures with an emissive setting of 1,1,1.  This causes the textures to become completely white when imported into Xen.

 

A quick fix to see if this is your issue  (if your still having it), is to search the FBX file (if its ascii formatted) and replace any lines that have "Emissive" or "EmissiveColor" set to 1,1,1 to 0,0,0.

 

Cheers,

ilarion

Dec 8, 2010 at 5:46 PM

I'll try that, thanks :)

Jan 10, 2011 at 2:01 AM

Yes, that quick fix for the textures works. Still no idea about the animations though, do we have to wait for the Xen 2.0 model importer to get fixed, or is there a workaround?

Jan 10, 2011 at 10:50 PM

Hey Dirty Steve,

 

Are you using Blender for your animations?

Perhaps this post on gamedev will help you (http://www.gamedev.net/topic/592224-blender-25-to-xna-4---with-animations/page__p__4754831#entry4754831)

Basically, XNA 4.0 uses an updated FBXImporter which got rid of importing multi-take animations from Blender.  So to fix it you have to break up your animations and import than separately.  If you don't, then when you read in a multi-take animation file, it only reads in the first animation.  If you then try to play any other animation besides the first one, it will complain and give you the error above (basically, telling you that it couldn't find the animation).

 

Before it stops at that point in the code, place a break point and look at your model data.  Look through the Animations list and see if you imported all the animations you expect for that model.  If not, then something went wrong with the model import.

 

Cheers,

ilarion

 

 

Jan 10, 2011 at 11:20 PM
Edited Jan 10, 2011 at 11:34 PM

Thanks, Ill give it a lash tomorrow, have you tried this yet?, I was curious as to the exact process, do you export from blender into one model/armature file, and several animation files? And how does Xen deal with importing the separate animation files then?
And yes, I use Blender, I saw the option in 2.56 to split the model across separate takes, though I think they may have messed up the script in 2.56. At any rate, it's good to know there's a fix.

Jan 12, 2011 at 10:33 PM

I managed to get the model imported, but I'm still having several problems. For some odd reason the code to draw the bounding spheres only works on certain bones, but not on others. Head and chest are fine, the others don't appear. I also cant get keyboard input working, is it something to do with this update code?

KeyboardInputState keyboardState = state.KeyboardState;
            //Movement code
            Vector3 playerPositionAdd = Vector3.Zero;
          
            if (keyboardState.KeyState.Space.OnPressed)
            {
                comboEnabled = true;
                StopAnimations();
                Punch = control.PlayAnimation(punchIndex);               
            }        

            else if (Punch.Time >= .3)
            {
                StopAnimations();
                Stance = control.PlayLoopingAnimation(stanceIndex);
                comboTimer = 0.0f;
            }
            if (keyboardState.KeyState.LeftShift.OnPressed)
            {
                StopAnimations();
                LowKick = control.PlayAnimation(lowKickIndex);
                LowKick.PlaybackSpeed = 1.5f;
            }
            else if (LowKick.Time >= .5)
            {
                StopAnimations();
                Stance = control.PlayLoopingAnimation(stanceIndex);
            }
            if (keyboardState.KeyState.A.OnPressed)
            {
                StopAnimations();
                Walk = control.PlayLoopingAnimation(walkIndex);
                Walk.PlaybackSpeed = 1.5f;
                worldMatrix = leftFacing * Matrix.CreateTranslation(Position);
            }
            if (keyboardState.KeyState.A.IsDown)
            {
                playerPositionAdd.Y -= 0.2f;
            }
            else if (keyboardState.KeyState.A.OnReleased)
            {
                StopAnimations();
                Stance = control.PlayLoopingAnimation(stanceIndex);
            }

            if (keyboardState.KeyState.D.OnPressed)
            {
                StopAnimations();
                Walk = control.PlayLoopingAnimation(walkIndex);
                Walk.PlaybackSpeed = 1.5f;
                worldMatrix = rightFacing * Matrix.CreateTranslation(Position);
            }
            if (keyboardState.KeyState.D.IsDown)
            {
                playerPositionAdd.Y -= 0.2f;
            }
            else if (keyboardState.KeyState.D.OnReleased)
            {
                StopAnimations();
                Stance = control.PlayLoopingAnimation(stanceIndex);
            }
            if (RoundHead.Time >= .7f)
            {
                StopAnimations();
                Stance = control.PlayLoopingAnimation(stanceIndex);
            }
            if (comboEnabled == true)
            {
                comboTimer += state.DeltaTimeSeconds;
                if (comboTimer <= .5f )
                {
                    if (Punch.AnimationFinished)
                    {
                        if (keyboardState.KeyState.LeftShift.OnPressed)
                        {
                            StopAnimations();
                            RoundHead = control.PlayAnimation(roundHeadIndex);
                        }
                        
                    }
                } 
            }

            worldMatrix = Matrix.CreateTranslation(playerPositionAdd) * worldMatrix;
            return UpdateFrequency.FullUpdate60hz;