Skip to main content
gamedev.net
🔒 Locked

GL_SPHERE_MAP

Started by jsaade Mar 2, 2007 at 2:54 AM 1 replies 3.1k views
Original Post
jsaade
jsaade
I am trying to play with opengl texture coordinate generation. The generated coordinates are in eye space. I was browsing chapter 6 of more opengl game programming. well, there was a mention of multiplying the texture matrix by the inverse of the model view matrix, thus taking the texture coordinates back to the world space. well I tried to browse the sample and I saw only inverse of rotation was performed, I am trying to do the same thing but in a general way so the coordinates would be in world space. so if i have a sphere object the texture would be wrapping the sphere and wont seem to move when i rotate or translate. I do not know if this is possible but i know that it does not work if I just multiply by the inverse of the model view (which for some reason does not seem so logical to me). I am not very pro when it comes to OGL texture generation, so I need some help if possible.
Lord_Evil
Lord_Evil
Well you mentioned that only the inverse rotation is used, and that's correct. Texture coordinate generation takes place in eye space and thus the coordinates have to be transformed to world space by the inverse rotation. Modelview also includes the translation but you should not include translation into your inverse rotation matrix unless you want the texture to move when the camera does.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
jsaade
jsaade
This should do the trick then:
double m[16];glGetDoublev(GL_MODELVIEW_MATRIX,m);m[12]=m[13]=m[14] = 0; //remove translationMatrix mt(m);m.inverse();glMatrixMode(GL_TEXTURE);glLoadMatrixd(matrix.getRaw());glMatrixMode(GL_MODELVIEW);Render();


yet it has not effect at all, if i walk towards the object, i still see the texture zooming in, and if i rotate i still see the texture rotating. I am sure it has something to do with me not being very familiar with OGL.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.