PDA

View Full Version : UV map problem in .lwo format



Wavesonics
12-11-2007, 02:14 PM
I'm not sure if this is the right forum for this, if not please direct me to it.

I'm writing a loader to load the data from .lwo files as my models in an engine.

I'm using the lwobject code from the lightwave SDK, and got it running just fine and even pulling verticies and UV maps for simple geometry.

But When we took a cube that was rendering just fine and tessellated it we ran into problems.

I was pulling the UV map as such:

float **textureCoords = layer->polygon.pol[ii].v[yy].vm[0].vmap->val;
model->m_polygon[ii + polyIndexOffset].polyVert[yy].u = textureCoords[yy][0];
model->m_polygon[ii + polyIndexOffset].polyVert[yy].v = textureCoords[yy][1];
So for a given layer, for a given polygon of that layer, for a given vertex of that polygon, I was getting the polyVert structure, and from there the VMapPt structure, which gave me a pointer to the correct VMap struct and an index into that structs 2 dimensional **val array who's 1st dimension I indexed into with the index from the VMapPt struct, and who's 2nd dimension stored the 2D UV coordinates for my specific vertex.

This like I said, worked fine for simple geometry (namely quads) but when we tried our tessellated cube, many of the PolyVert structs contained no pointer to any VMapPt structs (nvmaps also = 0).

So my question is, how am I suppose to access UV Maps in the context of a given polygon?

Wavesonics
12-11-2007, 06:50 PM
Ah, it had to do w\ the fact we had a discontinuous UV map.