PDA

View Full Version : why the highlight spot of a sphere doesn't change while i'm moving camera?



bluebleam
06-01-2013, 03:00 AM
before:
https://7y6xpa.sn2.livefilestore.com/y2pA2GeFvo8-HQgHnqO0jd_jpsiiagIns_oKM3gwjiLshqhONw-vWcvWqKtjj1V10-4Vm8Dz9PuHwm1W8darAHGrVmaR7qLWD_lx-f8oEZorFLtDKcq3Ror5twWoED-PvYp/QQ%E6%88%AA%E5%9B%BE20130601175243.png?psid=1

after (camera moved to the right side of the room):
https://7y6xpa.sn2.livefilestore.com/y2p3RN3TUeYr8trHqYi19r6HkrnbyEDB08TwMJzOrALMU_CzlY kfOQeipq3Cx-IzqNUbVNA8f_obxhIO-RbWViBFgDjunhzod3IdzkkhCnOZI4S9oIAt8hzCMpThpC1RxE0/QQ%E6%88%AA%E5%9B%BE20130601175302.png?psid=1

The position of the lights didn't change while the camera is moving (In fact, the white ball and the red cone represent where the lights are).

The highlight spot of the sphere (circled) is really strange. I thought the spot would change when I looked at it at a different position (changing the camera), because it's Specular Reflection! But it just didn't.

I checked my code and found nothing. Can anyone please give some tips?

bluebleam
06-01-2013, 03:51 AM
Well, I now know what happened. I use glLookAt while glMatrixMode(GL_PROJECTION)!
Let me get this straight:
before:
glMatrixMode(GL_PROJECTION)->gluPerspective(...)->gluLookAt(...)
after (fixed):
glMatrixMode(GL_PROJECTION)->gluPerspective(...)->glMatrixMode(GL_MODELVIEW)->gluLookAt(...)

so, gluLookAt cannot be used under projection matrix!
But now I don't quite understand while the wrong was like that. Though it was wrong, When I set "gluLookAt", the camera position did changed! Why just the highlight spot turned out like that?

tonyo_au
06-01-2013, 07:21 PM
read this http://www.songho.ca/opengl/gl_transform.html to understand how the matrices work