On Feb 2, 2008 3:38 AM, Txema Vicente <[EMAIL PROTECTED]> wrote: > 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
I'm not sure I understand what you're doing here - you're calling gluProject to fill out wx,wy,wz, and then you're immediately overwriting them with the call to gluUnProject? Also, if you're converting from screen coordinates to world coordinates, aren't you going to need to return wx, wy, AND wz? Seems like it'd be simpler to do something like this: def screenToWorld(screen_x, screen_y, screen_z, model_view_matrix, projection_matrix, view_matrix): world_x, world_y, world_z = GLdouble(), GLdouble, GLdouble() gluUnProject(screen_x, screen_y, screen_z, model_view_matrix, projection_matrix, view_matrix, world_x, world_y, world_z) return wx.value, wy.value, wz.value and then call screenToWorld twice to get a ray: p1 = screenToWorld(mouse_x, mouse_y, 0, [...]) p2 = screenToWorld(mouse_x, mouse_y, 1, [...]) Also, if you don't want to save the various matrices, it's easy enough to ask GL what they are. For example: model_view_matrix=glGetDoublev(GL_MODELVIEW_MATRIX) -Dave LeCompte --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
