opengl_qt_draw3D

所属分类:OpenGL
开发工具:C/C++
文件大小:302KB
下载次数:222
上传日期:2012-08-24 15:48:03
上 传 者tornadomeet
说明:   四棱锥由5个面构成一个封闭的立体图,其中4个共顶点的侧面是三角形,底面是个四边形。如果我们要绘制一个3D的四棱锥只需要绘制这5个面即可,绘制的方法和前一篇文章OpenGL_Qt学习笔记之_03(平面图形的着色和旋转)的相同。只不过这里的顶点坐标是3维的,所以图像深度那一维不一定为0。因此我们可以事先计算好四棱锥各个顶点的坐标,这对学过立体几何的人来说应该是小case了。然后绘制每个面就可以。 注意,在opengl中绘制每个面时,所有面给出的顶点的顺序都要按照逆时针或者顺时针(我这里采用的是逆时针),这样才能保证所绘制出来的图像时正确的。 现在我们在paintGL中开始绘制四棱锥,如果按照NeHe的教程,它只是绘制了个金字塔,并没有底面,只有4个侧面,这里,我采用它的方法,代码如下:
(A closed perspective view of four-sided pyramid is constituted by 5 surface, wherein the side of vertex 4 is triangular, the bottom surface is a quadrangle. If we want to draw a 3D pyramid only need to draw the five faces can, the drawn and former article OpenGL_Qt study notes _03 (planar graph coloring and rotation). But here vertex coordinates of a three-dimensional, so the image depth that dimension is not necessarily 0. So we can be calculated in advance the good four-sided pyramid coordinates of each vertex should learn solid geometry, is a small case. Then you can draw each face. Opengl in draw each surface, all surface given vertex order must be in accordance with the counterclockwise or clockwise (I used counterclockwise), so as to ensure the drawn image. Now we start drawing in paintGL four pyramid NeHe tutorial, it just draws a pyramid and the bottom surface of only four sides, here, I adopt its methods, the code is as follows:)

文件列表:
OpenGL_Qt学习笔记之_04(3D图形的绘制和旋转).pdf (331815, 2012-08-24)
opengl_qt_nehe_04\glwidget.cpp (5080, 2012-08-24)
opengl_qt_nehe_04\glwidget.h (530, 2012-08-24)
opengl_qt_nehe_04\glwidget.ui (447, 2012-08-24)
opengl_qt_nehe_04\main.cpp (183, 2012-08-23)
opengl_qt_nehe_04\opengl_qt_nehe_04.pro (135, 2012-08-24)
opengl_qt_nehe_04\opengl_qt_nehe_04.pro.user (17666, 2012-08-24)
opengl_qt_nehe_04 (0, 2012-08-24)

近期下载者

相关文件


收藏者