>> Are you trying to convert screen coordinates to world coordinates?
Ok, its almost working. Big headache, but finally It seems surprisingly
easy.
Now I understand lots of mistakes I do with OpenGL (what red book??).
Let me share some thoughts, corrections are welcome:
0.- Do not reinvent the wheel.
1.- Never move the camera, move the rest of the world. (Fog works! :)
2.- Save a copy of the projection and view matrix when projection is
initially set.
3.- Save a copy of the model matrix before the target.blit
4.- For each target, project target position and then unproject mouse coords
to
get the coords in its plane.
Some code for point 4, may be it helps to another newbie.
#class target
def convert_3d(self,mouse_x,mouse_y):
wx,wy,wz,sz = GLdouble(),GLdouble(),GLdouble(),GLdouble()
gluProject(self.x, self.y, self.z,
self.model_matrix, win.proj_matrix, win.view_matrix,wx, wy, sz)
gluUnProject(mouse_x, mouse_y, sz,
self.model_matrix, win.proj_matrix, win.view_matrix,wx, wy, wz)
return wx.value,wy.value
It works fine when traslating the world around the camera.
Sure it is another typical newbie question, The only issue that I have is
that when I rotate the world, the target coords are not correct.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---