コード例 #1
0
  /**
   * This will add a particle to the system.
   *
   * @param particle
   */
  public void addParticle(E3DParticle particle) {
    particle.setSector(getSector());
    particleList.add(particle);
    particle.setParticleSystem(this);

    renderTree.getParticleHandler().add(particle);
  }
コード例 #2
0
  /**
   * Create a new particle system as a copy of the old
   *
   * @param toCopy
   */
  public E3DParticleSystem(E3DParticleSystem toCopy) {
    super(toCopy.getEngine());

    this.orientation = new E3DOrientation(toCopy.getOrientation());

    // don't copy the ID. Its useless. It needs to be given a new id and set by hand
    E3DParticle particle = null;
    this.renderTree = new E3DRenderTree(getEngine());
    //        this.blendAndTextureSortedParticleMap = new E3DSortedRenderableMap();
    setParticleList(new ArrayList());

    for (int i = 0;
        i < toCopy.getParticleList().size();
        i++) // make actual copies of all the particles
    {
      particle = (E3DParticle) toCopy.getParticleList().get(i);
      try {
        addParticle(particle.onGetClone());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    setGravityDirection(new E3DVector3F(toCopy.getGravityDirection()));
    this.lifeSeconds = toCopy.getLifeSeconds();
    startTime = -1.0;

    setBlendMode(new E3DBlendMode(toCopy.getBlendMode()));
    setRenderMode(new E3DRenderMode(toCopy.getRenderMode()));
  }
コード例 #3
0
  public void setBlendMode(E3DBlendMode blendMode) {
    super.setBlendMode(blendMode);

    E3DParticle particle;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      particle.setBlendMode(new E3DBlendMode(blendMode));
    }
  }
コード例 #4
0
  /**
   * If a particle systems renderMode is changed, so are all the particles contained in the particle
   * system. To change a single particle, change that particles rendermode
   *
   * <p>This will overwrite an individual particle's rendermode. It will not be able to revert back
   * to its original renderMode automatically, you will be responsible for resetting any particle to
   * a different render mode as you see fit.
   */
  public void setRenderMode(E3DRenderMode renderMode) {
    super.setRenderMode(renderMode);

    E3DParticle particle;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      particle.setRenderMode(new E3DRenderMode(renderMode));
    }
  }
コード例 #5
0
  /**
   * Rotate all particles, and movement directions(permanently) in the system around upVec by angle
   * amount
   *
   * @param angle Radian angle
   * @param upVec Normalised up vector to use as the rotation axis
   */
  public void rotate(double angle, E3DVector3F upVec) {
    orientation.rotate(angle, upVec);

    E3DParticle particle = null;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      particle.rotateMovementDirection(angle, upVec, true);
    }
  }
コード例 #6
0
  /**
   * Returns the list of all the quads of all the particles in it
   *
   * @return
   */
  public ArrayList getQuadList() {
    ArrayList quadList = new ArrayList(particleList.size() + 1);
    E3DParticle particle = null;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      if (particle.isAlive()) quadList.add(particle.getQuad());
    }

    return quadList;
  }
コード例 #7
0
  /**
   * Translate the particleSystem by translationVec amt.
   *
   * <p>Translating will translate particles currently in the system. It will NOT translate
   * particles that are added after the translation. New particles will be assumed to know it is at
   * its position when they're startPositions are set
   *
   * @return
   */
  public void translate(E3DVector3F translationAmt) {
    checkSectorChangeDuringMovement(
        orientation.getPosition(), orientation.getPosition().add(translationAmt));

    E3DParticle particle = null;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      particle.translate(translationAmt);
    }

    orientation.translate(translationAmt);
  }
コード例 #8
0
  /** This updates the particles in the system (makes them all move 1 unit) */
  public void updateParticles(E3DActor curActor) {
    double lastFrameTime = getEngine().getFpsTimer().getLastUpdateTimeSeconds();

    if (lifeSeconds > 0.0 && startTime < 0.0)
      startTime = getEngine().getFpsTimer().getCurrentEngineTimeSeconds();

    E3DParticle particle = null;

    if (particleList != null) {
      for (int i = 0; i < particleList.size(); i++) {
        particle = (E3DParticle) particleList.get(i);

        if (!particle.update(curActor, lastFrameTime)) {
          removeParticle(particle);
          i--;
        }
      }
    }
  }
コード例 #9
0
  public static ArrayList getQuadList(List particleList) {
    ArrayList quadList = new ArrayList(particleList.size() + 1);
    E3DParticle particle = null;
    E3DQuad quad = null;
    E3DOrientation orientation;
    for (int i = 0; i < particleList.size(); i++) {
      particle = (E3DParticle) particleList.get(i);
      if (particle.isAlive()) {
        quad = new E3DQuad((E3DQuad) particle.getQuad());
        orientation = particle.getOrientation();

        quad.setVertexPosA(orientation.getWorldVector(quad.getVertexPosA()));
        quad.setVertexPosB(orientation.getWorldVector(quad.getVertexPosB()));
        quad.setVertexPosC(orientation.getWorldVector(quad.getVertexPosC()));
        quad.setVertexPosD(orientation.getWorldVector(quad.getVertexPosD()));

        quadList.add(quad);
      }
    }

    return quadList;
  }