Jump to content
  • Advertisement
Sign in to follow this  
guyaton

.X file exporter

This topic is 4844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Don't mean to repost, but my article was in Game programming and my question has not been answered so i thought i would bring it here. the origional post is here I just need to convert from Right handed (3ds max) to .X file left handed. thanks, ~guyaton

Share this post


Link to post
Share on other sites
Advertisement
if you follow the link i'm trying to make a custom .X file exporter from max. Both learning experience and for a project, so unfortunately, milkshape is out of the question.

~guyaton

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Normally you would just negate the z axis and change the winding order of your polygons (ie per poly in the index buffer {0,1,2}->{0,2,1}).

but max is a little different
for every matrix swap your Z&Y axis...that brings you back to a D3D-centric left handed system. You may still have to change the winding order. The DirectX SDK ships source code for their exporter. I would just look there as a reference.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by guyaton
Don't mean to repost, but my article was in Game programming and my question has not been answered so i thought i would bring it here. the origional post is here I just need to convert from Right handed (3ds max) to .X file left handed.

thanks,
~guyaton

AP said the steps that you need to convert from right to left handed. But considering that you want to export an X-file from 3ds max, the easiest way is to use Panda plugin (http://www.andytather.co.uk/Panda/directxmax_downloads.aspx). It allow you to choice exporting in right or left handed.

Share this post


Link to post
Share on other sites
You can use "Panda Exporter" a very good free tool for exporting in .x fromat. You can also chose the coordinate system and if animation frames, textures and shaders are to be included in the exported file.

Download Page : http://www.andytather.co.uk/Panda/directxmax_downloads.aspx

Share this post


Link to post
Share on other sites
Panda may be very useful, but the point is that I want to write my own, not use someone elses. Need to make one to export only certain things.


thanks for all the help so far
~guyaton

edit: Microsofts version doesn't convert. Already checked though. If you try exporting it, you will note the objects are all rotated.

[Edited by - guyaton on August 12, 2005 8:12:56 AM]

Share this post


Link to post
Share on other sites
I re-edited this post for a better understanding.

There are many ways to convert a right handled in a left handled coordinate system:
- Negating z-axis direction
- Negating x-axis direction
- Negating y-axis direction
- Changing y and z axes

But what we must pay attention is if only this procedure is enough to coincide the new axes with the axes of the "target coordinate system". If they aren't, it's necessary to apply a simple transformation. So, the general steps are just:

1) Convert the right handled in a left handled coord. system
2) Transform the axes to the desired place (if necessary)

Considering a conversion between 3ds max and Direct3D, changing y and z axes ([x,y,z]->[x,z,y]) is enough to place the new coordinate system to the correct place. Of course, you could use other conversion ways, but they will require an aditional transformation.

Also, to get a correct conversion, it's necessary to know how 3ds max and Direct3D generate the faces. Let's consider that:

- 3ds max creates a face in this order: maxVert1 -> maxVert2 -> maxVert3
- Direct3D creates a face in this order: D3DVert1 -> D3DVert2 -> D3DVert3

The correspondence between them is:

3ds max | Direct3D
---------- ----------
maxVert1 | D3DVert1
maxVert2 | D3DVert3
maxVert3 | D3DVert2


To exemplify, I wrote a short script for you:

IndexFace = 0

obj = snapshotAsMesh rootNode.children[1]

NumFaces = obj.faces.count
NumVerts = 3 * NumFaces

clearListener()

------------------------------------------------------
-- Vertex positions
------------------------------------------------------
format "%;\n" NumVerts

for f = 1 to NumFaces do
(
local IndicesVertFace = getFace obj f

local IndVert1 = integer IndicesVertFace.x
local IndVert2 = integer IndicesVertFace.y
local IndVert3 = integer IndicesVertFace.z

local Vert1 = getVert obj IndVert1
local Vert2 = getVert obj IndVert2
local Vert3 = getVert obj IndVert3

format "%;%;%;,\n" Vert1.x Vert1.z Vert1.y
format "%;%;%;,\n" Vert3.x Vert3.z Vert3.y

if ( f != NumFaces ) then
(
format "%;%;%;,\n" Vert2.x Vert2.z Vert2.y
)
else
(
format "%;%;%;;\n" Vert2.x Vert2.z Vert2.y
)
)



------------------------------------------------------
-- Face indices
------------------------------------------------------
format "%;\n" NumFaces

for f = 1 to NumFaces do
(
local IndicesVertFace = getFace obj f

if ( f != NumFaces ) then
(
format "3;%,%,%;,\n" IndexFace (IndexFace+1) (IndexFace+2)
)
else
(
format "3;%,%,%;;\n" IndexFace (IndexFace+1) (IndexFace+2)
)

IndexFace += 3
)

actionMan.executeAction 0 "40472"


In this simple script I didn't optimise the mesh (reducing the number of vertices). The results will be printed at the output window of MaxScript Listener.
I leave the conversion of the vertex normals and UV texture coordinates as an exercise. [smile]

Hope this helps.

[Edited by - adriano_usp on August 12, 2005 5:49:26 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by guyaton
Panda may be very useful, but the point is that I want to write my own, not use someone elses. Need to make one to export only certain things.


thanks for all the help so far
~guyaton

edit: Microsofts version doesn't convert. Already checked though. If you try exporting it, you will note the objects are all rotated.




The microsoft one looks rotated because it is changing Max's Z-up to the more common Y-up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!