I used the following and would expect the objects in the if or else statements to appear to have the same colour, however it seems that one object's front face appear brighter than the other even though lighting conditions and colour are kept the same..

glColor3ub(242,134,60);

if(m_aniso==TRUE){

aniso(); //draw 3d polygon to left of y //y axis

glRotatef(180,0.0f,1.0f,0.0f);

aniso();} //draw mirror image

else{shape();} //draw a rect

Just a guess, have you double-checked that the normals are consistant across the 2 objects ?

the 2 objects are different in shape, but the front face both have the same normal pointing out along z-axis, and have same "length" along z-axis also, so i not sure where is the problem

Originally posted by coda:

the 2 objects are different in shape, but the front face both have the same normal pointing out along z-axis, and have same "length" along z-axis also, so i not sure where is the problem

I am not sure if I understand you but you are rotating around 180 degrees so the plane normal would surely be not the same.

I am not even sure if you use normals, lighting and materials since your example doesnt show any of them.

Perhaps you can explain things more detailed?

okie this is wat i did:

void CMainDialog::shape()

{

//normals for 6 surfaces of cube

GLfloat n[6][3]={{-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},{0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}};

//vertex indices for 6 faces of cube

GLint faces[6][4]={{0, 1, 2, 3},

{3, 2, 6, 7}, {7, 6, 5, 4},{4, 5, 1, 0},

{5, 6, 2, 1}, {7, 4, 0, 3} };

//coordinates of vertices

v[0][0] = v[1][0] = v[2][0] = v[3][0] = x;

v[4][0] = v[5][0] = v[6][0] = v[7][0] = -x;

v[0][1] = v[1][1] = v[4][1] = v[5][1] = -y;

v[2][1] = v[3][1] = v[6][1] = v[7][1] = y;

v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1;

v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;

int i=0;

for (i = 0; i < 6; i++) {

glBegin(GL_QUADS);

glNormal3fv(&n[i][0]);

glVertex3fv(&v[faces[i][0]][0]);

glVertex3fv(&v[faces[i][1]][0]);

glVertex3fv(&v[faces[i][2]][0]);

glVertex3fv(&v[faces[i][3]][0]);

glEnd();}

}

void CMainDialog::aniso()

{

glBegin(GL_POLYGON);

glNormal3f( 0.0f, 0.0f, 1.0f); glVertex3f(-w, y, 1.0f); glVertex3f(-x, y, 1.0f); glVertex3f(-x,-y, 1.0f); glVertex3f(0,-y, 1.0f); glVertex3f(0,y-(1.414*w),1.0f);

glEnd();

glBegin(GL_POLYGON);

glNormal3f( 0.0f, 0.0f,-1.0f);

glVertex3f(-x,y,-1.0f); glVertex3f(-w,y,-1.0f); glVertex3f(0,y-(1.414*w),-1.0f); glVertex3f(0,-y,-1.0f); glVertex3f(-x,-y,-1.0f);

glEnd();

glBegin(GL_QUADS);

glNormal3f( 0.0f, 1.0f, 0.0f);

glVertex3f(-w, y,-1.0f); glVertex3f(-x, y,-1.0f); glVertex3f(-x, y, 1.0f); glVertex3f(-w, y, 1.0f);

glNormal3f( 0.0f,-1.0f, 0.0f);

glVertex3f( 0,-y, 1.0f); glVertex3f(-x,-y, 1.0f); glVertex3f(-x,-y,-1.0f); glVertex3f( 0,-y,-1.0f);

glNormal3f(-1.0f, 0.0f, 0.0f);

glVertex3f(-x, y, 1.0f); glVertex3f(-x, y,-1.0f); glVertex3f(-x,-y,-1.0f); glVertex3f(-x,-y, 1.0f);

glNormal3f( 1.0f, 0.0f, 0.0f);

glVertex3f( 0, y-(1.414*w),-1.0f); glVertex3f( 0, y-(1.414*w), 1.0f);

glVertex3f( 0,-y, 1.0f); glVertex3f( 0,-y,-1.0f);

glNormal3f( 0.816f, 0.577f, 0.0f); glVertex3f( -w, y,-1.0f); glVertex3f( -w, y, 1.0f); glVertex3f( 0,y-(1.414*w), 1.0f); glVertex3f( 0,y-(1.414*w),-1.0f); glEnd();

}

Overmind

01-07-2004, 05:06 AM

I guess you are using positional lights, so when the polygon is at a different position it will have a slightly different color because the object->light vector will be different.

For example: In your shape() function there is a face in the z=-1 plane with the normal (0,0,1). In your aniso() function there is a face having the same normal but it is at the z=1 plane. These two faces would end up not having the same color despite identical normals because of a different position relative to the light source.

Btw.: Is it intentional that the normals of your cube are facing inwards?

I hope that helps

Overmind

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.