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

Exporting FBX to XNA 3.0 Project

Last post 3/23/2009 9:19 PM by MAN9A. 11 replies.
  • 1/28/2009 4:05 AM

    Exporting FBX to XNA 3.0 Project

    Hi All,

    Obviously there seems to be quite some amount of problems with XSI and XNA at the point. I tried to export an FBX file, but I hit an issue. I got a cube, squashed it down so it was almost a flat plane. I exported it with a texture (not embedded) with U=0.2 and V=0.2. But the texture comes in as 0.5 (??) and a unit cube :S

    I'm confused... Any thoughts? I can post the files (someplace) if anyone wants to see them.

    I downloaded the FBX viewer for quicktime and the mesh showed ok, so it looks like the fbx is ok, but xna is doing something funky.

    Paddz.
  • 1/28/2009 1:44 PM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Possibly the squashing was done through a change to the root transform rather than changes to the actual vertices and somehow you are not utilizing that root transform when drawing in xna. Did you do the typical model.CopyAbsolut....(transformArray) and use those transforms in the effect.World =.... section of the draw call? If you think this may be part of your problem, post your code & we'll help you with the implementation if you want.

    I'm not sure about the texture issue.
    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here
  • 1/29/2009 3:07 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Trying another couple of things, but the code is taken from the tutorials on this site. I call:

     

    1 DrawGameObject(m_floor); 

    That calls this:

     

    1         void DrawGameObject(GameObject _gameObject)  
    2         {  
    3             foreach (ModelMesh mesh in _gameObject.Model.Meshes)  
    4             {  
    5                 foreach (BasicEffect effect in mesh.Effects)  
    6                 {  
    7                     effect.EnableDefaultLighting();  
    8                     effect.PreferPerPixelLighting = true;  
    9  
    10                     effect.World = Matrix.CreateTranslation(_gameObject.Position);  
    11                     effect.Projection = m_camera.Projection;  
    12                     effect.View = m_camera.View;  
    13                 }  
    14  
    15                 mesh.Draw();  
    16             }  
    17         } 

    When I look at the FBX file in the QuickTime viewer plug-in it looks exactly as I planned. I've tried a few other shapes and they don't seem to come over to XNA...

    UPDATE: I just downloaded Milkshape and converted the FBX to an FBX (natch) and, baring a couple of misplaced triangles it showed the correct shape. Now I'm confused... Are there any settings that need to be made in XSI to get a 'good' FBX to export. I have the following set:

    Select mesh
    Click File | Crosswalk | Export FBX
    Choose the filename

    In the dialog box Everthing is default except I uncheck Camera, lights, Embed textures, Convert to portable format, Export to ASCII format, export animations. Although I have tried every other permutation :o)

    Paddz

     

  • 1/29/2009 3:51 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

  • 1/29/2009 12:39 PM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Well, I'm not sure. Could you recheck the ASCII option, and export it again, then open it in notepad & paste it to this pastebin. Also paste the rest of the xna code there too. It kind of seems like there is a scaling transform (along the Up axis) either in the fbx file scaling it down that xna is not utilizing or one the xna file scaling it up. And I think since it looks normal in the quick time viewer, most likely you need an adjustment to your xna code (despite the fact that it is straight out of the tut) so make sure to paste the xna code (at the very least the LoadContent() method. probably don't even need the patebin for that)
    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here
  • 1/30/2009 2:41 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Hi again,

    I've pasted the code into the paste bucket -- cool tool and thanks! -- the fbx file is split in two, but it can be re-built easily enough. I've included all the classes I wrote / playing about with.

    Paddz
  • 1/30/2009 1:36 PM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    There was a transform in the fbx that was not being taken into account in your xna code. Here is a couple code changes to get it to work properly

    Add a matrix array to the fields section
            Camera m_camera;
            GameObject m_floor;
            GameObject m_alien8;
            Matrix[] m_floorTransforms;

    Instantiate & populate the array in the LoadContent section
                m_floor = new GameObject(Content.Load<Model>("Floor\\10x10grid"), Vector3.Zero);
                m_alien8 = new GameObject(Content.Load<Model>("Characters\\alien8"), Vector3.Zero);
                m_floorTransforms = new Matrix[m_floor.Model.Bones.Count];
                m_floor.Model.CopyAbsoluteBoneTransformsTo(m_floorTransforms);


    Utilize the transforms while drawing.
           effect.World = m_floorTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(_gameObject.Position);

    Here is an article written by Shawn Hargreaves that explains the code changes. You should set up a similar matrix array for the m_alien8 model (and any other model you may put in the game) so the drawing code works with it too.
    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here
  • 1/31/2009 2:52 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Steve,

    You the man! That worked a treat, well geometry wise at least. UVs still mucked up but I can at least live with that just now. It makes you wonder why that article isn't first page on the XNA 3.0 news though.

    Thanks again,

    Paddz
  • 1/31/2009 3:25 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Yeah, glad I was able to help. Shawn is pretty much the supreme guru of xna. Here is an index to all the articles he has written about xna. Definitely a link to bookmark. see you around.

    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here
  • 2/6/2009 12:06 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Steve, I Just wanted to add one more note of thanks.

    I've only been playing with XNA / XSI for a few days so I'm still very green. I had a similar problem and your solution fixed it right up. Going off to read Shawn's articles now, there's still a load of unanswered questions out there.
    Thanks again for the post!
  • 2/6/2009 2:52 AM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Thanks, I hope you enjoy xna as much as I have. See you around.
    Unlock The *I don't use 3 angles in a Vector3 for rotations anymore* Achievement Here
  • 3/23/2009 9:19 PM In reply to

    Re: Exporting FBX to XNA 3.0 Project

    Those links are very very good.

    Thanks for it
Page 1 of 1 (12 items) Previous Next