LWO material importer: release 0.2.2 (pag.5)

Hey mom, look another post from this blender-python-programmer-wannabe.

Hi all.
I hope not to be OT. In case, just be patient.
This post is a halfway a “teaser” and a request for clarification on APIs.
All started trying to import some LWO models, and ended up tweaking the very clean lightwave importer code to grab materials, uvmaps and textures from lwo files.
The goal is to release the code as a contribution to the already excellent importer (thanks Anthony).

I’m nearly halfway. This is an example of object imported.

http://uaraus.altervista.org/dload/piano.jpg
(edit by mod, c&p) http://uaraus.altervista.org/dload/piano.jpg

Note: this is the result of the importer, and has not been altered in any way
(scaled and grabbed to fit camera view)

Some more examples on:
http://uaraus.altervista.org/index.php?filename=en/content/other/gallery.php
(credits for models in the News page)

I need to fix the following before evaluating a code release
* fix sub-surf - actually they are imported but are a little messy
* trying a modified fanning algo for concave polys
* fix problem with transparent materials %|
(parameters are ok, but materials are not transparent at all)

While uvmaps work (well, hoping so …) other texture mappings do not.
Maybe I’ve missed something but I cannot find the API calls to set
* texture rotation
* texture offset
* axis mapping
* type of wrapping (flat, cube, cylinder …)
* influence on normals

Oh, btw, in your knowledge, there is some known bug opening BMP image format? In Blender they result like “tilted”.
I had to convert all the images in png (ok, they could be better, but it’s so annoying)

Thank you in advance

I was looking at the apple, and the UV cooords do look wrong. This might be one of those weird cases where the mesh stores and uses uv coords from a combination of both the VMAD and VMAP chunks.

Hi scorpius, thank you for your feedback.
Sorry for my late reply but it’s hard time (cause of my “real” life).

Problems with uv in the apple image is not due to importer un-correct uvmap association.
Having both VMAP end VMAD chunks I’m not discarding any of the two, but I’m substituiting
the VMAP uv with the VMAD uv only for the specified face/vertex (as I understood from documentation).
It seems to work well for any other model … except for the apple.
Inspecting with blender uvmap editor, the uv for the incriminated face is correct, but “rotated”.
And this holds from the real beginning, from VMAP (before VMAD, triangulation and other things).

UV’s seems to work with my sample files and I’m pointlessly wandering for other texture mappings (as in my previous post), so I made little progress with them, but I’ve added sub-surf (PATCH) import and a triangulation algorithm for concave polygons (based on un-optimized brute-force ear reduction, but it’s reasonably fast and works quite well)
Avi demo here http://uaraus.altervista.org/dload/lwo_mov.avi
(open a fresh browser then cut&paste address)

… ok, stop talking to myself … :slight_smile:
I’m sending you the code by e-mail

I like the video! Cool stuff.

That’s the correct way to do it. I’m glad you know about this. So it’s something specific to the apple. If it works for most other objects, I wouldn’t worry about it too much.

I’m getting the error below for every object with more than 2 verts in a face. An outline imports just fine, but a plane will not. Is it supposed to triangulate quads as well?

File “lwo_import7p.py”, line 321, in find_ear
if list_dict[‘P’][a] > 0.0: #we have to start from a convex vertex
UnboundLocalError: local variable ‘a’ referenced before assignment

Hi just curious on the status of your project,

LetterRip

LetterRip
sorry for this late response,
long time before looking here (hard time). :smiley:
I’ve completed a first “stage”: I needed the script to import some UVmapped objects and it worked (for me).
Materials ok; tex mapping ok, but left me unsatisfied.
(made a test movie: on my site, look in the gallery for time-out, 8megs dload)

This is very far from perfection and it was a real mess, but I gave it to scorpius, to see if he can integrate it in his code (not because Anthony lacks experience and ability, but because I wrote it very bad).

To further map some material/texture property I need some additional API calls (or I’m missing them?), so I will look at 2.37 API docs to see if there is something new on this side.

I will post an evaluation copy, only to collect feedbacks.
(oh, if someone’s interested, anyway :D).
All the best

I hada look at improving the LWO importer to support more lightwave stuff-
ANd managed to find some docs, but couldent find many test files.

If sombody was some test files that use LWO 6.5+? Features that it could be usefull to me (or scorpius) for testing.

  • Cam

Cam if you download the demo version of Modo it has a number of free lightwave models.

LetterRip

Just in case you want a good polygon filler for those concave polygons, there is a high quality filler which you can append to your code. See the last post in this thread:
https://blenderartists.org/forum/viewtopic.php?p=352043#352043

It will never create polygons the wrong way, and will create quad polygons first.

How is the lighwave importer coming along?

Actually my main problem is that I can’t seem to get materials exported with the lightwave exporter and would like to use the importer to see if the exporter is actually working. :stuck_out_tongue:

Regards
Paul

Hi all.

First release available for dload at:
http://uaraus.altervista.org/dload/lwo_import0.1.14.zip

edit: from 0.1.13 fixed the absence of mod_vector.py from latest releases.

Web page at:
http://uaraus.altervista.org/index.php?filename=en/content/categories/Blender/LWO_importer.html
maybe you need to dload from it (direct dload could not work):
I’d like to add links to some blend models imported from LWO (in the near future).

some shots:
http://uaraus.altervista.org/dload/canberra_0_640.jpg

http://uaraus.altervista.org/dload/Vega2_0_640.jpg

http://uaraus.altervista.org/dload/sponza_1_640.jpg

Hope you like it.
Please, if you can give feedback. Thanks.

Getting stable.
New update at:
http://uaraus.altervista.org/dload/lwo_import0.1.15.zip
Many tweaks under the hood and UVmap not only in the material but also on faces game engine settings.

Web page at:
http://uaraus.altervista.org/index.php?filename=en/content/categories/Blender/LWO_importer.html
maybe you need to dload from it (direct dload could not work):

1 more shot:
http://uaraus.altervista.org/dload/Shuttle_0.jpg

Hope you like it.
Please, if you can give feedback. Thanks.

wow what a great job uaraus

I primarily use lightwave but I love to exploring all the new features of blender and often use it to get in and out of file formats that lightwave has little or no support for. It is UNREAL how well this script imports lwo files. There are a few glitches here and there but nothing you dont cover how to fix in the pdf provided. Now all I need is for someone to write a .mdd import script for blender so I can bring in baked animations as rvks.

anyone that uses lightwave should try this script

@slow67
thanks for your review and your feedback. Happy to hear it is useful to you :smiley: .

Getting a little better.
New update at:
http://uaraus.altervista.org/dload/lwo_import0.1.16.zip
little tweaks especially on image search, logfile feedbacks and parameters for non-uv-mapped textures

Web page at:
http://uaraus.altervista.org/index.php?filename=en/content/categories/Blender/LWO_importer.html
maybe you need to dload from it (direct dload could not work):

Hope you like it.
Please, if you can give feedback. Thanks.

I’m sorry I cannot give you any worthwhile feedback. Your script worked to perfection, importing all the textures with unerring accuracy.

I tried it on a lightwave mesh from a client and it even imported this tricky mirrored material that was giving me trouble. The only thing missing is procedural textures, and that is more or less impossible.

I’m impressed. :smiley:

Every feedback is valuable.
Especially the ones that confirm all is going ok. :smiley:
(so I’ve said it: tomorrow 1 million bug reports) :smiley:
Thanks

I did notice that while your script was importing a Lightwave mesh that had about 15,000 polygons, the screen would flicker madly during the import process.

But it in the end it imported just fine.

@nyrathwiz
Thank for your feedback :smiley:
Sorry, I can’t re-create the same behaviour.
(Win2K box, Blender 2.37a-no CVS, Python 2.3.4)

During the file reading phase, the only interaction of the script with the GUI is to show the progressbar.
During the mesh generation (obviously) there is also the redraw of 3d window.
Cannot figure out how this two could nastily interact with the screen (may be an OpenGL problem? just guessing).
Have you tried if the same thing happens with the standard importer? It basically shares the same structure as mine.

It seems strange to me this behaviuor depends on the number of imported polygons.
I made some tries with a couple of mid-poly model, and all seems fine to my side.
http://uaraus.altervista.org/dload/Jaguar1935-800x600.jpg

The flickering also occurs with the standard importer. And it does not happen on my second computer. So it is obviously a problem with the first computer, not your script.

Now, I did find another person’s mesh that your standard LW importer will load, but the LW material importer seems to choke on it. The mesh is rather huge so maybe this is understandable.
The mesh is here:
http://www.lwg3d.org/v3/meshes.php?item=537
a free registration with LWG3D is required to access the mesh.

The progress bars during the import process move, then at some point they freeze, and nothing seems to happen after that. After about five minutes I do a ctrl-alt-del and manually shut down Blender.

Again, this is a huge mesh, so if your importer can’t handle it, this is no big deal. And like I said, your standard importer loads the mesh with no problem.

Even if a script can’t import a file because it is too big - it should fail gracefully - ie do a size check beforehand and then warn that the file is too complex, etc.

LetterRip