PDA

View Full Version : glMap2f color adjusting to z value



01-13-2003, 09:22 AM
Hi,

well I have a 3d chart showing some FFT analysis using glEvalMesh2f.

How can I add color data to the surface referring to z values (sse Code). I tried GL_MAP2_INDEX and GL_MAP2_COLOR_4 but without success.

for better understanding I add my code here:

void CGLSample1View::FFT3()
{
int u, v;
float xS, yS;

GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat position[] = {0.0, 0.0, 2.0, 1.0};
GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0};
GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat mat_shininess[] = {100.0};

xS = -1.5; yS =-1.5;

for (u = 0; u < 30; u++) {
for (v = 0; v < 30; v++) {
if (v < 2) {
ctlpoints[u][v][0] = xS;
ctlpoints[u][v][1] = yS;
ctlpoints[u][v][2] = 0; }
else {
ctlpoints[u][v][0] = xS;
ctlpoints[u][v][1] = yS;
ctlpoints[u][v][2] = FFTHistory1[v*2 + u*60]/8; } //this are z Values

xS=xS + ((float)4/30);
}
yS = yS + ((float)4/30); xS = -1.5;
}

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_POSITION, position);

glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);

glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 30,
0, 1, 3*30, 30, &ctlpoints[0][0][0]);
glEnable(GL_MAP2_VERTEX_3);

// here I should add a color routine which adds color to the surface correlating to the Z values.
glMapGrid2f(40, 0.0, 1.0, 40, 0.0, 1.0);

glEnable(GL_AUTO_NORMAL);

glPushMatrix ();
glRotatef(-45, 1, 0, 0);
glRotatef(-30, 0, 0, 1);
glEvalMesh2(GL_LINE, 0, 40, 0, 40);
glPopMatrix ();
}

I somebody could help I would be very thankfull.

Greetings

Nik Schaefer