/** Draws circular particle using a display list. */ public void display(GL gl) { if (PARTICLE_DISPLAY_LIST < 0) { // MAKE DISPLAY LIST: int displayListIndex = gl.glGenLists(1); gl.glNewList(displayListIndex, GL.GL_COMPILE); drawParticle(gl, new Point3d(), radius); // /particle at origin gl.glEndList(); System.out.println("MADE LIST " + displayListIndex + " : " + gl.glIsList(displayListIndex)); PARTICLE_DISPLAY_LIST = displayListIndex; } // / COLOR: DEFAULT WHITE; GREEN IF HIGHLIGHTED; ADD RED IF PINNED Color3f c = new Color3f(1, 1, 1); // default: white if (pin) { c.x = 1f; // add red c.y *= 0.2f; c.z = 0; } if (highlight) { c.y = 1; c.z = 0; } if (GooParticle.class.isInstance(this)) { c.x = 0; c.y = 0; // now its blue } gl.glColor3f(c.x, c.y, c.z); // / DRAW ORIGIN-CIRCLE TRANSLATED TO "p": gl.glPushMatrix(); gl.glTranslated(x.x, x.y, x.z); gl.glCallList(PARTICLE_DISPLAY_LIST); gl.glPopMatrix(); }
/** Draws a canonical circular particle. */ private static void drawParticle(GL gl, Point3d p, double r) { double radius = r; double vectorY1 = p.y; double vectorX1 = p.x; double vectorZ1 = p.z; GLU glu = new GLU(); GLUquadric quadratic = glu.gluNewQuadric(); glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH); glu.gluQuadricTexture(quadratic, true); gl.glPushMatrix(); gl.glTranslated(p.x, p.y, p.z); glu.gluSphere(quadratic, radius, 12, 12); gl.glPopMatrix(); }