stavbodik

08-31-2015, 02:43 PM

Hello , I have read about matrix translations and understood what is the purpose of Modelview/Projection matrix's.

The thing that I cant understand is how same Modelview can handle information about each object move?

When we use at the beginning of rendering glLoadIdentity (resetting all) and right after that glTranslatef yeah we get matrix which have information about the first moved object, but then whene we move another object the matrix get multiplyed again and again , so how is it works ?

I came to this question after having next problem :

How do I get vertices coordinates after rotate/translate my mesh.

I understood that in order to achieve the new coordinates we must apply the same translations that openGL did to Modelview when used glTranslatef to our mesh vertices , and this is done by multiplying our old vertices * new Modelview matrix .

But who said that this current Modelview matrix that we multiply has only information about the last translate ?

Here is what am I doing and unfortunately I get wrong result :

1. I am setting initial position of my mesh which represent wall at position from (x,height ,z) to (x,height ,z)

From Mesh class :

2073

2. Then inside onDrawFrame I initiate my Mesh and setting position with the function mentioned before + using glTranslatef to move the center of the mesh .

2077

This move my mesh center to point 2.5 , 0 , 2.5

After this translation I am trying to retrieve the new vertices coordinates which should be :

0,0,2.5

5,0,2.5

0,5,2.5

5,5,2.5

To retrieve it I am using next method :

2076

*Note , I know that there is multiplyMM function for multiply 4*4 matrix i gave it a try 2 and got same results .

Unfortunately I get results which I did not expected , what am I doing wrong ,please may some help ?

The thing that I cant understand is how same Modelview can handle information about each object move?

When we use at the beginning of rendering glLoadIdentity (resetting all) and right after that glTranslatef yeah we get matrix which have information about the first moved object, but then whene we move another object the matrix get multiplyed again and again , so how is it works ?

I came to this question after having next problem :

How do I get vertices coordinates after rotate/translate my mesh.

I understood that in order to achieve the new coordinates we must apply the same translations that openGL did to Modelview when used glTranslatef to our mesh vertices , and this is done by multiplying our old vertices * new Modelview matrix .

But who said that this current Modelview matrix that we multiply has only information about the last translate ?

Here is what am I doing and unfortunately I get wrong result :

1. I am setting initial position of my mesh which represent wall at position from (x,height ,z) to (x,height ,z)

From Mesh class :

2073

2. Then inside onDrawFrame I initiate my Mesh and setting position with the function mentioned before + using glTranslatef to move the center of the mesh .

2077

This move my mesh center to point 2.5 , 0 , 2.5

After this translation I am trying to retrieve the new vertices coordinates which should be :

0,0,2.5

5,0,2.5

0,5,2.5

5,5,2.5

To retrieve it I am using next method :

2076

*Note , I know that there is multiplyMM function for multiply 4*4 matrix i gave it a try 2 and got same results .

Unfortunately I get results which I did not expected , what am I doing wrong ,please may some help ?