Skip to main content
GameDev.net gamedev.net
🔒 Locked

2D mesh rotation

Started by mike4 Feb 25, 2012 at 12:49 PM 0 replies 950+ views
Original Post
mike4
mike4
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
Tsus
Tsus
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).
glTranslatef(-64, 0, -64);
Rotate around the y-axis.
glRotatef(angleInDegree, 0,1,0);
Move back to the original position.
glTranslate(64, 0, 64);

Okay… and since we are in OpenGL land, you actually have to do it in the reverse order. smile.png
glTranslate(64, 0, 64);
glRotatef(angleInDegree, 0,1,0);
glTranslatef(-64, 0, -64);


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

Cheers!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.