Main Page | Report this Page
Computers Forum Index  »  Computer - Graphics - API (Opengl)  »  extract obserwator position from modelview matrix...
Page 1 of 1    

extract obserwator position from modelview matrix...

Author Message
Michal...
Posted: Mon Aug 31, 2009 8:03 pm
Guest
How could i extract obserwator position from modelview matrix?
I tried to do it like this:
double m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, m)
double x = m[12];
double y = m[13];
double z = m[14];

but it looks like it is not observator position.

--
 
fungus...
Posted: Mon Aug 31, 2009 8:03 pm
Guest
On Aug 31, 6:03 pm, Michal <natural-born-kil... at (no spam) dontmailme.com> wrote:
Quote:
How could i extract obserwator position from modelview matrix?
I tried to do it like this:
double m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, m)
double x = m[12];
double y = m[13];
double z = m[14];

but it looks like it is not observator position.


You must invert the matrix first.



--
<\___/>
/ O O \
\_____/ FTB.

http://www.topaz3d.com/ - New 3D editor for real time simulation
 
fungus...
Posted: Mon Aug 31, 2009 9:51 pm
Guest
On Aug 31, 9:43 pm, Michal <natural-born-kil... at (no spam) dontmailme.com> wrote:
Quote:

You must invert the matrix first.

does this matrix has some properties that could help me do it or do i
have to use generic methods?

If there's no scale factor in the matrix then this
should work:

x = -(m[12]*m[0] + m[13]*m[1] + m[14]*m[2]);
y = -(m[12]*m[4] + m[13]*m[5] + m[14]*m[6]);
z = -(m[12]*m[8] + m[13]*m[9] + m[14]*m[10]);

If there's a scale factor you have to use generic methods.


--
<\___/>
/ O O \
\_____/ FTB.

http://www.topaz3d.com/ - New 3D editor for real time simulation
 
Michal...
Posted: Mon Aug 31, 2009 11:43 pm
Guest
On Mon, 31 Aug 2009 12:29:48 -0700 (PDT)
fungus <openglMYSOCKS at (no spam) artlum.com> wrote:

Quote:
On Aug 31, 6:03 pm, Michal <natural-born-kil... at (no spam) dontmailme.com> wrote:
How could i extract obserwator position from modelview matrix?
I tried to do it like this:
double m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, m)
double x = m[12];
double y = m[13];
double z = m[14];

but it looks like it is not observator position.


You must invert the matrix first.

does this matrix has some properties that could help me do it or do i
have to use generic methods?
 
Michal...
Posted: Tue Sep 01, 2009 12:50 am
Guest
Quote:

You must invert the matrix first.

or maybe there is some easier way to extract this position? Maybe glu
library has this functionality?
--
 
Wojciech \"Spook\" Sura...
Posted: Tue Sep 01, 2009 9:31 am
Guest
Michal wrote:
Quote:
How could i extract obserwator position from modelview matrix?
I tried to do it like this:
double m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, m)
double x = m[12];
double y = m[13];
double z = m[14];

but it looks like it is not observator position.

Vector (0,0,0,1) multiplied by the modelview matrix sholud return inverse of
observer position (-Vector).

Best regards -- Spook.
 
 
Page 1 of 1    
All times are GMT
The time now is Wed Dec 02, 2009 2:48 am