Texture mapping a Lightwave 3D object...
Hi
My lightwave object loader is almost finished apart from one little problem. I can't find any texture mapping coordinates in the model files. I'm using Lightwave 5 and the objects it produces don't seem to contain any texture coordinates. So how on earth am I supposed to texture an object with no coordinates??? Do I have to calculate them myself??? Anyone got any experience of writing a Lightwave object loader and come across this problem?
Steve
September 08, 2005 11:02 AM
Lightwave objects up through version 5 ("LWOB") had no texture coordinates. In a surface, for a texture layer, you can select various mapping modes, such as spherical, cylindrical, planar, etc. you will just need to read the material definition, and calculate texture coords based on the mapping type (and scale/translation/whatever applied to it.)
Now, from version 6.0 on, "LWO2" is used, which does support texture coordinates, but the artist has no obligation to make texture coordinates because the other mapping methods are still available. Actually, you can have many kinds of vertex maps with per-vertex information in an LWO2, such as point weights for SDS, multiple UV tex coord maps for multiple materials, all sorts of fun stuff.
Now, since you are using the lwo format, may I suggest you check out the Lightwave SDK? There is sample code for reading a lightwave object in either the new or old format. It is one of the samples, but I don't recall the name. If you remove the file with main() from that sample, you can compile the rest as a library, or just add it to a project, and it will handle all the quirks of a .lwo file. Unfortunatelt, the header file isn't as well commented as one might like, so it can be slightly annoying to try to get at everything. But, I found it much less annoying than trying to roll my own! :)
I haven't bothered adding texture mapping to my current project yet, but I do use the color and opacity from .lwo's in it. Very easy, and slick. The only drawback is that because a lightwave object supports arbitrary polygons, it isn't convenient to use vertex arrays without some processing when you load the object. How are you drawing your objects?
Now, from version 6.0 on, "LWO2" is used, which does support texture coordinates, but the artist has no obligation to make texture coordinates because the other mapping methods are still available. Actually, you can have many kinds of vertex maps with per-vertex information in an LWO2, such as point weights for SDS, multiple UV tex coord maps for multiple materials, all sorts of fun stuff.
Now, since you are using the lwo format, may I suggest you check out the Lightwave SDK? There is sample code for reading a lightwave object in either the new or old format. It is one of the samples, but I don't recall the name. If you remove the file with main() from that sample, you can compile the rest as a library, or just add it to a project, and it will handle all the quirks of a .lwo file. Unfortunatelt, the header file isn't as well commented as one might like, so it can be slightly annoying to try to get at everything. But, I found it much less annoying than trying to roll my own! :)
I haven't bothered adding texture mapping to my current project yet, but I do use the color and opacity from .lwo's in it. Very easy, and slick. The only drawback is that because a lightwave object supports arbitrary polygons, it isn't convenient to use vertex arrays without some processing when you load the object. How are you drawing your objects?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement