PDA

View Full Version : Depth Sorting

Theo
01-13-2001, 09:46 AM
Can someone PLEASE tell me how to find the coord (Vertex) that
can be used to calcuate my object's distance from the camera?

I know how to do depth sorting once I have an array of depths,
I know how to build the array of depths, find distances from
a point to another point, and every thing except for one step
that I have tried absolutely everything I can think of but all
have failed.

Its just one simple small little step but I can't work it out
because I don't know what OpenGL does inside.

I just want to find the coord (vertex) that can be used to
calculate the distance of any object to the camera.

Eg, if I transform all vertexes by +7 in the x direction, then
I need to use that in my 3d pythagoras function. The problem
comes from when I rotate. Then I'm totally and completely lost,
and I get incorrect visual results no matter what I try.

Can someone help please?

DFrey
01-13-2001, 12:09 PM
Again, Theo, OpenGL does not rotate or translate vertices as two seperate operations. When OpenGL transforms the vertex coordinates, it simply uses the current modelview matrix to transform the vertex into view-space. This by itself is just multiplying the (homogeneous) vertex by the modelview matrix. When you use commands like glRotate and glTranslate, OpenGL creates the appropriate rotation or translation matrix and multiplies it to the current matrix, and sets the current matrix to the results. When it is time for OpenGL to transform vertices into view-space, it doesn't do anything other than take the vertices and multiply them by the current modelview matrix. That's it. OpenGL does not rotate, and then translate vertices. It simply transforms them. You can do the exact same transform by getting the modelview matrix and multiplying by some homogeneous vector.

[This message has been edited by DFrey (edited 01-13-2001).]