Exemplo n.º 1
0
  /** 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();
  }
Exemplo n.º 2
0
  public void getPropertyComponents(List comps, final ObjectListener listener) {
    visibleCbx = new JCheckBox(getName(), visible);
    float[] rgb = color.get().getRGBComponents(null);
    slider = new JSlider(0, 100, (int) (rgb[0] * 100));

    float[] xyz = new float[3];
    direction.get(xyz);
    directionXFld = makeField("" + xyz[0], listener, "X Direction");
    directionYFld = makeField("" + xyz[1], listener, "Y Direction");
    directionZFld = makeField("" + xyz[2], listener, "Z Direction");

    double[] pxyz = new double[3];
    location.get(pxyz);
    locationXFld = makeField("" + pxyz[0], listener, "");
    locationYFld = makeField("" + pxyz[1], listener, "");
    locationZFld = makeField("" + pxyz[2], listener, "");

    List fldComps =
        Misc.newList(GuiUtils.rLabel("Direction:"), directionXFld, directionYFld, directionZFld);
    //
    // fldComps.addAll(Misc.newList(GuiUtils.rLabel("Location:"),locationXFld,locationYFld,locationZFld));

    comps.add(visibleCbx);
    GuiUtils.tmpInsets = new Insets(0, 2, 0, 0);
    comps.add(
        GuiUtils.vbox(
            slider, GuiUtils.left(GuiUtils.doLayout(fldComps, 4, GuiUtils.WT_N, GuiUtils.WT_N))));

    if (listener != null) {
      visibleCbx.addActionListener(listener);
      slider.addChangeListener(listener);
    }
  }
Exemplo n.º 3
0
 public void brighter() {
   float[] rgb = color.get().getRGBComponents(null);
   rgb[0] = (float) Math.min(rgb[0] + 0.1, 1.0);
   rgb[1] = (float) Math.min(rgb[1] + 0.1, 1.0);
   rgb[2] = (float) Math.min(rgb[2] + 0.1, 1.0);
   color = new Color3f(rgb);
   updateLight();
 }