コード例 #1
0
  public void update(final float theDeltaTime) {
    _myTargetForce.strength(_cTargetStrength);
    _myTargetForce.lookAhead(_cLookAhead);
    _myTargetForce.maxForce(_cMaxForce);
    _myTime += 1 / 30f * _cNoiseSpeed;

    _myParticles.update(theDeltaTime);

    _myForceField.noiseOffset(new CCVector3f(_myTime * 0.5f, 0, 0));
    _myForceField.noiseScale(_cNoiseScale);
    _myForceField.strength(_cNoiseStrength);
    _myViscousDrag.drag(_cDrag);
    _myGravity.direction().set(_cGravityX, _cGravityY, _cGravityZ);
    _myGravity.strength(_cGravityStrength);
  }
コード例 #2
0
  public void setup() {
    _myArcball = new CCArcball(this);

    final List<CCForce> myForces = new ArrayList<CCForce>();
    myForces.add(_myViscousDrag = new CCViscousDrag(0.3f));
    myForces.add(_myForceField);
    myForces.add(_myTargetForce = new CCGPUMultiTargetForce(700, 700));
    myForces.add(_myGravity = new CCGravity(new CCVector3f()));

    _myParticles = new CCParticles(g, myForces, new ArrayList<CCGPUConstraint>(), 700, 700);
    _myEmitter = new CCGPUIndexParticleEmitter(_myParticles);
    _myQuad =
        new CCQuad3f(
            new CCVector3f(-250, -250, 0),
            new CCVector3f(250, -250, 0),
            new CCVector3f(250, 250, 0),
            new CCVector3f(-250, 250, 0));
    _myTargetSetup = new CCGPUTargetQuadSetup(_myQuad, CCGPUTargetQuadCreationMode.RANDOM);
    _myTargetForce.targetSetup(_myTargetSetup);

    for (int i = 0; i < 700 * 700; i++) {
      _myEmitter.emit(new CCVector3f(0, 0, 0), CCVecMath.random3f(10), 10, true);
    }

    addControls("app", "app", this);
    fixUpdateTime(1 / 30f);
    _myTileSaver = new CCTileSaver(g);
    addUpdateListener(_myTileSaver);
    addPostListener(_myTileSaver);
  }