《基于MFC的OpenGL编程》Part 5 Transformations - Rotations, Translations and Scaling
2011-12-27 09:23
501 查看
Transformations - Translation, Rotation and Scaling
Translation is nothing but moving along an arbitrary axis. Rotation is spinning about an arbitrary axis. Scaling is increase or decrease in size along an arbitrary axis. One important point to remember is that OpenGL uses a right hand coordinate system where Z-ve goes into the Screen. An object said to be undergoing a transformation could be undergoing a translation, rotation and/or scaling. Understanding how different types of transformations work together is very important.
本文将对地球进行建模,让其围绕着太阳,此外它还会有月球伴随,而在下文中将会加入对鼠标和键盘的事件响应机制。
绘制代码
void CCY457OpenGLView::RenderScene ()
{//绘制函数
//Draw Sun
glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(1.0f,20,20);
//Draw Planet
glPushMatrix();
glTranslatef(-1.2f,-0.5f,-2.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(0.5f,20,20);
//Draw Moon
glPushMatrix();
glTranslatef(-1.2f,-0.5f,-2.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(0.05f,20,20);
glPopMatrix();
glPopMatrix();
}
作者:洞庭散人
出处:http://phinecos.cnblogs.com/
本博客遵从Creative Commons Attribution 3.0 License,若用于非商业目的,您可以自由转载,但请保留原作者信息和文章链接URL。
Translation is nothing but moving along an arbitrary axis. Rotation is spinning about an arbitrary axis. Scaling is increase or decrease in size along an arbitrary axis. One important point to remember is that OpenGL uses a right hand coordinate system where Z-ve goes into the Screen. An object said to be undergoing a transformation could be undergoing a translation, rotation and/or scaling. Understanding how different types of transformations work together is very important.
本文将对地球进行建模,让其围绕着太阳,此外它还会有月球伴随,而在下文中将会加入对鼠标和键盘的事件响应机制。
绘制代码
void CCY457OpenGLView::RenderScene ()
{//绘制函数
//Draw Sun
glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(1.0f,20,20);
//Draw Planet
glPushMatrix();
glTranslatef(-1.2f,-0.5f,-2.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(0.5f,20,20);
//Draw Moon
glPushMatrix();
glTranslatef(-1.2f,-0.5f,-2.0f);
glRotatef(6,1.0f,0.0f,0.0f);
glutWireSphere(0.05f,20,20);
glPopMatrix();
glPopMatrix();
}
作者:洞庭散人
出处:http://phinecos.cnblogs.com/
本博客遵从Creative Commons Attribution 3.0 License,若用于非商业目的,您可以自由转载,但请保留原作者信息和文章链接URL。
相关文章推荐
- 【转】《基于MFC的OpenGL编程》Part 5 Transformations - Rotations, Translations and Scaling
- 《基于MFC的OpenGL编程》Part 4 Transformations - Rotations, Translations and Scaling
- 《基于MFC的OpenGL编程》Part 5 Transformations - Rotations, Translations and Scaling
- 《基于MFC的OpenGL编程》Part 5 Transformations - Rotations, Translations and Scaling
- 《基于MFC的OpenGL编程》Part 13 Creating 2D and 3D Text
- 《基于MFC的OpenGL编程》Part 11 Blending, Antialiasing and Fog
- 《基于MFC的OpenGL编程》Part 12 Creating and Using Display Lists
- 【转】 《基于MFC的OpenGL编程》Part 6 Keyboard and Mouse Control
- 《基于MFC的OpenGL编程》Part 13 Creating 2D and 3D Text
- 《基于MFC的OpenGL编程》Part 10 Blending, Antialiasing and Fog
- 《基于MFC的OpenGL编程》Part 11 Blending, Antialiasing and Fog
- 《基于MFC的OpenGL编程》Part 12 Creating 2D and 3D Text
- 《基于MFC的OpenGL编程》Part 11 Blending, Antialiasing and Fog
- 【转】 《基于MFC的OpenGL编程》Part 11 Blending, Antialiasing and Fog
- 《基于MFC的OpenGL编程》Part 5 Keyboard and Mouse Control
- 《基于MFC的OpenGL编程》Part 11 Creating and Using Display Lists
- 《基于MFC的OpenGL编程》Part 6 Keyboard and Mouse Control
- 【转】 《基于MFC的OpenGL编程》Part 13 Creating 2D and 3D Text
- 《基于MFC的OpenGL编程》Part 12 Creating and Using Display Lists
- 【转】 《基于MFC的OpenGL编程》Part 12 Creating and Using Display Lists