Hello,
I have issues for generating texture coordinates for cubemapped objects.
Here’s about the story: I load a model which has 3D texture coordinates. This models renders pretty well with cubemapping, the textures do not overlap, are not distorded and so on.
Now I would like to generate textures for it, by program.
For achieving this, I use this tutorial to calculate which cubemap texture to bind for, and the 2D texture coordinates according the 3D textures coordinates:
http://developer.nvidia.com/object/cube_map_ogl_tutorial.html
However, the texture looks very strange (cf image link below).
Basically, choosing the good texture to bind for (GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB…), works very fine, since I tested it for drawing normals with different kind of colors according to the 3D textures coordinates. So I guess, maybe I misunderstood the calculations to transform a (s,t,r) texture coordinates to a (s,t) one.
Here is a piece of code of what I’m doing:
// if s is positive and the major axis direction:
s = (-rz/ax+1)/2;
t = (-ry/ax+1)/2;
// same but s is negative:
s = (rz/ax+1)/2;
t = (-ry/ax+1)/2;
...
where rx,ry,rz are the (s,t,r) texture coordinates, and ax,ay,az, the magnitude (so postive parts) of these texture coordinates.
I stricly followed up what nvidia said about the calculations.
But maybe I misunderstood the sc,tc and ma values ? What do you think about how I calculated s,t here ?
EDIT: I colored every triangle with random color. So, what’s messed in the image is not those little colored triangles, but the long rectangles and the big blue triangle.