01-22-2003, 04:31 AM

I was wondering what kind of mathematical operation does opengl to convert a 3d point to a 2d screen point. Any doc where i can read about this?

View Full Version : How does OpenGL project a 3D point to screen?

01-22-2003, 04:31 AM

I was wondering what kind of mathematical operation does opengl to convert a 3d point to a 2d screen point. Any doc where i can read about this?

nexusone

01-22-2003, 07:32 AM

It has to do with projection of vector's from 3D space into the 2D screen, a very complex set of mathematical functions.

Even get more complex when you add lighting and textures.

Do a google search on rendering, which is what it is called with the 3D scene is projected on to the 2D screen.

Originally posted by DogAd:

I was wondering what kind of mathematical operation does opengl to convert a 3d point to a 2d screen point. Any doc where i can read about this?

Even get more complex when you add lighting and textures.

Do a google search on rendering, which is what it is called with the 3D scene is projected on to the 2D screen.

Originally posted by DogAd:

I was wondering what kind of mathematical operation does opengl to convert a 3d point to a 2d screen point. Any doc where i can read about this?

zen

01-22-2003, 07:55 AM

Complex?I thought it was:multiply by modelview,clip,multiply by projection and divide by w.Maybe clipping comes last,not sure.

01-23-2003, 12:39 AM

I have looked in google and i have found some documents about projecting 3D points, but none of them specifically explains what does opengl do...

Deiussum

01-23-2003, 04:49 AM

If you take a look at the OpenGL specification (http://www.opengl.org/developers/documentation/specs.html) , you can find out the formula it uses for just about everything. The formula you are looking for goes something like so...

From the spec with a few minor edits to account for no graphics

if a vertex in object coordinates is given by v(x0, y0, z0, w0) and the model-view matrix is M, then the vertex's eye coordinates are found as

eye(xe, ye, ze, we) = M*v

Similarly, if P is the projection matrix, then the vertex's clip coordinates are

clip(xc, yc, zc, wc) = P*eye

The vertex's normalized device coordinates are then

dev(xd, yd, zd) = (xc/wc, yc/wc, zc/wc)

The viewport transformation is determined by the viewport's width and height in pixels, px and py, respectively, and its center (ox, oy)(also in pixels)."

The vertex's window coordinates (xw, yw, zw) are given by.

xw = (px/2)xd + ox

yw = (py/2)yd + oy

zw = [(f-n)/2]zd + (n+f)/2

The factor and offset applied to zd encoded by n and f are set using

void DepthRange(clampd n, clampd f);

[This message has been edited by Deiussum (edited 01-23-2003).]

From the spec with a few minor edits to account for no graphics

if a vertex in object coordinates is given by v(x0, y0, z0, w0) and the model-view matrix is M, then the vertex's eye coordinates are found as

eye(xe, ye, ze, we) = M*v

Similarly, if P is the projection matrix, then the vertex's clip coordinates are

clip(xc, yc, zc, wc) = P*eye

The vertex's normalized device coordinates are then

dev(xd, yd, zd) = (xc/wc, yc/wc, zc/wc)

The viewport transformation is determined by the viewport's width and height in pixels, px and py, respectively, and its center (ox, oy)(also in pixels)."

The vertex's window coordinates (xw, yw, zw) are given by.

xw = (px/2)xd + ox

yw = (py/2)yd + oy

zw = [(f-n)/2]zd + (n+f)/2

The factor and offset applied to zd encoded by n and f are set using

void DepthRange(clampd n, clampd f);

[This message has been edited by Deiussum (edited 01-23-2003).]

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.