Re: [PyOpenGL-Users] get Translation inside matrix stack
Brought to you by:
mcfletch
From: Gary H. <gh...@is...> - 2008-07-22 18:14:52
|
Prashant Saxena wrote: > I am sorry but I didn't get any success with your code. I tried this: > > glPushMatrix() > glTranslate(5,0,0) > glTranslate(10,0,0) > glTranslate(5,0,0) > # To get total increment of x axis(which is 5+10+5=20) > modelview = glGetFloatv( GL_MODELVIEW_MATRIX ) > print modelview > glPopMatrix() My mistake. The glGetDouble/glGetFloat call is the right thing here, but I was confusing my Python-to-OpenGL libraries. Your syntax is correct for PyOpenGL. (Mine was for a library called Pyglet.) > > but I am getting this: > [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], > [0.0, 0.0, 0.0, 1.0]] > Which does,'t solve my problem. There are several matrix stacks maintained by OpenGL. Which one are you using when you issue the glPushMatrix-glTranslate-glPopMatrix calls? Probably not the GL_MODELVIEW_MATRIX since that's still the identity when you get it back. You need to choose your matrix first: glMatrixMode(GL_MODELVIEW) # Specify which matrix then do your matrix ops ... = glGetFloatv( GL_MODELVIEW_MATRIX ) # Retrieve the matrix back Gary Herron > > ----- Original Message ---- > From: Prashant Saxena <ani...@ya...> > To: Gary Herron <gh...@is...> > Sent: Tuesday, July 22, 2008 9:59:38 PM > Subject: Re: [PyOpenGL-Users] get Translation inside matrix stack > > I am sorry but I didn't get any success with your code. I tried this: > > glPushMatrix() > glTranslate(5,0,0) > glTranslate(10,0,0) > glTranslate(5,0,0) > # To get total increment of x axis(which is 5+10+5=20) > modelview = glGetFloatv( GL_MODELVIEW_MATRIX ) > print modelview > glPopMatrix() > > but I am getting this: > [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], > [0.0, 0.0, 0.0, 1.0]] > Which does,'t solve my problem. > > > ----- Original Message ---- > From: Gary Herron <gh...@is...> > Cc: pyo...@li... > Sent: Tuesday, July 22, 2008 8:48:24 PM > Subject: Re: [PyOpenGL-Users] get Translation inside matrix stack > > Shantytown Saxena wrote: > > > > glPushMatrix() > > glTranslate(5,0,0) > > glTranslate(10,0,0) > > glTranslate(5,0,0) > > # How do I get here total increment of x axis(which is 5+10+5=20) > > before I Pop up. > > glPopMatrix() > > All the transformations are recorded by OpenGL in a 4x4 matrix. > You can recover that matrix like this: > > buff = (ctypes.c_double*16)() > pyglet.gl <http://pyglet.gl.gl>.glGetDoublev(stack, buff) > > If you started with the identity and did no other transformations you'll > find the 20 in that 4x4 array. > > In either the [0,3] or [3,0] element. (I've forgotten which way Opengl > stores the array now.) > > Gary Herron > > > > > > ------------------------------------------------------------------------ > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > > Build the coolest Linux based applications with Moblin SDK & win > great prizes > > Grand prize is a trip for two to an Open Source event anywhere in > the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > <http://moblin-contest.org/redirect.php?banner_id=100&url=/> > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > PyOpenGL Homepage > > http://pyopengl.sourceforge.net > > _______________________________________________ > > PyOpenGL-Users mailing list > > PyO...@li... > <mailto:PyO...@li...> > > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > <http://moblin-contest.org/redirect.php?banner_id=100&url=/> > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > <mailto:PyO...@li...> > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ------------------------------------------------------------------------ > > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |