PDA

View Full Version : glRotate (calculating the roted vertex given the angle and original vertex)



02-28-2002, 07:26 AM
This probably seems stupid, but ive been trying for some days to figure this out.
I have a Polygon (whose points I know), I use glRotatef(Theta,1,0,0) to rotate it on screen. But now I need to determine if a mouse click falls within the rotated polygon - (I already have an algo wich tells me if the mouse click was in the polygon, but only if the polygon is not rotated) - also the polygon in question has z=0 at all vertex's... if anyone can help. Thnks!

Furrage
02-28-2002, 09:01 AM
Read this thread and see if it gives you some hints. http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/007555.html

02-28-2002, 10:24 PM
Thank you!
It seems to return valid results... however not in the coordinate system that im working in... Firstly, where should I call glGet for the matrix information (on click - or - where i'm doing the actuall drawing?)

03-01-2002, 12:01 AM
Also the Vertexes that I have are in GL coords ie canvas(width 32000 height 16000)
(From WMF file) when I give gluUnProject my mouseclick X,Y,0 it returns 2,... ; 2,... ; -1 (How do i translate what it gives me into correct coords) - I dont even know if these results are correct?!? PLease help!

Furrage
03-01-2002, 07:17 AM
glGet should be placed in your mouse click function. However, it's effectiveness depends on not performing any tranformations (glTranslate, glRotate, etc) after drawing any of the objects you want to select. glGet gets the current matrices and if transformations were performed after drawing, the matrices will be different from that used to draw.

Furrage
03-01-2002, 07:28 AM
I just saw your other post (not cool). In this case, you either need to use selection (chapter 13 of the redbook) or place your UnProject code between each transform and draw pair. In the case of the latter, you're going to have to repeat your drawing code in your mouse click function. You don't necessarily have to draw it to screen, but you will need to repeat all your transform and render code for Unproject to work properly.

03-03-2002, 05:57 AM
Thanks for all your help Furrage
, this UnProject thing is notworking for me...; This 'Red Book' that your talking about? Whats its full name or ISBN or something; Ill have to go buy it!

Thanks Again

thelamberto
03-05-2002, 03:52 AM
The Red Book is the OpenGL Programmer's Guide. Also there is the Blue Book the OpenGL Reference Manual. They are probably the best source of info (bible?) when you get stuck - they're always my first check http://www.opengl.org/discussion_boards/ubb/wink.gif

03-05-2002, 05:18 AM
The Red Book is good, but if you are a beginner I recommend the GameDev OpenGL Game Programming Guide - it's more user friendly if you find the red book too phasing at the start (it does start with a lot of hard stuff first)

03-05-2002, 11:28 PM
Do you know/have the ISBN no so I can get my local book store to order it for me? I live in South Africa, our book stores don't generally just have stock of these sorts of things - though they'll order them if asked (but I need the ISBN) Thanks again for all the help.

Furrage
03-06-2002, 05:22 AM
The redbook is online. So is the OpenGL Superbible (haven't used it but a lot of persons recomend it as well). Do a seach in the this forum. There are a number of posts giving it's location. Otherwise check google or yahoo or something.

You can also check out tutorials including nehe's webite (http://nehe.gamedev.net) . Again thi is highly recommended.