Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

3 Dimensional Chat / Simple DirectX .X file editor wanted

Author
Message
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Nov 2010 13:34 Edited at: 16th Nov 2010 13:47
I'm trying to find a simple X file editor.

I already have a variety of packages, e.g. MilkShape, TrueSpace, Google SketchUp, MarbleCLAY, but I seem completely incapable of working out how to import a standard DirectX X file into those packages so that I can edit it.

I must be missing something really obvious but when I try to import an X file into any of those packages, X files don't seem to appear in the menus under Files of Type.

Yet when I do a search on this forum for this problem I find threads like this:

How to edit .x files

where a poster says:

Quote: "See the sticky "Great 3D Resource" at the top of the board. Any of those will do the trick"


Well, what is "the trick" that I am missing?

Edit Could a Mod please edit the thread title to include the missing .X,? I meant to say "DirectX .X file" of course.
Cyborg ART
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden - Sthlm
Posted: 16th Nov 2010 19:35
For milkshape, take a look under tools. There you will find "DirectX Mesh Tool". It will import directX meshes, but not the animations.

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Nov 2010 22:03
Thanks. Rather baffling that X files aren't included under Import like everything else.

I have a horrible feeling that someone's told me that before and I'd forgotten.

You'd think that such a standard format would be easier to find.

I guess I'll have to browse all the menus of the other packages as well to see which one is hiding the X file importer.
PrimalBeans
14
Years of Service
User Offline
Joined: 14th Oct 2010
Location: The sewer.... hunting alligatiors.
Posted: 17th Nov 2010 00:02
blender 2.49 has an importer as well though i dont use it just the exporter in 2.54. I dont think one has been implemented in 2.54 yet as it is still beta ans no one has created a py script for it. (I could be mistaken.) Heh just out of curiosity why do you need an importer? Usually .x files are trying to get out not in lol(that was a joke intended for all the .x exporter fails there are. for such a simple format seems alot of people have tons of trouble with it.)

Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 17th Nov 2010 08:40
Ultimate Unwrap can convert a direct x file
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Nov 2010 09:00
I never export or import .X from a modelling package, .3DS is a good pre-game format I think, well supported and is ideal for simple meshes and mechanical objects.
I tend to stick DBConv inbeside the .3DS files I want to convert, then run that, and it generates .X files - DBConv is of course supplied with DBClassic, but it's .X files work great in DBPro too. That's just for static meshes.
For bone animation, I use CharacterFX, which has a great .X export, those load right into DBPro.

Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2010 11:20 Edited at: 17th Nov 2010 13:51
Thanks for fixing the title.

I'm used to text .X files because they're easy to work with yourself on the odd occasion that you need to - and you can read their contents in a simple text editor. Handy when things go wrong. Not so handy when the file is huge though.

Quote: "Heh just out of curiosity why do you need an importer?"


Strange question.

Thanks for the suggestions, everyone, but I'm not out of the woods yet.

I've now tried using MilkShape's X file importer on some simple objects I wanted to fix and it seems to have trouble making the polys face the correct way. It's as if alternate polys are back-facing so a simple switch doesn't help - you need to fix every single wrong poly individually. Weird. Also, the exporters are cumbersome to use as well. I'll try some more simple models to see if I can narrow down the problem.

Edit The problem seems to be the source models I was using. I was trying to weld the model but hadn't realised that the original models seem to have every poly duplicated, one clockwise and one anti-clockwise so when you weld the vertices the normals become nonsensical. I don't know why the models were constructed this way - so they could work with either poly winding order I suppose.

Anyone know a quick way of removing all the "wrong" polys?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Dec 2010 22:19
Quote: "I don't know why the models were constructed this way - so they could work with either poly winding order I suppose."

I think this is a technique to make the model double sided - an inside and an outside without having any additional depth.

Quote: "Anyone know a quick way of removing all the "wrong" polys?"

Once the object is exported, there's no real way to know which polygon is facing the wrong way unless you are the modeler. For example, if you had a bowl with double polygons so you could see the inside and the outside, you wouldn't want to remove any or else you'd see through where the "wrong" winded polys were removed (unless of course culling was off).

Unless you can get at the model before it is exported, I think it'd take a bit of work to remove the extra polygons. A possibility would be removing the face indexes for every face number above the halfway point of the polygon count. Assumingly, one side of the model is done, then the other side (a duplication of the polygons with reverse winding order). But then again, each face could be in pairs, face 1a then face 1b, face 2a then face 2b, etc.

Another possibility, if you load the model into a 3d app, depending on the app and the importer, it may create 2 versions of the model based on the polygon. You simply delete the inside version and export the outside. Or merge all of the faces/verts that overlap and recalculate the normals, then export.

Enjoy your day.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Dec 2010 21:37
Quote: "I think this is a technique to make the model double sided - an inside and an outside without having any additional depth."


Yes, that was probably what made the model's author do that, but in the case in point it was probably done in error since it was a model of a stone wall and you wouldn't normally want to be inside a solid structure like that.

Quote: "I think it'd take a bit of work to remove the extra polygons."


Yes it might.

Quote: "A possibility would be removing the face indexes for every face number above the halfway point of the polygon count. Assumingly, one side of the model is done, then the other side (a duplication of the polygons with reverse winding order)."


I didn't think of checking that possibility - but if I recall correctly they are all mixed up together. Worth another look though, thanks.

Quote: "But then again, each face could be in pairs, face 1a then face 1b, face 2a then face 2b, etc. "


That might be fairly easy to fix in code. Messy but doable.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Dec 2010 00:30 Edited at: 5th Dec 2010 00:36
I just messed around a little with Deled3d and it seems that you can edit an imported x file that has the double polys, with relative ease.

I'm attaching a cube I exported from Blender using my own python exporter (so I think it's ok ). The cubes faces are exported as quads - so instead of 6 there are 12. The faces are all stored in the same mesh so I think it should mimic the situation you are describing. The outer 6 have the face normals pointing outward. The inner 6 have the face normals pointing inward.

In Deled, import the cube using the direct x import plugin. Scale the cube up to about 200 units (about 100 times) so you can see it easily. Deled uses a pretty large 3d unit scale - a 32 or 64 unit base (where Blender's base is 1 unit) - though I'm using a pretty old version of deled. Hold SHIFT and LEFT CLICK on the object to select it. Once selected, RIGHT CLICK on the object to view it's properties. Next to the Polygons list item, you should see 12. That means our 6 sided cube is registering 12 sides. And since the x file was exported with quads, not triangles, we can see that there are twice as many polygons as we need.

Anyway, once imported, select the object, then go to polygon mode. Hold SHIFT+CTRL and left click on each face on the outside of the object. DON'T do group select by using a drag box because that will select the polygons on the inside as well. There may be a way to select multiple faces at once without selecting the inside faces, but I don't know how.

Once all of your faces are selected, press the delete key. You should be left with the opposite polygons with the normals pointing in. While still in polygon mode, hold SHIFT, and this time drag a selection box by holding LEFT CLICK around the entire object. The whole thing should highlight. Under the polygon menu, click FLIP to reverse the normals.

If you RIGHT CLICK on the object now to check it's properties, the polygons should read 6.

We did the outside and then kept the inside. I chose this way because it's a little easier. If you want to do the inside and just delete the polygons and thus skip the step of flipping the normals, then you just have to move the camera into the object in the 3d view. It's a little tricky because it's easy to lose your way. But if you delete a few polygons at a time instead of all of them at once, you should be fine. Just make sure culling is on if you select and delete polygons from the inside because that way, the outside ones won't show and you won't be easily confused by what you deleted and what you didn't delete.

When you're done, texture you object how you need to if it hasn't maintained it's textures, and export it to direct X or 3ds or whatever. Deled has plugins for all of this and the free version can use them.

Enjoy your day.

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Dec 2010 01:01
Yes, I considered doing essentially the same thing in MilkShape but decided that selecting each poly one at a time was too laborious (there were thousands ). I couldn't see a way of selecting only the visible polys (the choice was ignoring/not ignoring backfacing polys).

Perhaps I ought to have another look at DeleD?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Dec 2010 02:20 Edited at: 5th Dec 2010 02:25
Hmmm... maybe the ignore option is the trick? Or does that just not select polys at the back of the model?

If you want to take a stab at Blender I think I have a solution. Forgive me, I'm going to outline the steps in a long post. It's not much work I'm just breaking it down so it's easy to follow.

This process is based on Blender 2.45 (it's what's in front of me without rebooting and switching OSs) but should work at least up to version 2.49

1. Start Blender

2. At the top click on File > Load Factory Settings > (answer ok to erase all). This step is just to make sure we are looking at the same thing and there isn't a custom setup to worry about.

3. Tap the TAB key until the mode is Object Mode. There should be a little view box about midway down the screen that will display the current mode.

4. RIGHT CLICK on the cube in the middle of the grid. It should highlight purple/pink if it isn't already.

5. Press X to delete the object

6. Click File > Import > Direct X (or whatever file format is available that you want to change. For our purposes we'll stick with Direct X) Import your object.

Press SHIFT+C and then press C. This will center everything in the view so it's all visible.

7. Right click on the object. If an object is made up of multiple limbs, they will all load as individual objects. RIGHT CLICKING selects an individual mesh/object.

8. Press F7 to open the object control panel. At the bottom of the screen there should be a panel with the heading Draw. Within this panel there should be a series of buttons under the heading Drawtype. Click on the button labeled Solid. If you weren't already, you should be in solid mode. This is the mode that's going to allow us to separate the inside and the outside polygons.

9. Tap TAB to toggle to Edit mode.

10. Press CTRL+TAB+3 to enter polygon mode

11. Tap 'A' key until NONE of the faces are selected.

12. There is a menu bar dividing the grid on which the cube is draw and the panel area where you selected solid. This menu bar has a control on the FAR LEFT that looks like a little 3d cube. It should be next to a button with a triangle on it that is depressed. The triangle button is the control to be in face mode which we used shortcuts to activate.

Anyway, this cube button will control whether we can select all of the faces, or just the visible ones. We want to press this button (click on it) to select just the visible ones. If you hover the mouse over it, it reads

Limit Selection to Visible

13. We're almost there! Move the mouse onto the grid. Press the 'B' key and a dotted plus will appear. This is Box Select mode. Hold the LEFT MOUSE BUTTON and drag a box around the object. All of the visible faces should highlight.

Now, some of the faces on the outside might have been out of the camera view. With the mouse in the grid screen, hold the LEFT and RIGHT buttons simultaneously and move the mouse around to rotate the camera view. If you see any faces that are not selected, release the mouse buttons, press B, abd select the object again.

Once you are sure all of the outside faces are selected, press '7' on the numerical key pad to return to the default view. If you need to, you can center the screen as we did in the beginning - but you don't have to.

14. On the middle menu bar, click on Select > Inverse . This will highlight all of the hidden polygons.

15. Press the 'X' key and click on Faces to erase the hidden faces.

16. You are done! Toggle to Object mode (TAB key) and right click to select any other objects/meshes that were imported and run through the same selection/deletion stuff.

Likely, there's going to be some missed polygons, or a few doubled polygons. Handle those on an exception basis. Once you get the short cut keys down, this entire process only takes a couple of minutes at most to do in Blender. Once you've removed the doubles and exported your model, you can tweak it in an app you're more comfortable with.

There are many threads on exporting an X file from Blender so I won't get into that.

Enjoy your day.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Dec 2010 12:34 Edited at: 5th Dec 2010 14:14
Is Blender reliable?

Every modelling package I've tried fails to export X files consistently. For example, I went to a lot of trouble to create a simple welded model in MilkShape - no limbs, no animation. The final model had 1002 vertices and was exactly what I wanted. (I needed them to be welded because I was going to adjust the vertices in code later and didn't want them to separate.) Then I tried to export the model as an X file. I just couldn't get either to work despite the many suggestions various people have made. What was particularly annoying was the fact that after exporting the previously welded loaded model was partly unwelded again. Why? Why not leave the loaded model alone? I then tried FragMotion. I loaded the same welded MilkShape model into FragMotion and then tried to export it as an X file. Lo and behold! The model was partly unwelded again.

Would Blender be any better?

I'm probably going to have to resort to writing my own X file in code - at least that method works although it is rather tedious.

Edit Latch, your comments have prompted me to have another attempt at removing the duplicate polys using MilkShape. Careful use of the select and deselect options seems to be what is required. Once I've done that I'll look into the X exporting issue again - sometimes the X files can be made to work by editing them manually. Just yet another tedious task.

All is not lost yet.
charger bandit
15
Years of Service
User Offline
Joined: 10th Nov 2009
Location: Slovenia
Posted: 5th Dec 2010 17:12
Fragmotion has some pretty sweet import and export functions,works great.


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Dec 2010 19:57
Quote: "Fragmotion has some pretty sweet import and export functions,works great."


Except it messes up the welding.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Dec 2010 22:49 Edited at: 5th Dec 2010 22:53
Quote: "Every modelling package I've tried fails to export X files consistently... Would Blender be any better?"

Yes and no. Blender's (2.4x) built in exporter, Kira Vakaan's, and my exporter all create an x file where each face has it's own set of vertices. That means that the faces are not welded, correct? You would like adjacent faces to share the same vertex indeces, yes?

When I created my direct x exporter from Blender, I originally used shared vertices. I eventually ran into trouble with complex normals and UV coordinates.

I think in the case of my exporter, when I used shared indexed vertices in the exported x file (8 for a cube for example), the normals always ended up flat shaded (face normals instead of vertex normals) and individual face UVs could not be manipulated without affecting their neighbors. Everything was "magically" solved when I output unwelded mesh information. This may be the case with many direct x exporters.

Also in Blender specifically, there are a few methods to get the vertex data. You can query the vertex data by itself in which case it will give the "welded" vertex index, or you can query the face data which will give you individual vertex information relative to each face. The UV's, the normals, the textures, all are based on the face data. It's much easier, and depending on the data to retrieve, almost necessary to use the face data references when creating the export.

What does all of this mean? It could be most 3d apps only make their internal data available for export relative to face data. Materials may be tied to a face, textures are tied to a face, UVs are tied to a face, etc. In order to be "universally adaptable" to multiple output formats, this is how the data has to be retrieved. I'm just guessing.

For the Blender exports, it's totally possible to still use the internal face data and add code to combine the same vertex data and output faces with repeating vertex indeces. If you have any desire to use Blender, you may want to drop a line to Kira Vakaan to add welded faces as an option to their exporter.

So after this long winded response, the short answer is: all of the Blender exports I'm aware of do not export welded vertices - though you can quickly eliminate the double face problem you mentioned previously following the multiple steps I posted earlier.

Enjoy your day.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Dec 2010 00:35
In MilkShape you have the option to weld vertices and it works fine. It's unfortunate that the X file exporters are both broken.

Welded vertices don't make sense for objects like cubes - except separately on each face where you can use 4 welded vertices rather than 6. For more complex objects without sharp edges, such as human faces, welded vertices might offer some optimisations.

But really there's no excuse for not exporting the object in the form it was constructed, especially X file exporters.

Your point about UV coordinates is relevant in that it doesn't usually make sense to weld all coincident vertices. It would be difficult to satisfactorily UV map a completely welded sphere for example - one or both poles are usually left unwelded and a pole to pole seam is usually left unwelded for the same reason. Ideally it should be up to the modeller to choose the appropriate option for their model - not chosen automatically in some undocumented way by the exporter.

Quote: "though you can quickly eliminate the double face problem you mentioned previously following the multiple steps I posted earlier."


I'd be surprised if it was quick if my experience of MilkShape is anything to go by. In a complicted model with several overlapping parts in different viewports it's too easy to select the wrong faces. The mistake that gave me the biggest headache was accidentally changing the winding order of one member of a hidden pair of duplicates and not noticing till many other edits later - after changing one member you always selected neither or both members of the pair thereafter. Would Blender distinguish between the two?

The good news is that I've reduced the poly count from about 2200 polys to about 1150 with just a few minor errors (probably on my part ). Either there are some duplicates I haven't yet spotted or the model wasn't purely duplicated to begin with. The bad news is that one exporter produces X files that won't load into other apps, and the other crashes MilkShape before finishing exporting.

The steps I used were essentially those you described for Blender and were straightforward, but time-consuming, and a bit error prone if you forgot to deselect unwanted choices correctly.

Quote: "So after this long winded response"


Seems to be catching.

It does give a welcome break from struggling with duplicate vertices though.
Duke E
15
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 6th Dec 2010 10:46
After exporting my models from Blender i run them trough MeshView (mview.exe, MS DirectX SDK tool).
In "MeshOps menu/Weld vertices" I use Regenerate Adjacency and Partially Weld Vertices, remember to set the Epsilons to 0.0 for all axis. "weld all vertices" do not quite work with UV coordinates. "partially weld" reduces the vertices quite nicely though.

Regards
Duke
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Dec 2010 11:58
Quote: ""weld all vertices" do not quite work with UV coordinates"


Yes, you need to watch out for that.

The good news about the model with duplicated polys is that the poly count has been almost halved from about 2200 to 1120 and now runs at 1230 fps rather than the original 930 with two copies on the screen - one with and one without a normal map shader applied. I had to open the MilkShape model in FragMotion and export the X file from there. As charger bandit said, the FragMotion exporter seems to be reliable (except for the unwanted unwelding issue).

My original reason for doing this was that I wanted to weld the vertices so the vertices could be randomly moved around in code - but I think the UV mapping could be a problem as others have noted.

At least I've learnt a lot about how to use MilkShape in the process.

Thanks everyone for suggestions on this.

Login to post a reply

Server time is: 2024-11-24 08:08:43
Your offset time is: 2024-11-24 08:08:43