Fix a quadstrip front/back-face inconsistancy.
Only set front material colors to make it noticable if front/back-face determination is incorrect anywhere.
This commit is contained in:
@@ -441,8 +441,8 @@ DrawConnector(float length, float thickness,
|
|||||||
for (i = 0; i <= 36; i++) {
|
for (i = 0; i <= 36; i++) {
|
||||||
const int j = i % 36;
|
const int j = i % 36;
|
||||||
glNormal3f(normals[j][0], normals[j][1], 0);
|
glNormal3f(normals[j][0], normals[j][1], 0);
|
||||||
glVertex3f(points[j][0], points[j][1], z0);
|
|
||||||
glVertex3f(points[j][0], points[j][1], z1);
|
glVertex3f(points[j][0], points[j][1], z1);
|
||||||
|
glVertex3f(points[j][0], points[j][1], z0);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ DrawEngine(const Engine *eng, float crankAngle)
|
|||||||
glTranslatef(0, 0, -0.5 * crankLen);
|
glTranslatef(0, 0, -0.5 * crankLen);
|
||||||
|
|
||||||
/* crankshaft */
|
/* crankshaft */
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
|
||||||
glColor4fv(CrankshaftColor);
|
glColor4fv(CrankshaftColor);
|
||||||
DrawPositionedCrankshaft(eng, crankAngle);
|
DrawPositionedCrankshaft(eng, crankAngle);
|
||||||
|
|
||||||
@@ -760,12 +760,12 @@ DrawEngine(const Engine *eng, float crankAngle)
|
|||||||
rot += k * eng->V_Angle;
|
rot += k * eng->V_Angle;
|
||||||
|
|
||||||
/* piston */
|
/* piston */
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, PistonColor);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PistonColor);
|
||||||
glColor4fv(PistonColor);
|
glColor4fv(PistonColor);
|
||||||
DrawPositionedPiston(eng, rot);
|
DrawPositionedPiston(eng, rot);
|
||||||
|
|
||||||
/* connecting rod */
|
/* connecting rod */
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
|
||||||
glColor4fv(ConnRodColor);
|
glColor4fv(ConnRodColor);
|
||||||
DrawPositionedConnectingRod(eng, rot);
|
DrawPositionedConnectingRod(eng, rot);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
@@ -780,7 +780,7 @@ DrawEngine(const Engine *eng, float crankAngle)
|
|||||||
}
|
}
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, BlockColor);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlockColor);
|
||||||
glColor4fv(BlockColor);
|
glColor4fv(BlockColor);
|
||||||
if (eng->CrankList)
|
if (eng->CrankList)
|
||||||
glCallList(eng->BlockList);
|
glCallList(eng->BlockList);
|
||||||
@@ -1250,6 +1250,7 @@ Init(void)
|
|||||||
{
|
{
|
||||||
const GLfloat lightColor[4] = { 0.7, 0.7, 0.7, 1.0 };
|
const GLfloat lightColor[4] = { 0.7, 0.7, 0.7, 1.0 };
|
||||||
const GLfloat specular[4] = { 0.8, 0.8, 0.8, 1.0 };
|
const GLfloat specular[4] = { 0.8, 0.8, 0.8, 1.0 };
|
||||||
|
const GLfloat backColor[4] = { 1, 1, 0, 0 };
|
||||||
|
|
||||||
Q = gluNewQuadric();
|
Q = gluNewQuadric();
|
||||||
gluQuadricNormals(Q, GLU_SMOOTH);
|
gluQuadricNormals(Q, GLU_SMOOTH);
|
||||||
@@ -1261,10 +1262,14 @@ Init(void)
|
|||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
|
||||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 40);
|
glMaterialf(GL_FRONT, GL_SHININESS, 40);
|
||||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
|
|
||||||
|
glMaterialfv(GL_BACK, GL_DIFFUSE, backColor);
|
||||||
|
#if 0
|
||||||
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
|
||||||
|
#endif
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
InitViewInfo(&View);
|
InitViewInfo(&View);
|
||||||
|
Reference in New Issue
Block a user