New .x Export Script

I’m a very new Blender user - one week. As with any new program I begin to learn, I like to get one “proof-of-concept” project done - no matter how simple. So after going through most of the noob->pro tutorial, I created my own animated mesh - part of one leg 50 verts, 3 bones, textured and animated. Then I hit the brick wall!

When I went to try and export it to .x to view in another program, I ran into a whole series of problems. The fundamental problem was that the included scripts and the other ones that I downloaded were tempermental at best.

The most frustrating thing was that when they didn’t work, there was no clue as to why! So after figuring out a number of issues, I decided to attempt to rewrite a script with the following goal:

GOAL: Export a valid file every time, or let the user know why not (preferably in advance of the export.)

Here is my first stab at it… (remember the “one week” thing… so I have to disclaim this as noob/beta)

Two main notes:

  • This works for me and catches most of the basic junk I threw at it - it worked or told me why it wouldn’t. But I’m one new user. Please try it and if it won’t handle your file or produces a bogus .x file, please let me know what broke it and I’ll try and fix the script.
  • Unlike most of the scripts I’ve seen for .x export, (if you select to export animations) this script exports ALL actions as named animation sets. (I never got the point of exporting 10 times and cut/pasting the animations into one file and anyway if you only want one, it’s easier to delete the extra ones.)

I have a number of functionallity changes in mind for the future, mostly related to the exported vertex count/UV/normal handling as well as a lot of internal code changes, but I want to make sure I’m on the right track.

I hope this is a help, esspecially to the noobies who haven’t learned all of the local “tricks of the trade” yet.

Enjoy… xFileExporter242.zip

hi Rakar, you might want to contact the original author with your suggested changes,

I’ll have a look later,

LetterRip

Thanks LetterRip,

This is already more than just a couple of suggestions and I expect to continue to modify the functionallity. I mean no disrespect to Ben, but I’d feel a little funny asking “So, could you re-write the approach you take to exporting verticies, faces, skin weights and normals?”

Also, yes, very appropriate suggestion… I have sent Ben a email about the changes.

Rakar, this is an excellent initiative! I use Quest3D myself, and a solid .x exporter is essential to convince the rest of the team to get blender in our workflow. I will certainly test it and get back to you if I find any problems. Thanks for your efforts so far!

Rakar,
Thanks for doing this. I’m having hell to pay to get anything at all out of Blender. Not sure what the problem is, but every complex model I try to export will not open at all in mview.exe (microsoft) or PolyTrans ( expensive file converter) . I tried your exporter and got the same thing so it may be my model. Nothing special. A lot of polys since I applied the subsurf. Materials, textures (jpgs), one bump map. no bones.

PolyTrans gave this error message:
Error: The file j:\blender_modelproduction\3mmask\final\3mmask_1ss_nomod242.x cannot be parsed. The .X file must conform to the Direct3D Retained Mode format.

I’m still looking for an export path. I like .x since it handles bones, textures and animation. But so far, nothing will export using at least 4 different scripts for x.

What is this script supposed to do if it finds a problem? write a file or post a message to the window?
Thanks for your effort,
John

John,
The script should put a warning up on the screen for any errors it anticipates and it shouldn’t let you export until all is well.

You mentioned subsurfing your model. Two questions…
Did you actually apply the subsurf mod so that the modifier has gone away?
Are you exporting animations?

I was working on a version that would export unapplied subsurf models with animations, but was waiting on another pending (maybe done by now) change change to blender - the modifier stack. I’ve been too busy to check lately.

I don’t know how “proprietary” your model is… If I could get a sample I’d be happy to try and see what the problem is.

Rakar

rakar,

modifier stack has a python API for it since 2.41 I think.

LetterRIp

Don’t know if this helps, but for some external viewers of x files, exporting model with texture image(uv) but without material allows it to be seen.

Rakar,
I talked to Ben and he found one problem. I had a surface name that started with a number. Once I hand edited that name inside the x file, mview.exe would open it. But then the next model (without a number) also would export but would not load. Again, I have not got a clue what is wrong. I’d be happy to work with you to find models that will export to x but can not be loaded into mview. That might find all the problems. Unless I can export good x files, my entire model production is limited to non-animated models. And right now, I have no reliable way to export all x files.
John

I have been away from the board for a little bit. Too many demands from the real world. My main use of blender is to construct animated (boned) models… Don’t give up.

Just to throw it out, the only problem I’ve encountered with my script has to do with having a subsurf modifier active at render time.

If you don’t have this issue, then I don’t have a clue, but would be happy to take a look at it. I think the best thing would be for you to email me the model that is failling if that is acceptable to you.

I don’t have an “x file analyzer” that would highlight the problems. I find that messing with the model and watching the script (via debug messages) is the most effective process.

Let me know…
Rakar

Rakar,
I applied the SS and then exported again and mview croaked - probably due to the number of faces. But PolyTrans (my ultimate target) continues to say that the x file is not formated correctly. Something to do with it not meeting the standard for Retained mode files.
I’ll see if a smaller SS ( 1 instead of 3) gives me a file mview can load.
Thanks,
John

Hi.
i have problem with exporter. I get this:

.x File Export (DirectX) for V2.42 version 0.1 (beta) Envoked.
Exporting Scene…
Diag: Writing Animation Keys - Method 1
Diag: Current Action: aa
Diag: Exporting Bone: R foot
Diag: Extracting Keyframe Points IP Bone Name: ActIpo.703
Traceback (most recent call last):
File “xFileExporter242.”, line 205, in draw
File “xFileExporter242.”, line 115, in my_callback_sel
File “xFileExporter242.”, line 527, in ExportScene
File “xFileExporter242.”, line 551, in ExportAnimation
File “xFileExporter242.”, line 1231, in writeAnimation
File “xFileExporter242.”, line 1354, in getKeyFramePoints
IndexError: list index out of range

Can anybody help?

Thanks.

I allways get this “IndexError: list index out of range”-message when re-importing a .x-file that had several objects (e.g. two cubes) before exporting them to .x

When using only one single object everything is ok. But as soon as there is more than one object I can’t re-import them. Only the first object gets imported. The others get lost.
I tried different things (assinging materials to each of the cubes for example) but it didn’ help. Any suggestions?