diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-12-02 18:25:10 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-12-02 18:25:10 +0100 |
commit | 833d94c60092058258539ee39fbb6392515c5443 (patch) | |
tree | b25af987b864f92439ef8b28c984dae576875643 | |
parent | 99b2e305f2769c6d22de7600c193036cb00db44a (diff) | |
download | 2iv60-robots-833d94c60092058258539ee39fbb6392515c5443.tar.gz |
Fix material colors, increase precision for spheres
-rw-r--r-- | src/Robot.java | 12 | ||||
-rw-r--r-- | src/RobotRace.java | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/Robot.java b/src/Robot.java index bd99a0b..7d69460 100644 --- a/src/Robot.java +++ b/src/Robot.java @@ -67,7 +67,7 @@ class Robot extends BetterBase { gl.glTranslatef(0, 0, torsoHeight / 2 + legLength); // These materials control the reflected light - gl.glMaterialfv(GL_FRONT, GL_DIFFUSE, material.diffuse, 0); + gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, material.diffuse, 0); gl.glMaterialfv(GL_FRONT, GL_SPECULAR, material.specular, 0); gl.glTranslatef(0, 0, footHeight); @@ -142,7 +142,7 @@ class Robot extends BetterBase { */ private void drawJoint() { if (asStickFigure) { - glut.glutSolidSphere(boneSize * 1.5, 10, 10); + glut.glutSolidSphere(boneSize * 1.5, 16, 16); } } @@ -181,10 +181,10 @@ class Robot extends BetterBase { setColor(Colors.BLUEISH); // Set the drawing color and draw right shoulder - glut.glutSolidSphere(shoulderRadius, 10, 10); + glut.glutSolidSphere(shoulderRadius, 32, 32); // left shoulder gl.glTranslatef(-2 * shoulder_x, 0, 0); - glut.glutSolidSphere(shoulderRadius, 10, 10); + glut.glutSolidSphere(shoulderRadius, 32, 32); // restore position gl.glPopMatrix(); @@ -258,7 +258,7 @@ class Robot extends BetterBase { // Give me a big hand! setColor(Colors.DIRTY_BLUE); gl.glTranslatef(0f, 0f, -armLength / 2); - glut.glutSolidSphere(armWidth * 1.25f, 10, 10); + glut.glutSolidSphere(armWidth * 1.25f, 32, 32); } gl.glPopMatrix(); @@ -281,7 +281,7 @@ class Robot extends BetterBase { // Set color and draw head setColor(asStickFigure ? boneColor : Colors.PALE_TURQOISE); - glut.glutSolidSphere(headRadius, 10, 10); + glut.glutSolidSphere(headRadius, 32, 32); // Pop so we are at the origin again gl.glPopMatrix(); diff --git a/src/RobotRace.java b/src/RobotRace.java index bb47b09..9d51498 100644 --- a/src/RobotRace.java +++ b/src/RobotRace.java @@ -178,9 +178,6 @@ public class RobotRace extends Base { gl.glEnable(GL_LIGHT0); //gl.glEnable(GL_LIGHTING); - // blend the light with the material colors - gl.glEnable(GL_COLOR_MATERIAL); - // necessary because normals are improperly scaled gl.glEnable(GL_NORMALIZE); } @@ -261,7 +258,14 @@ public class RobotRace extends Base { // Draw the axis frame if (gs.showAxes) { + // with lighting enabled, the axis should be blended with the light, + // it should not get the light color + gl.glEnable(GL_COLOR_MATERIAL); + drawAxisFrame(); + + // disable for robot materials + gl.glDisable(GL_COLOR_MATERIAL); } // Draw the robots |