是否可以使用像素值作为Z坐标在3D中渲染灰度图像? 我应该从哪里开始?在OpenGL中绘制点的命令是什么?确保此点可见的基本设置是什么?
我正在使用Qt,并能够运行和运行Qt的OpenGL示例。
答案 0 :(得分:1)
好的,我已经发现了如何使用Qt实现它并实现了一个小型演示:
https://github.com/vheinitz/Cell3DViewerDemo
要理解的主要内容似乎是如何创建顶点列表:
glNewList(_vertexes, GL_COMPILE);
GLenum mode = GL_TRIANGLES;//GL_TRIANGLES GL_POINTS GL_LINES GL_POINTS GL_TRIANGLE_STRIP GL_QUADS
glBegin(mode);
for (int y = 0; y < height - 2; y++) {
int x = 0;
float gy = y*sy -yo;
float gy1 = (y+1)*sy-yo;
for (x; x < width-2; x++) {
float z = qGray(qimg.pixel(x, y));
float gx = x*sx -xo;
float gx1 = (x+1)*sx -xo;
float gz = qGray(qimg.pixel(x, y))*sz -zo;
glColor3f(0, gz, 0);
glVertex3f(gx, gz, gy);
gz = qGray(qimg.pixel(x, y+1))*sz -zo;
glColor3f(0, gz, 0);
glVertex3f(gx, gz, gy1);
gz = qGray(qimg.pixel(x+1, y))*sz -zo;
glColor3f(0, gz, 0);
glVertex3f(gx1, gz, gy);
glVertex3f(gx1, gz, gy);
gz = qGray(qimg.pixel(x, y+1))*sz -zo;
glColor3f(0, gz, 0);
glVertex3f(gx, gz, gy1);
gz = qGray(qimg.pixel(x+1, y+1))*sz -zo;
glColor3f(0, gz, 0);
glVertex3f(gx1, gz, gy1);
}
}
glEnd();
glEndList();