Scott
Scott

Reputation:

OpenGL Projection Matrices

I have a question on taking a viewer and their projection plane and how exactly to calculate the projected point that should be created.

EX. Viewer at the origin, looking in the negative Z direction. Projection plane at z = -2. Point (-6,1,-4).

I have seen some websites talking about using similar triangles and some that have a matrix to multiply it by. The problem for me is I don't know how to set either one up.

I would guess that my viewer's point seeing as it is at origin (0, 0, 0, 1). When I search for the perspective projection matrix I find a site that sets up a matrix like this.

1 0 0 0
0 1 0 0
0 0 0 0
0 0 1 0

But seeing as my viewer's point as far as I can tell is at (0, 0, 0, 1) then the projection makes no sense as to how it factors into the equation. That matrix also needs to be adjusted as according to the formula to set it up on this site:
http://www.cs.nps.navy.mil/people/faculty/capps/iap/class2/viewing/projection.html

I just need a little help in figuring this out and what we discussed in class was only using similar triangles which does not make sense to me...

Upvotes: 1

Views: 4108

Answers (2)

heeen
heeen

Reputation: 4886

The viewer's position is usually not handled through the projection matrix, but the modelview matrix. The projection matrix only handles the transformation from eye-space to clip-space.

Camera transformation is achieved by applying the camera's inverse transformation as the first Matrix on the modelview stack.

Advanced graphics programming using openGL

OpenGL Transformation

Upvotes: 3

unwind
unwind

Reputation: 400069

Consider reading out OpenGL's matrixes, using glGet...() functions, and running the vertex through the relevant matrices yourself. First read up on the details of the transformation pipeline of course, so you know how to apply the matrices, ordering matters a great deal as always.

Upvotes: 0

Related Questions