ok, let’s say i have a point that is at the 4,10,6 position on the current matrix (untrasformed). This is the center of my cube.
glPush()
Do glRotated
some glTranslated
other few glRotated
glPop()
Now the cube is transformed, and my old matrix is restored.
if i want to draw a point, in the center of the transformed cube, with the untransformed matrix (the poped one), how can i do that? eheh I need to know where the vertex is at in the untransformed matrix. Is there any formula? Maybe i can calcul my vertex with each tranformation and use it after?
I don’t really know… so help will be gradly apreciated.
Before you call glPopMatrix I think you should make a call to glGetDoubleV to get the model view matrix. You can multiply the vertex you mentioned (4,10,6,1) with this matrix to get the new centre of your cube.
Why don’t you just simply calculate the center of your cube before transforming it and then draw it as a point using the same matrix you used to transform the cube?
I won’t laugh. It’s pure mathematics. You know, the matrix you get is two dimenstional. It consists of 4 rows and 4 columns. Each column is a single vertex. You multiply each column with the vertex. To multiply two vertices you use this formula(the dot product formula):
Dot Product = x1x2 + y1y2 + z1z2 +w1w2
So, if you multiply the matrix M, which consists of 4*4=16 double precision floating point numbers, with a vertex V1(X1,Y1,Z1,1) you get the vertex V2(X2,Y2,Z2,1), so that:
Gorg: i can’t do this. Because i am working with 2 matrix at a time.
Like: I have to draw a line, from the center of my tranformed cube, to a x,y,z coord in an untransofmed matrix. Is like having a cube in a room. I must draw a line from x1,y1,z1 within my tranformed cube, to x2,y2,z2 in my room.
So, i must manualy calculate something here. If i draw my line while my matrix is transformed, i’ll have to calculate the coord x2,y2,z2 in my room with the same technique.
If i decide to draw my line when my matrix is’nt tranformed, i must calculate the x1,y1,z1 for my transformed cube.
I means, in either way, i have a point to calculate manualy.