public ParticleSystem(String name, int numParticles, ParticleType particleType) {
    super(name);
    this.numParticles = numParticles;
    this.particleType = particleType;
    emissionDirection = new Vector3f(0.0f, 1.0f, 0.0f);
    minimumLifeTime = DEFAULT_MIN_LIFE;
    maximumLifeTime = DEFAULT_MAX_LIFE;
    maximumAngle = DEFAULT_MAX_ANGLE;
    startSize = DEFAULT_START_SIZE;
    endSize = DEFAULT_END_SIZE;
    startColor = DEFAULT_START_COLOR.clone();
    endColor = DEFAULT_END_COLOR.clone();
    upVector = Vector3f.UNIT_Y.clone();
    leftVector = new Vector3f(-1, 0, 0);
    originCenter = new Vector3f();
    originOffset = new Vector3f();
    startSpin = 0;
    endSpin = 0;
    startMass = 1;
    endMass = 1;
    startTexIndex = 0;
    texQuantity = 1;
    releaseRate = numParticles;
    // init working vectors.. used to prevent additional object creation.
    upXemit = new Vector3f();
    absUpVector = new Vector3f();
    abUpMinUp = new Vector3f();
    initialVelocity = 1.0f;

    rotMatrix = new Matrix3f();
    initializeParticles(numParticles);
  }
  public void read(JMEImporter e) throws IOException {
    detachAllChildren();
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    emitType = capsule.readEnum("emitType", EmitType.class, EmitType.Point);
    particleType = capsule.readEnum("particleType", ParticleType.class, ParticleType.Quad);
    psLine = (Line) capsule.readSavable("psLine", null);
    psRect = (Rectangle) capsule.readSavable("psRect", null);
    psRing = (Ring) capsule.readSavable("psRing", null);
    psGeom = (Geometry) capsule.readSavable("psGeom", null);
    startSize = capsule.readFloat("startSize", DEFAULT_START_SIZE);
    endSize = capsule.readFloat("endSize", DEFAULT_END_SIZE);
    startColor = (ColorRGBA) capsule.readSavable("startColor", DEFAULT_START_COLOR.clone());
    endColor = (ColorRGBA) capsule.readSavable("endColor", DEFAULT_END_COLOR.clone());
    startSpin = capsule.readFloat("startSpin", 0);
    endSpin = capsule.readFloat("endSpin", 0);
    startMass = capsule.readFloat("startMass", 0);
    endMass = capsule.readFloat("endMass", 0);
    startTexIndex = capsule.readInt("startTexIndex", 0);
    texQuantity = capsule.readInt("texQuantity", 1);
    initialVelocity = capsule.readFloat("initialVelocity", 1);
    minimumLifeTime = capsule.readFloat("minimumLifeTime", DEFAULT_MIN_LIFE);
    maximumLifeTime = capsule.readFloat("maximumLifeTime", DEFAULT_MAX_LIFE);
    minimumAngle = capsule.readFloat("minimumAngle", 0);
    maximumAngle = capsule.readFloat("maximumAngle", DEFAULT_MAX_ANGLE);
    emissionDirection =
        (Vector3f) capsule.readSavable("emissionDirection", Vector3f.UNIT_Y.clone());
    worldEmit = (Vector3f) capsule.readSavable("worldEmit", Vector3f.ZERO.clone());
    upVector = (Vector3f) capsule.readSavable("upVector", Vector3f.UNIT_Y.clone());
    leftVector = (Vector3f) capsule.readSavable("leftVector", new Vector3f(-1, 0, 0));
    numParticles = capsule.readInt("numParticles", 0);
    rotateWithScene = capsule.readBoolean("rotateWithScene", false);
    geometryCoordinates = capsule.readFloatBuffer("geometryCoordinates", null);
    appearanceColors = capsule.readFloatBuffer("appearanceColors", null);

    releaseRate = capsule.readInt("releaseRate", numParticles);
    particleOrientation = capsule.readFloat("particleOrientation", 0);
    originCenter = (Vector3f) capsule.readSavable("originCenter", new Vector3f());
    originOffset = (Vector3f) capsule.readSavable("originOffset", new Vector3f());
    controller = (ParticleController) capsule.readSavable("controller", null);
    cameraFacing = capsule.readBoolean("cameraFacing", true);
    velocityAligned = capsule.readBoolean("velocityAligned", false);
    particlesInWorldCoords = capsule.readBoolean("particlesInWorldCoords", true);
    ramp = (ParticleAppearanceRamp) capsule.readSavable("ramp", new ParticleAppearanceRamp());
    texAnimation = (TexAnimation) capsule.readSavable("texAnimation", new TexAnimation());

    invScale = new Vector3f();
    upXemit = new Vector3f();
    absUpVector = new Vector3f();
    abUpMinUp = new Vector3f();
    rotMatrix = new Matrix3f();
    initializeParticles(numParticles);
  }
  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));
      }
    }
  }
  @Override
  public void invalidate() {
    super.invalidate();
    for (LightRecord record : lightList) {
      record.invalidate();
    }

    lightMask = -1;
    backLightMask = -1;
    twoSidedOn = false;
    enabled = false;
    localViewer = false;
    separateSpecular = false;
    globalAmbient.set(-1, -1, -1, -1);
  }
  private void applyFogColor(ColorRGBA color, FogStateRecord record) {
    final GL gl = GLU.getCurrentGL();

    if (!record.isValid() || !color.equals(record.fogColor)) {
      record.fogColor.set(color);
      record.colorBuff.clear();
      record
          .colorBuff
          .put(record.fogColor.r)
          .put(record.fogColor.g)
          .put(record.fogColor.b)
          .put(record.fogColor.a);
      record.colorBuff.flip();
      gl.glFogfv(GL.GL_FOG_COLOR, record.colorBuff); // TODO Check for float
    }
  }
示例#6
0
  /**
   * <code>toString</code> returns the string representation of this font object in the Format: <br>
   * <br>
   * jme.geometry.hud.text.Font2D@1c282a1 <br>
   * Color: {RGBA COLOR} <br>
   *
   * @return the string representation of this object.
   */
  public String toString() {
    String string = super.toString();
    string += "\nColor: " + fontColor.toString();

    return string;
  }
示例#7
0
 /**
  * <code>setColor</code> sets the RGBA values to render the font as. By default the color is white
  * with no transparency.
  *
  * @param color the color to set.
  */
 public void setColor(ColorRGBA color) {
   fontColor.set(color);
 }