Transformations pipeline

I want to project a point onto device coordinates (screen). I thought I would olny have to apply the current modelview matrix and then the current projection matrix to get the normalized device coordinates (ranging from <-1,-1,-1> to <1,1,1> ), but I end up with weird result… am I missing something?

Hmm, what are your results?
Did you multiply from the left?
v’ = Projection * Modelview * v

Maybe this helps: The matrices are in the Redbook: http://heron.cc.ukans.edu/ebt-bin/nph-d …lhtml;pt=7109#X

And there is a helper function called gluProject which does exactly what you want.

[This message has been edited by Relic (edited 07-27-2000).]

Yes, I apply the transformations in the correct order.

The thing is that the transformed coordinates I get, looks like they have not been ‘applied perspective to’. Like this: If I run a coordinate a certain distance down the viewing axis through this transformations, it yields result that are furter out towards the edge of the screen than it’s supposed to be, just like if no perspective was applied (orthogonal projection).

The matrices are correct, since OpenGL renders correct frames with them.

Interesting. Ideas which come to my mind, no offense meant.

What do you think is “going down the viewing axis”?
Are you aware that the coordinates in the world are right handed and after the projection left handed?

When did you grab the modelview and projection matrices? Right from the spot where your drawing occurs?

Have you analyzed the contents of the matrices for correctness?

Does gluProject work?

Ah, I think I realized my mistake. When applying the projection matrix, I must use the homogenous coordinate <x, y, z, 1> to get the w value to divide the transformed x’, y’ and z’ coordinates with. Or am I wrong in this as well?

But yes, I’m aware of the ‘handedness’ of OpenGL And yes, I grab the matrices ‘on spot’ where the drawing occurs. But I will try this new idea I got.

[This message has been edited by Lord Chaos (edited 07-27-2000).]

Yes, w = 1.
So translation hasn’t worked either, I suppose.
Yeah, some things end very simple.

w should be -z after projection transformation, which is why my points appeard to be orthogonally projected, since I didn’t apply perspective (dividing by this w = -z).