Fixing the Wings3D Import Script

http://adam.lastchancemedia.com/blender/hard_edges.jpg

I modified the wings import script to split meshes along the hard edges marked in wings. This is very useful for low poly and game models! I would like to continue to improve this script by doing the following things:

1 - Fix bug where faces with more than 1 hard edge get trashed
2 - Strip away hole materials
3 - Read UVs
4 - Just generally fix the script so that it can read all wings models, instead of seemingly random/arbitrary ones ( i think this has to do with textures & materials?)

Here is what I have so far!

http://adam.lastchancemedia.com/blender/wings_import.py

This is the first thing I ever did in Python, and I only spent a few hours on it, including learning python, etc, so it is not exactly a masterpiece. Most of the changes are in the “Read” function, but i also modified the “make face table” and “make faces” functions to work with non-manifold meshes. Any input, help, ideas etc would be greatly appreciated! I will finish this whole thing myself if I have to, but I would love to have others help! Thanks!

I’m not a coder, so I couldn’t help with the code, but would it be possible to convert the hard edges to edge weights instead?

That might be an option? It’s not one that I’m interested in, but if other people think its useful i’m sure someone could add that as a second possibility. weights are not very useful in terms of game models, which is what i’m gearing my work toward.

Great to see your work here Adam. I aways convert my polys to quads before sending to Blender. Blender doesn’t support Ngons as in 5 point polys. I don’t know if we have access to Blenders mesh system that relates to F-gons via Python. F-gons are a “fake” version of an Ngon “like” support for Blender’s system.

It would be nice to keep the 5 point polys from Wings 3d have these converted to F-gons.

JA-forreal - From what I can tell, the extension call to “meshbuild” or whatever passes in the n-gons, and the triangulated faces come out the other end (I think!). Maybe someone can modify the meshtools scripts to incorporate f-gons?

I’ve made some more progress on the hard edges, sort of, but I’ve realized that Blender already HAS the algorithm and effect that I need for the hard edges to work properly. If you mark seams in Blender, and then do an auto-unwrap, it appropriately doubles all the vertices along the correct edges already (in the UV map). I just need to use that same process to correctly dupe my verts and assign the faces correctly afterward.

So, from the Py script, I need to just build the mesh normally, then mark the hard edges, and do something similar to the way the unwrap works. Also, it would be nice to incorporate this operation in the blender edge edit menu I think. Highlight some edges and then call “split” or something, and have it separate the mesh so us game modelers can have something akin to hard edges. I am kind of a Blender newb, so please, if this op already exists, LET ME KNOW!!! It will make my life a lot easier. Thanks!

cool - the download did not work for me, but i want to take a look some time.

~Toni

Weird - I just tested the link, it seems fine. However, I’m afraid it may not help that much. My approach is too limited to work with all the possible hard edge cases, it only works for nice edge loops. My buddy Toastie from CGTalk has been working on adding the UV coordinate importing though, and that seems to be working pretty well so far. He is also looking at marking the seams as creases, rather than just splitting them up.

It would be REALLY nice if Blender could use the AutoUV Seam analysis to do a “split mesh on creases” operation. Then you could import your wings model, and either subdivide it or else just call that split op and have a great game model all set. I might be able to work on that myself but it would be a while, my 2 jobs are taking up a lot of free time lately!

yup now i can see the code

  • i can believe there is interest, hopefully a good solution is made.

~Toni

I would rather have edges weighted instead of split. Otherwise… why would I have modeled the object as one piece to begin with?

Pablo - The reasoning behind the idea to just split the mesh is because I use Wings3D and Blender to make video game models. Hardening edges is VERY fast in Wings3D, however, since it uses manifold meshes only, there is no clean/easy way to split the mesh up. Blender, with its animation and rendering, is at the end of my pipeline anyways, so it seemed to make sense.

However, after hearing input from users here and on CGTalk, and after talking to Toastie, I agree that the most sensible thing would be to “crease” the edges. Then users can use the model for SubD or for gaming, if we add a “split mesh on crease” option to the Blender edge menu. So for now we are going to try and get the import script to just bring in UVs and mark the correct edges. After that we will see about actually splitting the mesh!

Sounds marvelous! I’m looking forward to your updates on this great script.

Hi Adam,

I’ll see about getting this update bundled for the next release, is the link above the most recent version?

LetterRip

Behind contract work and my day job and Toastie’s crunch-time this is probably not a good thing to include yet! While we were able to get it to at least import Wings3D files correctly, we did not get it to mark the edges properly. Lemme talk to Toastie and see if we can get a clean-ish version of the script that at least does the Wings3D thing…

Adam,

ok really the only question is, is it better than current wings importer :slight_smile:

If yes we should probably try and include it…

LetterRip

haha - good point - yes it definitely is, since it no longer crashes on any wings files that actually use UV coordinates. Toastie will post his changes tonight or tomorrow I think, and we will work on importing the UVs (rather than just ignoring them) and marking seams in the future.

Any idea if a “cut mesh on seams” feature is in the works?

sorry, no idea, you might post to blender.org developer forum and ask there.

Have you tested with 2.40alpha1 or just 2.37a?

LetterRip

Hi,

there is a bug report in the tracker - it isn’t clear if wings wrote a bad length for the number of faces or if the script is parsing the struct incorrectly, but either way the file doesn’t have 4 billion faces :slight_smile:

the arg being given to
range() in line 141 is 4 billion faces. Tom and I agreed
this is a tremendous feat for a 468K file. Even if the
input file is bad, the script should be doing some error
checking.

here is the file

http://projects.blender.org/tracker/download.php/9/125/3586/1595/52.wings

Yeah, what happens is when there are UVs in the Wings3D file, Blender reads them all as separate verts or something? It’s pretty crazy. Our changes skip the correct bits so that meshes are read in properly, albeit without UV info. I will get Toastie to post our changes I swear :slight_smile:

heh :slight_smile:

cool will be much appreciated.

Are your changes going to be under GPL also - scorpius is relicensing all of his scripts so we have less headaches.

LetterRip

Hi Adam,

sorry to pester you but any word? Tommorrow (12-15 hours from now?) is likely the absolute deadline for inclusion for 2.41 so if you guys can post an update before then, it would be really appreciated.

LetterRip