Calculating UV Mapping coordinates

Hi there, all!

I’m having a bit of a philosophical question here, I think. How does one calculate correct UV mapping coordinates? (If there is a way to do it)

The thing is, I export OBJ files from my 3D modeling package (Carrara, buggy SOB, but nice), and the texture coordinates come out with a distorted edge. So, I set out to calculate my own. The way I see it, sphere mapping is not sufficient, since I need something that is more dependent on the distance between vertices.

So, I start out at vertex 0 (Already this is wrong, I’m supposed to start at some kind of “top vertex”, but hey!) and I wish to measure the circumference of my model. I don’t think this is possible, since we’re dealing with 3D here.

Any thoughts? How do 3DS Max handle this?



Right then, three possibilities,

  1. The texturing co-ordinates are correct but you interpret them incorrectly.

  2. You have specified the texture mapping incorrectly so it’s using something like GL_CLAMP when it should be using GL_REPEAT

  3. The package you use is giving you incorrect data

In order to check if it’s 1, there should be a list of texturing co-ordinates that start with an index of 1 and will count to n texturing co-ords. The faces then use an index on each vertex to determine which tex co-ord out of that array it should use. It may be that you are either a, getting the index incorrect because you’ve forgotten that array indices start at 0, and the file starts at 1; or, b, treating the texturing co-ords as though they should be applied in order and have mis-interpretted the file format.

If 2, there will be small areas of the model that have texturing co-ords that work OK, but the remaining areas have a texture distorted across them so that it appears that it is streched. If this sounds familiar, search for GL_CLAMP in your code and replace it with GL_REPEAT.

If none of the above works then 3 must apply. In that case, use a different modeller because creating your own texture co-ords (or getting opengl to do it for you) is a waste of time.