diff options
author | Frank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl> | 2014-01-09 15:18:32 +0100 |
---|---|---|
committer | Frank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl> | 2014-01-09 15:18:32 +0100 |
commit | 1a18507da4d04b2e26b6cad73b76f4bd6ba2f2d2 (patch) | |
tree | b960ec433e2b6dd8c0a173e6e63aed1daf9e36f3 | |
parent | c8025eb89306b4c7a47ca8236444d715e7cdfdca (diff) | |
download | 2iv60-robots-1a18507da4d04b2e26b6cad73b76f4bd6ba2f2d2.tar.gz |
Head is now textured too.
-rw-r--r-- | src/Robot.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Robot.java b/src/Robot.java index 51fad15..de7943f 100644 --- a/src/Robot.java +++ b/src/Robot.java @@ -3,6 +3,7 @@ import java.awt.Color; import javax.media.opengl.GL; import static javax.media.opengl.GL2.*; import javax.media.opengl.fixedfunc.GLLightingFunc; +import javax.media.opengl.glu.GLUquadric; import robotrace.Vector; /** @@ -105,8 +106,13 @@ class Robot extends BetterBase { race.getTorsoTexture().bind(gl); drawTorso(); - //race.getHeadTexture().bind(gl); + // Rotate the head so it looks forward (for texturing) + gl.glRotatef(180, 0, 0, 1); + race.getHeadTexture().bind(gl); drawHead(); + + // Rotate back so the other robot parts are facing the right direction + gl.glRotatef(180, 0, 0, 1); unbindTextures(); @@ -442,7 +448,16 @@ class Robot extends BetterBase { // Set color and draw head setColor(asStickFigure ? boneColor : Colors.PALE_TURQOISE); - glut.glutSolidSphere(headRadius, 32, 32); + + GLUquadric sphere = glu.gluNewQuadric(); + + glu.gluQuadricDrawStyle(sphere, glu.GLU_FILL); + glu.gluQuadricTexture(sphere, true); + glu.gluQuadricNormals(sphere, glu.GLU_SMOOTH); + + glu.gluSphere(sphere, headRadius, 32, 32); + + // glut.glutSolidSphere(headRadius, 32, 32); // Pop so we are at the origin again gl.glPopMatrix(); |