Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (13 posts)

Unreliable Export from SketchUp into XNA ? - What Works ?

Last post 12/13/2010 1:58 PM by Stonecode. 12 replies.
  • 12/12/2010 2:19 AM

    Unreliable Export from SketchUp into XNA ? - What Works ?

    Hello

    So I am new to XNA and 3D Modelling.  I tried Blender but it was way too daunting for my little brain to get into.  So I have started out with Google SketchUp (version 8)  and using the xExporter into X Files.  For very simply models (and color textures) this seemed to work for me in my XNA phone App.  So I have a basic 3D model of a ship and Sprites all looking OK. - But I wanted to work on a more sophisticated 3D model, so worked up a nice model in SketchUp.  

    Then I started getting into deeper SketchUp Models, using Groupings, different color textures.  - But it then all starts to go wrong when I view in my XNA game.  Parts of the models components are displaced, or don't show, some faces are missing etc.

    My searches to resolve this discovered two aspects
    - I need to explode all Groups in Google Skectflow prior to Export  - But this made no difference
    - As I am using 2D Sprites as well, I should be using SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.deferred, SaveStateMode.SaveState)   - However this method is no longer seems available in XNA 4.0 

    Instead on xExporter I have also tried 3DRad which seems a bit more robust and clear in its export options.

    I have used DirectX 3D Viewers, and my model seems look geometrically OK in that, albeit it is not clear how Textures are displayed

    I have also downloaded various SkecthUp Models, and tried to export these into .X format with mixed results.  Some look OK DirectX Viewer, but when displyed in XNA, some faces and components also become missing.  

    So the GoogleSketchUp exports I have been trying do not seem very robust.  What methods are others using, and what are your experiences and most methods to getting into a XNA compatible .X format ?  

    It is Looking as though I may have to export via Blender or end up having to get top grips with Blender.
    ** Edit:  So I have Downloaded Blender and Python etc.  => Export from Sketchup in DAE format, import into Blender - Seems to look OK in Blender.
    Export to DirectX - Exports to  .X file, but Notice various errors in console Mesh XXX without vertices, out or range errors.  

    Jeez Really Microsoft would do well to develop and put out a basic X Modelling Tool to help us in the XNA community generate our models (Like Google seem willing to do) I would have thought that was obvious to help the community and help the Indie XBox and WM7 platforms - I am on the verge of giving up: I will see if I can really learn Blender.
     
    For what its worth here is my Draw method (but as I said it seems ok on very basic models of Sketchup exports using xExporter):-

    // =========================================================================

    Matrix[] transforms = new Matrix[myModel.Bones.Count];

    myModel.CopyAbsoluteBoneTransformsTo(transforms);

    foreach (ModelMesh mesh in myModel.Meshes)

    {

    foreach (BasicEffect effect in mesh.Effects)

    {

    effect.EnableDefaultLighting();

    effect.World = transforms[mesh.ParentBone.Index] *Matrix.CreateRotationX(modelRotation)* Matrix.CreateTranslation(ShipPosition *Matrix.CreateScale(50.0f);

    effect.View = TheCameraView;

    effect.Projection = TheViewProjection;

    }

    mesh.Draw();

    spriteBatch.Begin();

    // Draw the Head Up Display

    TheHUD_Display.Display_HUD(spriteBatch);

    spriteBatch.Draw(StartButton, StartButtonRectPos, Color.White);

    spriteBatch.DrawString(DebugStringFont, DebugString, DebugPosVector, Color.Red);

    spriteBatch.End();


    // ====================================================================


    Cheers for Any help
    Jules





  • 12/12/2010 3:59 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Could you post a picture of what you're seeing somewhere? It sounds like the normals for the mesh faces are getting getting reversed. Maybe someone that's more experienced in Sketchup can comment on this, but I don't remember a way in there to "flip" the faces.

    To test this theory, try this:

    GraphicsDevice.RenderState.CullMode = CullMode.None; 
     
    foreach (ModelMesh mesh in myModel.Meshes) 
    foreach (BasicEffect effect in mesh.Effects) 
    effect.EnableDefaultLighting(); 
    effect.World = transforms[mesh.ParentBone.Index]     *Matrix.CreateRotationX(modelRotation)* Matrix.CreateTranslation(ShipPosition *Matrix.CreateScale(50.0f); 
    effect.View = TheCameraView; 
    effect.Projection = TheViewProjection; 
    mesh.Draw(); 
     
    GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace; 

    Additionally, you might want to give Softimage Mod Tool a go. It's free for non-commercial use and isn't too bad to learn. http://usa.autodesk.com/adsk/servlet/pc/item?id=13571257&siteID=123112

  • 12/12/2010 4:42 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    3D file formats are a pain.  Not really Microsofts fault.  Even the professional studios have to work out the pipeline from their chosen design tool into their code.

    For me I find that FBX is more reliable than X.   Both can be a pain but I have more luck with FBX.  Perhaps because I also want the animations to work.

    Google Sketchup version 7 had a couple of free addon for FBX try them all and see if they help.

    For Blender make sure that you use the correct FBX exporter.  The one that ships with Blender 2.49b does not work with XNA you need the external one.

    Bit of a plug, I've just written (modified) an XNA FBX exporter for version 2.55 of Blender, so you might want to try that.  If you follow the instructions (limitations) for how models have to be produced from Blender to work with XNA even the most complex model will work.
    http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/Blender-toXNA

    I like Google Sketchup because it is simple to get to grips with but I prefer to use Blender as it gives more control.  I admit I spent a two week holiday just learning how to use it and now watch tutorial videos when I need to do something I have not done before.

    Good luck.
  • 12/12/2010 5:23 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    SilverMoonLight:
    ... I have used DirectX 3D Viewers, and my model seems look geometrically OK in that...

    While working on getting my models from Blender to XNA I found several times that my animated models exported to .X files would look OK in the DirectX viewers based on the DirectX SDK but would still not look right in XNA.

    I have no idea why but ended up using FBX instead.
  • 12/12/2010 8:06 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Joshua

    Thanks for your consideration.  I have posted up some picture images of what is happening at:
    http://silvermoon.stonerocket.co.uk/WM7_Ship/Problems.html

    I Tried your suggestion of putting GraphicsDevice.RenderState.CullMode = CullMode.None;  into my code.  But I do not appear to have this Property available to me on XNA 4.0  Windows Phone 7.   It is not obvious where this proprty can be applied on the WM7 platform.

    Cheers for the effort and support.

    Julian
  • 12/12/2010 8:16 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?


    JCBDigger: Oh OK  I think I considered seeing FBX examples when I first got into XNA, but I seem to remember that I gave up because either because I could not find any FBX exporters for the Free Google Sketchup.  Being a Newbie cheapskate I cannot commit to the Pro version of Sketchup.   So I take it that people agree that FBX is rather more reliable and exporters do exist.  In which case I gave up on FBX too soon.

    I will look harder if there are any ways to get an FBX export from the Free Google Sketchup. 

    Cheers and Interesting 

    Jules

    MB: (I still begrudge Microsoft - it is their format, and Dicrect X Files have been around for 10 years or so.  If they want a thriving indie XNA comminity, it would do them well to do what Google does and put a few modeling tools out there for us who cannot afford the professional Tools) - As it is I am on the point of giving up.   

     
  • 12/12/2010 10:14 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Answer
    Reply Quote
    SilverMoonLight:
    Joshua

    Thanks for your consideration.  I have posted up some picture images of what is happening at:
    http://silvermoon.stonerocket.co.uk/WM7_Ship/Problems.html

    I Tried your suggestion of putting GraphicsDevice.RenderState.CullMode = CullMode.None;  into my code.  But I do not appear to have this Property available to me on XNA 4.0  Windows Phone 7.   It is not obvious where this proprty can be applied on the WM7 platform.

    Cheers for the effort and support.

    Julian

    Ahhh... That looks like a draw order problem. Take a look at Shawn Hargreaves' blog about the RenderState changes after calling SpriteBatch.Begin()... http://blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4-0.aspx

    I think what you want to change back before any 3D draws after a SpriteBatch.Begin() call are:

    GraphicsDevice.BlendState = BlendState.Opaque; 
    GraphicsDevice.DepthStencilState = DepthStencilState.Default; 


    Sorry about that. My fault for missing that it's for WM7.

  • 12/12/2010 11:41 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    SilverMoonLight:

    Being a Newbie cheapskate I cannot commit to the Pro version of Sketchup.


    I like to use Open Source or free software if there's good stuff available.  Blender and Google Sketchup fit that category.  The FBX exporters I found for version 7 work with the free version of Sketchup.

    SilverMoonLight:

    ... Microsoft... put a few modeling tools out there for us who cannot afford the professional Tools...  


    They use to.  They provided the free Mod Tool for XNA.  Since the rebranding to App Hub I don't know where the link is.  Perhaps they stopped providing it.  It's still available for non-commercial use.  I didn't like it though.
  • 12/13/2010 2:25 AM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    JCBDigger:

    They use to.  They provided the free Mod Tool for XNA.  Since the rebranding to App Hub I don't know where the link is.  Perhaps they stopped providing it.  It's still available for non-commercial use.  I didn't like it though.

    A little digging on the Autodesk website  and I came up with this : http://usa.autodesk.com/adsk/servlet/pc/item?id=13571257&siteID=123112. The tool has been renamed to Autodesk Softimage Mod Tool.
  • 12/13/2010 11:15 AM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Brilliant Joshua

    It now looks great -  See updated image at bottom of following Link
    http://silvermoon.stonerocket.co.uk/WM7_Ship/Problems.html

    so basically as you suggested and from Shawn Hargreaves' blog I put the following after my SpriteBatch.End() call

    GraphicsDevice.BlendState =

     

    BlendState.Opaque;

     

     

    GraphicsDevice.DepthStencilState =

     

    DepthStencilState.Default;

     

     

    GraphicsDevice.SamplerStates[0] =

     

    SamplerState.LinearWrap;

    Thanks so so Much

    And Now on with the Fun!

  • 12/13/2010 11:21 AM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Interesting - I will look into this tool during my Christmas break. Especially as it seems that FBX files may be  more robust than .X files.

    Actually I have solved my immediate problem (As posted) above so I am OK with Sketchup at the moment.

    Thanks for the interest in helping me out

    Jules
  • 12/13/2010 1:55 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    Personally, I've mainly used the .X format when exporting since almost every modeling package either has the ability to or a plugin exists to export to this format. I've only seen .fbx exporters for Autodesk products.

    However, this caused me to do a little digging to see if there is an advantage for using one over the other. Here is what I've found.



    As of now it kind of still just looks like personal preference. I might check out fbx again since lately I've had the need to export data along with my scenes for info about physics and game layout... Currently, I have not succeeded in importing it from .X without writing a custom content processor... 
  • 12/13/2010 1:58 PM In reply to

    Re: Unreliable Export from SketchUp into XNA ? - What Works ?

    SilverMoonLight:
    Brilliant Joshua

    It now looks great -  See updated image at bottom of following Link
    http://silvermoon.stonerocket.co.uk/WM7_Ship/Problems.html

    so basically as you suggested and from Shawn Hargreaves' blog I put the following after my SpriteBatch.End() call

    GraphicsDevice.BlendState =

     

    BlendState.Opaque;

     

     

    GraphicsDevice.DepthStencilState =

     

    DepthStencilState.Default;

     

     

    GraphicsDevice.SamplerStates[0] =

     

    SamplerState.LinearWrap;

    Thanks so so Much

    And Now on with the Fun!


    Awesome! Glad it turned out into an easy fix instead of having to recreate your models. :)
Page 1 of 1 (13 posts) Previous Discussion Next Discussion
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG