XNA .X export

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

XNA .X export // Game Development

1  |  

Post by redcrosse // Aug 15, 2008, 6:04am

redcrosse
Total Posts: 19
So I've been a user of ts5 and started playing with xna. To get a usable .x file I used to go through a convoluted workflow of modeling a mesh in truespace and reloading in gamespace lite and finally exporting to a .x mesh. (This worked, but was a real pain & had some limits on poly counts)


Now that I am finally reaching the far greener pastures of ts7.6 :) I can't seem to get a model with textures to export properly. I have a mesh loaded in workspace view that has shaders which look right, but when I save a mesh as a .x file things seem to fall apart. The geometry loads, but none of the shaders seem to have any effect. At this point I'd love to just get a texture on the mesh :P (Again same code can load a mesh produced with the work around technique) Hoping its as simple as "check these boxes on the .x export dialog" :D


On a side note, any tips on the best way to "group" meshes together? I was used to the "glue as sibling" method and looks like the "encapsulate 3d object" is now the way to go. Is that correct? From what I've read in other posts caligari is "sunsetting" the model view and if I want to really learn and use the tool as its intended I should go ahead and get cozy with the workspace view.

Post by TomG // Aug 15, 2008, 6:41am

TomG
Total Posts: 3397
Bear in mind that some textures won't export - some are procedural, some are for DX9. At present, only regular texture mapping textures (ie those that use images mapped onto the surface) will export (that I know of). My tests there have been fine so far.


I haven't been able to get Reflectance shader settings to export at all (will be asking devs about that to see if it is meant to be possible).


So far have been using the Content Pipeline found in SkinningSample for skeletons, which was built with an FBX object. Have converted it to load an X object but it loads distorted (and can access an animation from tS, but it plays back distorted). Investigating that with the devs, and with some XNA users who know more about XNA than I do :)


For just regular models though the export and import has worked fine - I used the SimpleAnimation sample and replaced their tank with a simple object of my own, and could then access the object parts and animate them using rotate commands in XNA.


Yes, Encapsulate is the way to go. Be sure to give each part of your model a UNIQUE name. "Wheel1" inside the group "LeftWheels" will not be unique compared to "Wheel1" inside the group "RightWheels" and will mean you can't access the object in XNA to animate it. So be sure to name them LWheel1 and RWheel1 for example, even though they are in a group with a different name.


I find renaming in the LE is a fine way to go for that (but naming as you make the objects, using the object info panel, is probably better than waiting til the end and going through it all in the LE ;) ).


HTH!

Tom

Post by redcrosse // Aug 15, 2008, 6:49am

redcrosse
Total Posts: 19
Thanks for the quick reply :)


Not to sound thick, but does this mean that a dx shader which uses an image mapped texture will export properly from the workspace view to a .x file? Is there a list of dx shaders which are supported in the export?


One other note... (This part may be my code) What about transparency? Are the alpha channel values exported?

Post by Jack Edwards // Aug 15, 2008, 10:18am

Jack Edwards
Total Posts: 4062
pic
The TextureBump material is the recommended one to use. It should export both the color and normal maps.

Post by redcrosse // Aug 15, 2008, 6:22pm

redcrosse
Total Posts: 19
Thanks for the info!


It's a huge step in the right direction :)


Does anyone have any experience on what dx shaders to use for transparency? I'm using the TextureBumpTransparencyMetal as the basis for my material and it looks great in Truespace, but when its exported the transparency doesn't seem to export with it. It could definitely be my drawing code, just unsure if the export is handling it properly. I've tried using jpg, png, and dds for the image formats during export.

Post by clintonman // Aug 16, 2008, 5:10am

clintonman
Total Posts: 304
pic
I found that the .X transparency comes from the color texture and the truespace transparency shaders are ignored. So you have to have a 32 bit color texture with 8 bits for the transparency. There is a bug so png won't export 32 bit so you can use tga, bmp and dds to get transparency out of truespace via the color texture.

Post by Jack Edwards // Aug 16, 2008, 10:03am

Jack Edwards
Total Posts: 4062
pic
My lambert and blinn shaders have options to use the alpha values from the alpha channel of the color map when loaded as the alpha map:
http://forums1.caligari.com/truespace/showthread.php?t=5893
To use if for that, add your color map to the alpha map property and check the "Use mask" checkbox. You will also need to change the alphatest value to: "Enabled"

I haven't tested them with the X exporter though. So let me know if you have any problems.

Post by redcrosse // Aug 16, 2008, 12:28pm

redcrosse
Total Posts: 19
I'll definitely give them a try, thanks for the heads up :)

Post by redcrosse // Aug 30, 2008, 11:41am

redcrosse
Total Posts: 19
This may be obvious to some and off topic to others, but for me it was a pain so I'm posting it here to hopefully save someone some time :P


I've found that you get better control of transparency using XNA by toggling the graphics.GraphicsDevice.RenderState.AlphaBlendEnab le property to true and setting the up the basic effect in your draw code :) this comes in handy especially if you want to let the game determine the transparency of any given element.


foreach (ModelMesh mesh in model.Meshes) {

foreach (BasicEffect effect in mesh.Effects)

{

effect.Begin();

... [Insert Other needed code here]

effect.Alpha = alpha; //The alpha value between 0-1 effect.End();

}

mesh.Draw();

}


// When initializing the graphics device I used the following:


graphics.GraphicsDevice.RenderState.AlphaTestEnabl e = true;

graphics.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add ;

graphics.GraphicsDevice.RenderState.DestinationBle nd = Blend.InverseSourceAlpha ;

graphics.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha ;

graphics.GraphicsDevice.RenderState.AlphaSourceBle nd = Blend.One;

graphics.GraphicsDevice.RenderState.AlphaDestinati onBlend = Blend.InverseSourceAlpha ;


Hope it helps someone down the road
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn