Jump to content
  • Advertisement
Sign in to follow this  
mike4

2D mesh rotation

This topic is 2480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!