TheBlob
12-27-2001, 01:52 AM
Hi!
My code renders a very beautiful landscape via a heightfield. Itīs done with
GL_TRIANGLE_STRIP. Works fine except the f**** lighting. And canīt get the normals to work properly. Is there anything to consider if Iīm using GL_TRIANGLE_STRIP instead of GL_TRIANGLE ??
for(int y=int(y_start); y<int(y_end)-1; y++)
{
glBegin(GL_TRIANGLE_STRIP);
for(int x=int(x_start); x<int(x_end)-1; x++)
{
//FIRST TRIANGLE......
glColor3f(heightfield[(y*field_dim)+x].color[0],heightfield[(y*field_dim)+x].color[1],heightfield[(y*field_dim)+x].color[2]);
glNormal3f(heightfield[(y*field_dim)+x].normal.x, heightfield[(y*field_dim)+x].normal.y, heightfield[(y*field_dim)+x].normal.z);
glTexCoord2f(heightfield[(y*field_dim)+x].texture_coo.x,heightfield[(y*field_dim)+x].texture_coo.y);
glVertex3f(heightfield[(y*field_dim)+x].point.x,heightfield[(y*field_dim)+x].point.y,heightfield[(y*field_dim)+x].point.z);
//SECOND TRIANGLE......
glColor3f(heightfield[((y+1)*field_dim)+x+1].color[0],heightfield[y+1)*field_dim)+x+1].color[1],heightfield[y+1)*field_dim)+x+1].color[2]);
glNormal3f(heightfield[y+1)*field_dim)+x+1].normal.x, heightfield[y+1)*field_dim)+x+1].normal.y, heightfield[y+1)*field_dim)+x+1].normal.z);
glTexCoord2f(heightfield[y+1)*field_dim)+x+1].texture_coo.x,heightfield[y+1)*field_dim)+x+1].texture_coo.y);
glVertex3f(heightfield[y+1)*field_dim)+x+1].point.x,heightfield[y+1)*field_dim)+x+1].point.y,heightfield[y+1)*field_dim)+x+1].point.z);
}
glEnd();
}
I donīt know how to set the normals there???
[This message has been edited by TheBlob (edited 12-27-2001).]
My code renders a very beautiful landscape via a heightfield. Itīs done with
GL_TRIANGLE_STRIP. Works fine except the f**** lighting. And canīt get the normals to work properly. Is there anything to consider if Iīm using GL_TRIANGLE_STRIP instead of GL_TRIANGLE ??
for(int y=int(y_start); y<int(y_end)-1; y++)
{
glBegin(GL_TRIANGLE_STRIP);
for(int x=int(x_start); x<int(x_end)-1; x++)
{
//FIRST TRIANGLE......
glColor3f(heightfield[(y*field_dim)+x].color[0],heightfield[(y*field_dim)+x].color[1],heightfield[(y*field_dim)+x].color[2]);
glNormal3f(heightfield[(y*field_dim)+x].normal.x, heightfield[(y*field_dim)+x].normal.y, heightfield[(y*field_dim)+x].normal.z);
glTexCoord2f(heightfield[(y*field_dim)+x].texture_coo.x,heightfield[(y*field_dim)+x].texture_coo.y);
glVertex3f(heightfield[(y*field_dim)+x].point.x,heightfield[(y*field_dim)+x].point.y,heightfield[(y*field_dim)+x].point.z);
//SECOND TRIANGLE......
glColor3f(heightfield[((y+1)*field_dim)+x+1].color[0],heightfield[y+1)*field_dim)+x+1].color[1],heightfield[y+1)*field_dim)+x+1].color[2]);
glNormal3f(heightfield[y+1)*field_dim)+x+1].normal.x, heightfield[y+1)*field_dim)+x+1].normal.y, heightfield[y+1)*field_dim)+x+1].normal.z);
glTexCoord2f(heightfield[y+1)*field_dim)+x+1].texture_coo.x,heightfield[y+1)*field_dim)+x+1].texture_coo.y);
glVertex3f(heightfield[y+1)*field_dim)+x+1].point.x,heightfield[y+1)*field_dim)+x+1].point.y,heightfield[y+1)*field_dim)+x+1].point.z);
}
glEnd();
}
I donīt know how to set the normals there???
[This message has been edited by TheBlob (edited 12-27-2001).]