Jump to content



2D mesh rotation

  • You cannot reply to this topic
1 reply to this topic

#1 mike4   Members   -  Reputation: 76

Like
0Likes
Like

Posted 25 February 2012 - 06:49 AM

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

Ad:

#2 Tsus   Members   -  Reputation: 296

Like
0Likes
Like

Posted 27 February 2012 - 10:39 AM

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. Posted Image
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!
Acagamics e.V. – IGDA Student Game Development Club (University of Magdeburg, Germany)






We are working on generating results for this topic
PARTNERS