XNA Creators Club Online
Page 1 of 1 (14 items)
Sort Posts: Previous Next

Importing trueSpace7.6 Animations

Last post 09-09-2008 5:29 PM by tector. 13 replies.
  • 08-07-2008 3:45 PM

    Importing trueSpace7.6 Animations

    I've made a simple animation in trueSpace7.6, but I can't seem to import the animation.  I'm not using a skeleton, i'm just moving the meshes around.  From what I've understood the .x exporter is trueSpace automatically generates a bone for every mesh, so I didn't think this would be a problem.  However, within my custom processor, MeshHelper.FindSkeleton always returns null.  Is there a way to import my animation without making a skeleton?  It'd be really annoying to remake my animation with a skeleton, especially because I haven't explored that area of trueSpace yet.
  • 08-15-2008 6:55 PM In reply to

    Re: Importing trueSpace7.6 Animations

    I'm not sure on this at present - in my tests with the SkinningAnimation sample, I've needed to have a skeleton in tS to get a skeleton recognized by the Content Pipeline. In my tests with SimpleAnimation, I can indeed load a mesh and use XNA to animate rotation of various parts of a model, but not to replay animation saved in keyframes from tS.

    Tests are still on-going, and I'll be working with the tS devs on this, as well as XNA people who have some time to help out, so I'll keep you updated on progress!

    Thanks!

       Tom

    Tom Grimes
    trueSpace7.6 Liaison
    mail: b-thgrim@microsoft.com
  • 08-15-2008 10:21 PM In reply to

    Re: Importing trueSpace7.6 Animations

    You've gotten animations to work with the SkinningAnimation sample?  I can't get my models to work even if they DO have skeletons.  I keep getting the error that my models don't have skeletons...even though there is a definition in the .x file for "Skeleton"...
  • 08-16-2008 12:50 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Terminology gets a little confusing :) Seems in XNA an object with different parts has a "skeleton" and "bones" - just names for the different parts though. By skeleton and bones, trueSpace means a skeleton that deforms the vertices on the surface, and without that tS doesn't refer to the components as bones.

    So, if you make a model in tS without tS skeletons, you can export it, then animate it using SimpleAnimation sample (ie use XNA code to recalculate the rotation of the components of the model - those components are now called "bones" though tS would not call them such, it would just call them sub-objects inside the group or hierarchy). You can create keyframed animations in tS with these models, but I can't find a way to read those keyframed animations into XNA as yet.

    Next, if you make a tS model with tS skeletons, you can export it, then load it using the SkinningSample sample. If the tS skeleton has branches though, distortions appear. Next you can animate using the tS skeleton in tS, and XNA will also load this animation, and you can access it and play it back using the SkinningSample code - but the playback is distorted. Also, it seems the model always renders as black at present, the shaders don't work.

    So XNA always calls things skeletons and bones, but tS only refers to skeletons for a "real" skeleton built to animate and deform a surrounding mesh. If you don't build a tS skeleton and connect it to the model in tS, then SkinningSample will (rightly) tell you there is no skinning data, and will fail to import. Simply import this model as a straight X format model and not through the skinning pipeline. It will not load or playback animations though.

    The SkinningSample also won't load and playback keyframed animations except for those that involve the skeleton (ie if you rotate sub-objects etc without using skeletons, I don't think it will load).

    Will be continue to research this! I think with a different Content Processor, the X file from tS could be read in succesfully, but we'll need to see as the testing continues!

    Thanks!
        Tom

    Tom Grimes
    trueSpace7.6 Liaison
    mail: b-thgrim@microsoft.com
  • 08-16-2008 2:03 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Will be continue to research this! I think with a different Content Processor, the X file from tS could be read in succesfully, but we'll need to see as the testing continues!

    Tom,

    If TrueSpace writes a proper X file, no separate content importer would be necessary. Similarly, all animations need a custom content processor -- SkinningSample has one, RobotGame has one, KiloWatt Animation has one, etc. This is because the XNA Content Pipeline will load animations, but the XNA runtime code does not support animations by default.

    If you need help writing proper X files, you can look at an Open Source .X exporter for 3ds Max found on SourceForge. If you want to use an animation library that properly processes and plays back .X files with animation (both skeletal and not), you can try the KiloWatt Animation library (which comes with a viewer application).

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 08-16-2008 3:44 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Sadly there is no "proper" X file it would seem - each application writes and expects a slightly different structure to the file, making it the most non-standard standard I have come across. We've run into that time and again over the years with various game engines importing X, but each one expecting a different set up to the file, so each one needing different attributes switched on or off, or right handed or left handed, or 32 bit, or some other variation that makes the difference between loading or not loading. At present I have no reason to suspect the X file from tS is incorrect, and I believe the custom content processor is not reading in the animation as it expected a slightly different flavor to the X file, but only more testing will tell! My next step is to try the KiloWatt library and see what difference it makes (I imagine it does make a difference, or the same content processor from SkinningSample would have done and KiloWatt would never have been written) when used to process an X file from tS. I'll let you know the results!

    Thanks!

       Tom

    Tom Grimes
    trueSpace7.6 Liaison
    mail: b-thgrim@microsoft.com
  • 08-16-2008 5:50 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Sadly there is no "proper" X file it would seem - each application writes and expects a slightly different structure to the file

    Yes, there is! If you write the X file using the documentation on MSDN, and use the D3DX file writing APIs (rather than trying to roll your own), then you will produce files that are proper, and will load and work correctly in the DirectX MeshTool and in XNA, as well as for everyone using the D3DX functions (create mesh from X, or create hierarchy from X). The main problems stem from two sources:

    1) Exporters that try to write their own files using fwrite() or similar, instead of using D3DX.

    2) Importers trying to parse using sscanf() and similar, instead of using D3DX.

    The main problem actually comes from decoding the documentation of the writing classes, which is unnecessarily sparse. That's why I suggested looking at some available reference code. Unfortunately, there's only the very old D3D SDK exporters for Maya and Max, which are no longer included in the SDK, and the kW X-port source code on SourceForge. The Panda source is not available, and neither is any other proper X exporter code I can find.

    Speaking of TrueSpace -- I tried exporting a X file from TS and getting Effect file references, but I couldn't make that happen. Even when using DirectX materials that were effects (lava, etc), there were no effect references included in the file that was exported. Do you know of a way to make that work?

     

    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 08-16-2008 11:22 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Tom Grimes:
    Terminology gets a little confusing :) Seems in XNA an object with different parts has a "skeleton" and "bones" - just names for the different parts though. By skeleton and bones, trueSpace means a skeleton that deforms the vertices on the surface, and without that tS doesn't refer to the components as bones.

    Yes, I meant that even when I did have a skeleton the animations didn't work.  As in, bones that deformed the verticies.  So basically I can't get any form of animation working.  :(

    I got the skeletal animations working (something dumb on my part), but as Tom said before, playback is distorted.  Is there any way to un-distort them?

    Through some hacking in the UpdateWorldTransforms() method of AnimationPlayer I got it playing properly.  :)

  • 08-25-2008 1:49 PM In reply to

    Re: Importing trueSpace7.6 Animations

    "Through some hacking in the UpdateWorldTransforms() method of AnimationPlayer I got it playing properly.  :)"

    Now that sounds interesting :) Could you share the hacking you did, either here for all to see, or if not possible, direct to me by email at b-thgrim@microsoft.com? Just what hacking was required would be useful information for all XNA users, and for our devs too.

    Thanks!

       Tom

    Tom Grimes
    trueSpace7.6 Liaison
    mail: b-thgrim@microsoft.com
  • 08-25-2008 2:16 PM In reply to

    Re: Importing trueSpace7.6 Animations

    Tom Grimes:
    Could you share the hacking you did, either here for all to see...

    Well, yes, but it doesn't entirely work.  I got it working for mesh transformations, for example making a robot waddle back and forth.  I haven't gotten it working for vertex deformations, so in that department I guess we're all still stuck.  But if you're like me and you just want to move meshes around, change UpdateWorldTransforms() of AnimationPlayer to the following:

    /// <summary>  
            /// Helper used by the Update method to refresh the WorldTransforms data.  
            /// </summary>  
            public void UpdateWorldTransforms(Matrix rootTransform)  
            {  
                // Root bone.  
                worldTransforms[0] = boneTransforms[0] * rootTransform;  
     
                // Child bones.  
                for (int bone = 1; bone < worldTransforms.Length; bone++)  
                {  
                    int parentBone = skinningDataValue.SkeletonHierarchy[bone];  
     
                    worldTransforms[bone] = worldTransforms[parentBone];  
                }  
            } 

    I'm sorry if I got anyone's hopes up.  I will continue to investigate other hackings.

  • 08-31-2008 1:45 AM In reply to

    Re: Importing trueSpace7.6 Animations

    Anyone had any luck with skinned animations yet?  I've been trying most of the day with limited success. 

    I can get the rigged tank girl sample model to animate correctly, using a hacked version of the XNA Animation Component Library (it doesn't work with GSE 2.0 by default).  I've tried other sample models though, and a few I've put together myself - no successes, they've all distorted as Tom described, with the vertices scaling out of proportion:

    Tom Grimes:
    Next, if you make a tS model with tS skeletons, you can export it, then load it using the SkinningSample sample. If the tS skeleton has branches though, distortions appear. Next you can animate using the tS skeleton in tS, and XNA will also load this animation, and you can access it and play it back using the SkinningSample code - but the playback is distorted. Also, it seems the model always renders as black at present, the shaders don't work.

    I've tried debugging it, by rendering the skeleton alongside the mesh, interestingly the tank girl skeleton animates perfectly and matches the mesh as it moves, but all the others show the skeleton detached from the mesh (usually down in the Y axis somewhere).  The skeletons do animate properly though, even if they are offset.  This leads me to believe that it's got something to do with the rigging on the models, or another setting in the scene.  Unfortunately I'm no expert with 3D packages, I've tried fiddling with all the settings I can find - comparing with the tank girl model, but I can't spot the difference so far.

    Anyway, I've tried putting the working animation into other libraries and samples with no success.  Haven't had time to find out why they differ, since I've put most of my effort into comparing models against the working one.  If you're using the standard skinning sample then you might want to check the code against the XNA ACL before scratching your head too much over the models.

    P.S.  One last point, if you're getting a black model then it could just be because you don't have a texture.  Most of the animation importers will swap out your effect for their own in the pipeline.  Their effect usually reads a texture colour and multiplies it against the lighting, so if you don't have a texture then all you'll see is black.

  • 08-31-2008 2:21 AM In reply to