PDA

View Full Version : Texture Matrix



Orzech
03-08-2003, 10:13 AM
Hello!
I have one simple question. It is... What happens when rotating a texture matrix? It changes texture coordinates, or what? It would be great if someone could answer my question or explain me where am I wrong (if rotating texture matrix is not possible).

Thanks!

shinpaughp
03-08-2003, 11:43 AM
If you are looking to rotate a texture with an object, you do not need to touch texture matrix. From what I have read, the texture matrix allows you to add effects to textures which would otherwise be unattainable or difficult at best. Never messed with it as yet.

For having preexisting texture rotate with object rotation you just need to rotate about global center, translate, rotate about self, enable texturing, bind an existing texture, call glTexEnv to set up aspects of how you want the texture handles, draw polygons with tex coords, and disable texturing otherwise it will texture next object.

example



glRotatef(angle1, 0.01, 1.0, 0.0);
glTranslatef(250.0, 0.0, 0.0);
glRotatef(angle2*5, 0.03, 1.0, 0.0);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, texName[0]);
// gluQuadricTexture(quadsphere, GL_TRUE);
glSphere(2.0, 15, 15, TRUE, TRUE);//custom - used to be gluSphere
// gluQuadricTexture(quadsphere, GL_FALSE);
glDisable(GL_TEXTURE_2D);


If you are looking to do some effects with the texture matrix, sorry for the confusion.

[This message has been edited by shinpaughp (edited 03-08-2003).]

Orzech
03-09-2003, 06:40 AM
Hi.
Well I was thinking about something else. I know how to texture objects. I just wanted to know if there's any sens in rotating, scaling or translating texture matrix. You said that it can be used for making some addidtional effects. Any idea where can I find some info about it?

Thanks

Miguel_dup1
03-09-2003, 06:58 AM
Texture matrices are very useful when you want to render things such as a moving sky!!
This is how I use it. You can rotate, scale, and translate the texture as if it were a regular model.

Good luck.

Orzech
03-09-2003, 07:30 AM
Originally posted by mancha:
You can rotate, scale, and translate the texture as if it were a regular model.


Hmm.... So it changes texture coordinates, isn't it? I suppose that I can't use glMatrixMode() between glBegin/glEnd. Am i right? It would be too nice if that would be possible http://www.opengl.org/discussion_boards/ubb/smile.gif.

Thanks

Miguel_dup1
03-09-2003, 10:31 AM
That is right. But you want to have the matrix mode change outside of the glBegin, glEnd.


Originally posted by Orzech:
Hmm.... So it changes texture coordinates, isn't it? I suppose that I can't use glMatrixMode() between glBegin/glEnd. Am i right? It would be too nice if that would be possible http://www.opengl.org/discussion_boards/ubb/smile.gif.

Thanks