Esempio n. 1
0
 public void setGraphics(EGraphics graphics) {
   EGraphics.J3DTransparencyOption op = graphics.getTransparencyMode();
   TransparencyAttributes ta = getTransparencyAttributes();
   ta.setTransparency((float) graphics.getTransparencyFactor());
   ta.setTransparencyMode(op.mode);
   setTransparencyAndRenderingAttributes(ta, op != EGraphics.J3DTransparencyOption.NONE);
   set3DColor(null, graphics.getColor());
 }
Esempio n. 2
0
  /**
   * Sets the appearance.
   *
   * @param shape the new appearance
   */
  private void setAppearance(Shape3D shape) {
    Appearance sphereApp = new Appearance();
    TransparencyAttributes sphereTrans = new TransparencyAttributes();
    PolygonAttributes spherePa = new PolygonAttributes();

    spherePa.setCullFace(PolygonAttributes.CULL_NONE);
    sphereApp.setPolygonAttributes(spherePa);
    sphereTrans.setTransparency(0.6f);
    sphereTrans.setTransparencyMode(TransparencyAttributes.NICEST);
    sphereApp.setTransparencyAttributes(sphereTrans);
    shape.setAppearance(sphereApp);
  }
Esempio n. 3
0
 private Appearance makeMaterial(float r, float g, float b, float transparency) {
   Appearance appearance = new Appearance();
   Color3f color3f = new Color3f(r, g, b);
   Material material = new Material(color3f, new Color3f(0f, 0f, 0f), color3f, color3f, 10f);
   material.setLightingEnable(true);
   appearance.setMaterial(material);
   if (!Float.isNaN(transparency)) {
     TransparencyAttributes ta = new TransparencyAttributes();
     ta.setTransparencyMode(TransparencyAttributes.NICEST);
     ta.setTransparency(transparency);
     appearance.setTransparencyAttributes(ta);
   }
   return appearance;
 }
Esempio n. 4
0
  private void createGameField() {
    // Marker #0: game field
    Appearance app = new BlueAppearance();
    TransparencyAttributes ta = new TransparencyAttributes();
    ta.setTransparency(0.5f);
    ta.setTransparencyMode(TransparencyAttributes.BLENDED);
    app.setTransparencyAttributes(ta);
    pathObject = new PathObject(app);

    pathObject.getTransformGroup().addChild(GameController.getInstance().particleGroup);
    GameController.getInstance().pathObject = pathObject;
    EnemySpawnController eSpawn = EnemySpawnController.getInstance();
    pathObject.addChild(eSpawn);

    this.markerObjects[0].getTransformGroup().addChild(pathObject);
    this.markerObjects[0].getTransformGroup().addChild(GameController.getInstance());
  }
Esempio n. 5
0
  @Override
  protected Appearance createAppearance() {
    Appearance appearance = new Appearance();
    appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
    appearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);

    LineAttributes lineAttrib = new LineAttributes();
    lineAttrib.setCapability(LineAttributes.ALLOW_ANTIALIASING_WRITE);
    lineAttrib.setCapability(LineAttributes.ALLOW_PATTERN_WRITE);
    lineAttrib.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttrib.setLineWidth(linewidth);
    lineAttrib.setLinePattern(pattern);
    appearance.setLineAttributes(lineAttrib);

    PolygonAttributes polyAttrib = new PolygonAttributes();
    polyAttrib.setCapability(PolygonAttributes.ALLOW_MODE_WRITE);
    polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_FILL);
    polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
    polyAttrib.setBackFaceNormalFlip(true);
    appearance.setPolygonAttributes(polyAttrib);

    ColoringAttributes colorAttrib = new ColoringAttributes();
    colorAttrib.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
    colorAttrib.setColor(color);
    appearance.setColoringAttributes(colorAttrib);

    TransparencyAttributes tr = new TransparencyAttributes();
    int mode = transparency == 0f ? TransparencyAttributes.NONE : TransparencyAttributes.FASTEST;
    tr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
    tr.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
    tr.setTransparencyMode(mode);
    tr.setTransparency(transparency);
    appearance.setTransparencyAttributes(tr);

    Material material = new Material();
    material.setCapability(Material.ALLOW_COMPONENT_WRITE);
    material.setAmbientColor(0.1f, 0.1f, 0.1f);
    material.setSpecularColor(0.1f, 0.1f, 0.1f);
    material.setDiffuseColor(0.1f, 0.1f, 0.1f);
    appearance.setMaterial(material);
    return appearance;
  }
Esempio n. 6
0
  @Override
  protected Appearance createAppearance() {
    final Appearance appearance = new Appearance();
    appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
    appearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);

    final PointAttributes pointAttrib = new PointAttributes();
    pointAttrib.setCapability(PointAttributes.ALLOW_ANTIALIASING_WRITE);
    pointAttrib.setCapability(PointAttributes.ALLOW_SIZE_WRITE);
    pointAttrib.setPointSize(pointsize);
    appearance.setPointAttributes(pointAttrib);

    final PolygonAttributes polyAttrib = new PolygonAttributes();
    polyAttrib.setCapability(PolygonAttributes.ALLOW_MODE_WRITE);
    polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_FILL);
    polyAttrib.setCullFace(PolygonAttributes.CULL_BACK);
    polyAttrib.setBackFaceNormalFlip(false);
    appearance.setPolygonAttributes(polyAttrib);

    final ColoringAttributes colorAttrib = new ColoringAttributes();
    colorAttrib.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
    colorAttrib.setColor(color);
    appearance.setColoringAttributes(colorAttrib);

    final TransparencyAttributes tr = new TransparencyAttributes();
    final int mode =
        transparency == 0f ? TransparencyAttributes.NONE : TransparencyAttributes.FASTEST;
    tr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
    tr.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
    tr.setTransparencyMode(mode);
    tr.setTransparency(transparency);
    appearance.setTransparencyAttributes(tr);

    final Material material = new Material();
    material.setCapability(Material.ALLOW_COMPONENT_WRITE);
    material.setAmbientColor(0.1f, 0.1f, 0.1f);
    material.setSpecularColor(0.1f, 0.1f, 0.1f);
    material.setDiffuseColor(0.1f, 0.1f, 0.1f);
    appearance.setMaterial(material);
    return appearance;
  }
Esempio n. 7
0
  private void setOtherAppearanceValues(int mode, float factor, Color color, boolean visible) {
    // Transparency values
    TransparencyAttributes ta = new TransparencyAttributes(mode, factor);
    ta.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);
    ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
    ta.setCapability(TransparencyAttributes.ALLOW_MODE_READ);
    ta.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
    setTransparencyAttributes(ta);

    setCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
    setCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
    // For highlight
    setCapability(ALLOW_MATERIAL_READ);
    setCapability(ALLOW_MATERIAL_WRITE);
    // For visibility
    setCapability(ALLOW_RENDERING_ATTRIBUTES_READ);
    setCapability(ALLOW_RENDERING_ATTRIBUTES_WRITE);
    // Color
    setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
    setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);

    // Adding Rendering attributes to access visibility flag if layer is available
    if (layer != null) {
      RenderingAttributes ra = new RenderingAttributes();
      ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_READ);
      ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
      ra.setCapability(RenderingAttributes.ALLOW_DEPTH_ENABLE_READ);
      ra.setCapability(RenderingAttributes.ALLOW_DEPTH_ENABLE_WRITE);
      ra.setVisible(visible);
      setRenderingAttributes(ra);
      if (mode != TransparencyAttributes.NONE) ra.setDepthBufferEnable(true);
    }

    // Set up the polygon attributes
    // PolygonAttributes pa = new PolygonAttributes();
    // pa.setCullFace(PolygonAttributes.CULL_NONE);
    // pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    // setPolygonAttributes(pa);

    // TextureAttributes texAttr = new TextureAttributes();
    // texAttr.setTextureMode(TextureAttributes.MODULATE);
    // texAttr.setTextureColorTable(pattern);
    // setTextureAttributes(texAttr);

    // LineAttributes lineAttr = new LineAttributes();
    // lineAttr.setLineAntialiasingEnable(true);
    // setLineAttributes(lineAttr);

    // Adding to internal material
    //				Material mat = new Material(objColor, black, objColor, white, 70.0f);
    if (color != null) {
      Color3f objColor = new Color3f(color);
      // Emissive is black and specular is plastic!
      // Color3f specular = new Color3f(color.brighter());
      Material mat =
          new Material(objColor, J3DUtils.black, objColor, J3DUtils.plastic /*J3DUtils.white*/, 17);
      mat.setLightingEnable(true);
      mat.setCapability(Material.ALLOW_COMPONENT_READ);
      mat.setCapability(Material.ALLOW_COMPONENT_WRITE);
      mat.setCapability(Material.AMBIENT_AND_DIFFUSE);
      setMaterial(mat);
    }
  }