예제 #1
0
  public void updateGeometry(double length, double radius) {
    this.length = (float) length;
    this.radius = (float) radius;
    if (redShape == null) {
      redShape = new UprightCylinder();
      redShape.setName("red shape");

      redShape.setLocalTranslation(0, this.length * 0.375f, 0);
      this.attachChild(redShape);

      Node3D.setMaterial(getMaterial(Color.red), redShape);
    }

    if (blueShape == null) {
      blueShape = new UprightCylinder();
      blueShape.setName("blue shape");

      blueShape.setLocalTranslation(0, -this.length * 0.375f, 0);
      this.attachChild(blueShape);

      Node3D.setMaterial(getMaterial(Color.blue), blueShape);
    }

    if (centerShape == null) {
      centerShape = new UprightCylinder();
      centerShape.setName("center shape");
      this.attachChild(centerShape);

      TMaterial cMat = ColorUtil.getMaterial(Color.gray);
      cMat.setShininess(90f / 128f);
      Node3D.setMaterial(cMat, centerShape);
    }

    redShape.updateGeometry(4, 24, this.radius, this.radius, this.length / 4f, true, false);
    blueShape.updateGeometry(4, 24, this.radius, this.radius, this.length / 4f, true, false);
    centerShape.updateGeometry(4, 24, this.radius, this.radius, this.length / 2f, true, false);
  }
예제 #2
0
 // TODO: replace this by TealMaterial Constructor call
 private static TMaterial getMaterial(Color col) {
   TMaterial redMat = ColorUtil.getMaterial(col);
   redMat.setShininess(0.5f);
   return redMat;
 }