PDA

View Full Version : Selection in Orthographic mode



david_williams
12-30-2002, 01:49 PM
Hiya,
I have selection working in perspective mode, using the gluPickMatrix() function to generate the pick matrix. The relevant code is:

gluPickMatrix(x, viewport[3] - y, 2,2,viewport);
float aspect = static_cast<float>(width()) / static_cast<float>(height());
gluPerspective(45.0, aspect, 1.0, 100.0);

But what is the equivilent for Orthographic projections? With what do I replace gluPickMatrix()?

Thanks for the help!

Halcyon
01-01-2003, 08:26 PM
Hey i don't now much about selection. And i'm not sure if this is exactly what you are looking for but i hear the functions glProject and glUnproject getting thrown around a lot for selection.

david_williams
01-03-2003, 03:56 AM
They can be used for selection, but OpenGL also has a specific render mode for selection where it records which primatives end up in a specific area, which is what i'm trying to use. Anyone have any other ideas? Otherwise i might have to use glProject/unProject.

chxfryer
01-03-2003, 05:28 PM
Ortho is 2D. Can't u just use the mouse position?

Bob
01-04-2003, 04:36 AM
Orthographic projection is as much 3D as perspective projection. It just lacks perspective.

Selection with orthographic projection should not be any different from selection in perspective projection. It should be enough to replace gluPerspective with glOrtho instead. The selection mechanism in OpenGL is independent of type of projection.

david_williams
01-04-2003, 09:08 AM
Solved!

Yes it is the same, gluPickMatrix can be used in glOrtho mode. I was thrown by documentation refering to it defineing a 'frustrum' which I figured would be specific to 3D.

The problem was elsewhere, and it now works. Thanks guys!

01-05-2003, 12:36 PM
Originally posted by Bob:
Orthographic projection is as much 3D as perspective projection. It just lacks perspective.


3D - perspective = 2D Right?
Or are you talking about how the driver/card handels it; sending it through the same pipeline?

Bob
01-05-2003, 01:03 PM
With an orthographic projection matrix, you can still use the depth buffer to eliminate hidden objects, objects too far away are still clipped by the far clip plane, fogging will still fog the objects based on distance from the viewpoint, and so on. All objects have a depth, apart from left/right and up/down; three dimensions are present.

Orthographic projection are usually used to do 2D drawings, but that doesn't make orthographic projection itself 2D.