From Ohm

If the model coordinates are bounded by [0,1], then the texture coordinates are identical to model coordinates:

glTexCoord3f(x,y,z);

glVertex3d(x,y,z);

glVertex3d(x,y,z);

If this is not the case, OpenGL supports a texture matrix stack to transform the texture coordinates just like the transformation of vertices with the model view matrix.

Example for model coordinates $x,y,z\in[-0.5,0.5]$ and texture coordinates $s,t,r\in[0,1]$:

glMatrixMode(GL_TEXTURE);

glLoadIdentity();

glTranslated(0.5,0.5,0.5);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glTranslated(0.5,0.5,0.5);

glMatrixMode(GL_MODELVIEW);

Note: Transforming an object left, moves the object left. Transforming a texture coordinate **left** moves the texture coordinate left but it moves the texture visually **right**!

Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/TextureCoordinateGeneration

Page last modified on November 03, 2013, at 03:15 PM