private void setColor(double Z)
{
float r, g, b;
if (Z > colorParam1)
{
r = (float)((Z - colorParam1) / colorParam2);
b = 0;
}
else
{
r = 0;
b = (float)((colorParam1 - Z) / colorParam2);
}
g = 1 - (float)((Math.Abs(colorParam1 - Z)) / colorParam2);
GL.glColor3f(r, g, b);
return;
}
private void draw_Points(float[] X, float[] Y, float[] Z)
{
GL.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
GL.glClearDepth(1.0);
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluPerspective(90.0, 1.0, 1.0, 6 * eyez); // 投影矩阵( y 45度,纵横比1:1,near截平面1,far截平面10000.)
//GL.glOrtho(vertx[0].Min(), vertx[0].Max(), vertx[1].Min(), vertx[1].Max(), 1.0f, 6 * eyez);//dtmZ.Min(), dtmZ.Max());
GL.glMatrixMode(GL.GL_MODELVIEW); // 模型矩阵
GL.glLoadIdentity();
//GL.glDrawBuffer(GL.GL_BACK); // Specifies up to four color buffers to be drawn into with the following acceptable symbolic constants.
GL.glPushMatrix();
GL.gluLookAt(eyex, eyey, eyez, centerx, centery, 0.0f, 0.0f, 1.0f, 0.0f); //defines a viewing transformation
GL.glRotatef(roll_x, 1.0f, 0.0f, 0.0f);//
GL.glRotatef(yaw_z, 0.0f, 0.0f, 1.0f);//
GL.glRotatef(pitch_y, 0.0f, 1.0f, 0.0f);//
GL.glScalef(m_Scalex, m_Scaley, m_Scalez);//缩放
for (int i = 0; i < row; i += LOD_scale)
{
GL.glBegin(GL.GL_POINTS);
for (int j = 0; j < column; j += LOD_scale)
{
if (Z[i * column + j] == -frm3d.Zc)
continue;
setColor(Z[i * column + j]);
GL.glVertex3f(X[i * column + j], Y[i * column + j], Z[i * column + j]);
}
GL.glEnd();
GL.glFlush();
}
/*
* glFlush:将GL命令队列中的命令发送给显卡并清空命令队列,发送完立即返回;
* glFinish:将GL命令队列中的命令发送给显卡并清空命令队列,显卡完成这些命令(也就是画完了)后返回。
*/
GL.glPopMatrix();
}