PDA

View Full Version : position of vertices after rotation



Madcoretom
12-20-2007, 10:16 PM
Hey, i'm converting one of my projects to opengl from a crappy graphics library, adn thought i could take advantage of opengl's rotation rather than calculating it myself like i had to.

basically i have a few vertices (2000) that i would like to rotate in 3d space (without perspective) (which works) but i'd like to be able to know the '2d coordinates i guess' of where they appear on the screen, so i can find the closest vertex to the cursor and select it

i hope that makes sense without having to explain too much

cheers

-NiCo-
12-21-2007, 01:37 AM
Have a look at chapter 4.2 of the GLU (http://www.opengl.org/documentation/specs/glu/glu1_3.pdf) manual.

Basically, the project function multiplies the projection matrix, the modelview matrix and the 3D vertex (in that order) which return the screen coordinates in the range [-1,1]x[-1,1]. These are then scaled and translated to fit the viewport.

N.

Madcoretom
12-21-2007, 06:57 AM
wow, quick answer, and thanks. i was trying to see how far i could go without GLUT, only as far as asteroids and pong i suppose.

thanks

-NiCo-
12-21-2007, 07:27 AM
Indeed, glut only creates an opengl context/window with event handlers so that you can control what happens on keyboard input, window reshape, mouse movement, idle time,etc.
The limited collection of geometric primitives such as solidSphere are just extras, mainly used in tutorials on how to use glut.

N.

plasmonster
12-21-2007, 08:50 AM
Yes, think of GLUT as sort of the "PDF" of OpenGL. It's a great way to share ideas, without getting bogged down in gory boilerplate OS/GUI details (eeek!).