Sign in to follow this  
mike4

2D mesh rotation

Recommended Posts

Hi
I do:
for x < 128
for z < 128
returns a height map (y).
now I'd want to rotate (opengl glpoints glvertex2f) that with a given angle around the centre.
Any ideas/help?
Many thanks
Michael

Share this post


Link to post
Share on other sites
Hi!

Build the mesh exactly the way you have, but before the rendering of the mesh do:

Move the center of height map to (0,0,0).
[CODE]glTranslatef(-64, 0, -64);[/CODE]
Rotate around the y-axis.
[CODE]glRotatef(angleInDegree, 0,1,0);[/CODE]
Move back to the original position.
[CODE]glTranslate(64, 0, 64);[/CODE]

Okay… and since we are in OpenGL land, you actually have to do it in the reverse order. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[CODE]glTranslate(64, 0, 64);
glRotatef(angleInDegree, 0,1,0);
glTranslatef(-64, 0, -64);[/CODE]

(The matrices are pushed on a stack. What came last is executed first.)

Cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this