Exemplo n.º 1
0
  public static void setTranslucent(Spatial spatial) {
    MaterialState rs = (MaterialState) doRemoveRenderState(spatial, StateType.Material);
    if (rs != null) {
      materials.put(spatial.getName(), rs);

      MaterialState newState = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();

      ColorRGBA ambient = rs.getAmbient();
      ambient.a = .5f;
      ColorRGBA diffuse = rs.getDiffuse();
      diffuse.a = .5f;
      ColorRGBA emissive = rs.getEmissive();
      emissive.a = .5f;
      ColorRGBA specular = rs.getSpecular();
      specular.a = .5f;

      newState.setAmbient(ambient);
      newState.setColorMaterial(rs.getColorMaterial());
      newState.setDiffuse(diffuse);
      newState.setEmissive(emissive);
      newState.setMaterialFace(rs.getMaterialFace());
      newState.setShininess(rs.getShininess());
      newState.setSpecular(specular);
    }
    spatial.updateRenderState();
    if (spatial instanceof Node && ((Node) spatial).getChildren() != null) {
      for (int i = 0; i < ((Node) spatial).getChildren().size(); i++) {
        colorStripper(((Node) spatial).getChildren().get(i));
      }
    }
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see org.rifidi.designer.entities.Entity#loaded()
   */
  @Override
  public void loaded() {
    if (msStopped == null) {
      msStopped = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
      msStopped.setDiffuse(new ColorRGBA(1, 0, 0, .5f));
      msStopped.setEmissive(new ColorRGBA(1, 0, 0, .3f));
      msStopped.setShininess(1);
      msStopped.setSpecular(new ColorRGBA(1, 0, 0, .3f));
    }
    if (as == null) {
      as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
      as.setBlendEnabled(true);
      as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
      as.setDstFunction(AlphaState.DB_ONE);
      as.setEnabled(true);
    }

    getNode().clearRenderState(RenderState.RS_ALPHA);
    getNode().clearRenderState(RenderState.RS_MATERIAL);
    getNode().setRenderState(as);
    getNode().updateRenderState();
    ((PhysicsNode) getNode()).setMaterial(Material.GHOST);
    if (msStarted == null) {
      msStarted = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
      msStarted.setDiffuse(new ColorRGBA(0, 1, 0, .5f));
      msStarted.setEmissive(new ColorRGBA(0, 1, 0, .3f));
      msStarted.setShininess(1);
      msStarted.setSpecular(new ColorRGBA(0, 1, 0, .3f));
    }
    if (running) {
      turnOn();
    } else {
      turnOff();
    }
    fieldService.registerField(this);
  }