Lightwave objects and OpenGL

I’ve managed to make a VERY simple LWO loader into my 3D objects structures, but still can’t parse correctly the UV coordinates for texture mapping.

Any clue?

Hi,

generating UVs for LWO requires some work !

You need todo the projective math in function of the type of mapping (planar, spherical, cubic, cylindrical…) and its axis. Moreover, if you take into account the ‘World Coordinates’ flag, you have to take into account the position of the object in world coordinates ; so UVs can vary with its position, and a single LWO may have multiple UVs !

This must be done for every vertex of every face (because of discontinuities) ; and the results have to be merged (if you don’t want to end with a load of verticies).

You can find the algorithm (or source code) here : http://www.helsinki.fi/~tksuoran/UVCODE.TXT

I’m afraid your loader becomes less simple after that

There are some links that might interest you : http://www.mgdesign.org/uk/Liens/index.php3?pere=42

Hope that helps !

Originally posted by Nicolas Lelong:
[…]and the results have to be merged (if you don’t want to end with a load of verticies).
[…]
I’m afraid your loader becomes less simple after that

That source shows how to calculate the UV given XYZ of each vertex, not how to read those unknown UV data in a LWO file.

I’ve already managed to make a cylindical mapping, despite with a small bug across the z axis of the object. Perhaps those codes will help me to make better mapping.

Thanks

Hmm, LWO files don’t contain any explicit UV data, you have to calculate them yourself !

But, LWO2 (LW6+) files can contain UV data, depending whether UV mapping was used when modelling or not.

Good luck !

Hi!

I’m actually coding a converter for my own use for Lightwave 6.5 LWO2 format and the best place i have found information about the data structure is http://members.home.net/erniew2/lwsdk/

Check the file formats and examples, especially samples/lwo2prn, it prints the contents of an object file to standard output. Unfortunately it doesn’t support discontinous vertex maps and other things that are new for 6.5. And if you need to interpolate the envelopes, check samples/envelope for source code.

You should be able to make a loader or a converter for the LWO2 format quite easily if you know what values you need for your own use.

  • Janne

[This message has been edited by Janne (edited 11-21-2000).]