Search in sources :

Example 1 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerInfluencer method load.

@Override
public void load(AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData();
    Array<IntArray> effectsIndices = data.load("indices");
    AssetDescriptor descriptor;
    Iterator<IntArray> iterator = effectsIndices.iterator();
    while ((descriptor = data.loadAsset()) != null) {
        ParticleEffect effect = (ParticleEffect) manager.get(descriptor);
        if (effect == null)
            throw new RuntimeException("Template is null");
        Array<ParticleController> effectControllers = effect.getControllers();
        IntArray effectIndices = iterator.next();
        for (int i = 0, n = effectIndices.size; i < n; i++) {
            templates.add(effectControllers.get(effectIndices.get(i)));
        }
    }
}
Also used : ParticleEffect(com.badlogic.gdx.graphics.g3d.particles.ParticleEffect) IntArray(com.badlogic.gdx.utils.IntArray) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 2 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerInfluencer method dispose.

@Override
public void dispose() {
    if (controller != null) {
        for (int i = 0; i < controller.particles.size; ++i) {
            ParticleController controller = particleControllerChannel.data[i];
            if (controller != null) {
                controller.dispose();
                particleControllerChannel.data[i] = null;
            }
        }
    }
}
Also used : ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

Example 3 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class ParticleControllerInfluencer method save.

@Override
public void save(AssetManager manager, ResourceData resources) {
    SaveData data = resources.createSaveData();
    Array<ParticleEffect> effects = manager.getAll(ParticleEffect.class, new Array<ParticleEffect>());
    Array<ParticleController> controllers = new Array<ParticleController>(templates);
    Array<IntArray> effectsIndices = new Array<IntArray>();
    for (int i = 0; i < effects.size && controllers.size > 0; ++i) {
        ParticleEffect effect = effects.get(i);
        Array<ParticleController> effectControllers = effect.getControllers();
        Iterator<ParticleController> iterator = controllers.iterator();
        IntArray indices = null;
        while (iterator.hasNext()) {
            ParticleController controller = iterator.next();
            int index = -1;
            if ((index = effectControllers.indexOf(controller, true)) > -1) {
                if (indices == null) {
                    indices = new IntArray();
                }
                iterator.remove();
                indices.add(index);
            }
        }
        if (indices != null) {
            data.saveAsset(manager.getAssetFileName(effect), ParticleEffect.class);
            effectsIndices.add(indices);
        }
    }
    data.save("indices", effectsIndices);
}
Also used : ParticleEffect(com.badlogic.gdx.graphics.g3d.particles.ParticleEffect) Array(com.badlogic.gdx.utils.Array) IntArray(com.badlogic.gdx.utils.IntArray) IntArray(com.badlogic.gdx.utils.IntArray) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)

Example 4 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class EffectPanel method createDefaultParticleController.

private ParticleController createDefaultParticleController() {
    //Emission
    RegularEmitter emitter = new RegularEmitter();
    emitter.getDuration().setLow(3000);
    emitter.getEmission().setHigh(90);
    emitter.getLife().setHigh(3000);
    emitter.setMaxParticleCount(100);
    //Spawn
    EllipseSpawnShapeValue pointSpawnShapeValue = new EllipseSpawnShapeValue();
    pointSpawnShapeValue.setDimensions(1, 1, 1);
    pointSpawnShapeValue.setSide(SpawnSide.top);
    SpawnInfluencer spawnSource = new SpawnInfluencer(pointSpawnShapeValue);
    //Scale
    ScaleInfluencer scaleInfluencer = new ScaleInfluencer();
    scaleInfluencer.value.setHigh(1);
    scaleInfluencer.value.setLow(0);
    scaleInfluencer.value.setTimeline(new float[] { 0, 1 });
    scaleInfluencer.value.setScaling(new float[] { 1, 0 });
    //Velocity
    DynamicsInfluencer velocityInfluencer = new DynamicsInfluencer();
    //Directional
    DynamicsModifier.CentripetalAcceleration velocityValue = new DynamicsModifier.CentripetalAcceleration();
    velocityValue.strengthValue.setHigh(5, 10);
    velocityValue.strengthValue.setActive(true);
    velocityInfluencer.velocities.add(velocityValue);
    return new ParticleController("ParticleController Controller", emitter, new ParticleControllerControllerRenderer(), new ParticleControllerInfluencer.Single(editor.assetManager.get(FlameMain.DEFAULT_TEMPLATE_PFX, ParticleEffect.class).getControllers().get(0)), spawnSource, scaleInfluencer, velocityInfluencer, new ParticleControllerFinalizerInfluencer());
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) RegularEmitter(com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter) ParticleControllerFinalizerInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ParticleControllerFinalizerInfluencer) DynamicsModifier(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier) EllipseSpawnShapeValue(com.badlogic.gdx.graphics.g3d.particles.values.EllipseSpawnShapeValue) ScaleInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer) ParticleControllerControllerRenderer(com.badlogic.gdx.graphics.g3d.particles.renderers.ParticleControllerControllerRenderer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) ParticleControllerInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ParticleControllerInfluencer) SpawnInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)

Example 5 with ParticleController

use of com.badlogic.gdx.graphics.g3d.particles.ParticleController in project libgdx by libgdx.

the class EffectPanel method createDefaultPointController.

private ParticleController createDefaultPointController() {
    //Emission
    RegularEmitter emitter = new RegularEmitter();
    emitter.getDuration().setLow(3000);
    emitter.getEmission().setHigh(250);
    emitter.getLife().setHigh(500, 1000);
    emitter.getLife().setTimeline(new float[] { 0, 0.66f, 1 });
    emitter.getLife().setScaling(new float[] { 1, 1, 0.3f });
    emitter.setMaxParticleCount(200);
    //Scale
    ScaleInfluencer scaleInfluencer = new ScaleInfluencer();
    scaleInfluencer.value.setHigh(1);
    //Color
    ColorInfluencer.Single colorInfluencer = new ColorInfluencer.Single();
    colorInfluencer.colorValue.setColors(new float[] { 0.12156863f, 0.047058824f, 1, 0, 0, 0 });
    colorInfluencer.colorValue.setTimeline(new float[] { 0, 1 });
    colorInfluencer.alphaValue.setHigh(1);
    colorInfluencer.alphaValue.setTimeline(new float[] { 0, 0.5f, 0.8f, 1 });
    colorInfluencer.alphaValue.setScaling(new float[] { 0, 0.15f, 0.5f, 0 });
    //Spawn
    PointSpawnShapeValue pointSpawnShapeValue = new PointSpawnShapeValue();
    SpawnInfluencer spawnSource = new SpawnInfluencer(pointSpawnShapeValue);
    //Velocity
    DynamicsInfluencer velocityInfluencer = new DynamicsInfluencer();
    //Directional
    DynamicsModifier.PolarAcceleration velocityValue = new DynamicsModifier.PolarAcceleration();
    velocityValue.phiValue.setHigh(-35, 35);
    velocityValue.phiValue.setActive(true);
    velocityValue.phiValue.setTimeline(new float[] { 0, 0.5f, 1 });
    velocityValue.phiValue.setScaling(new float[] { 1, 0, 0 });
    velocityValue.thetaValue.setHigh(0, 360);
    velocityValue.strengthValue.setHigh(5, 10);
    return new ParticleController("PointSprite Controller", emitter, new PointSpriteRenderer(editor.getPointSpriteBatch()), new RegionInfluencer.Single((Texture) editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE)), spawnSource, scaleInfluencer, colorInfluencer, velocityInfluencer);
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) RegularEmitter(com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter) Texture(com.badlogic.gdx.graphics.Texture) DynamicsModifier(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier) PointSpawnShapeValue(com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue) ScaleInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer) PointSpriteRenderer(com.badlogic.gdx.graphics.g3d.particles.renderers.PointSpriteRenderer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) ColorInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer) RegionInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer) SpawnInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)

Aggregations

ParticleController (com.badlogic.gdx.graphics.g3d.particles.ParticleController)26 DynamicsInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer)8 ParticleEffect (com.badlogic.gdx.graphics.g3d.particles.ParticleEffect)7 RegularEmitter (com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter)6 SpawnInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)6 ColorInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer)5 DynamicsModifier (com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier)4 RegionInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer)4 ScaleInfluencer (com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer)4 BillboardRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.BillboardRenderer)4 PointSpawnShapeValue (com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue)4 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 SaveData (com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)2 ModelInstanceRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.ModelInstanceRenderer)2 ParticleControllerControllerRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.ParticleControllerControllerRenderer)2 PointSpriteRenderer (com.badlogic.gdx.graphics.g3d.particles.renderers.PointSpriteRenderer)2 EllipseSpawnShapeValue (com.badlogic.gdx.graphics.g3d.particles.values.EllipseSpawnShapeValue)2 Array (com.badlogic.gdx.utils.Array)2 IntArray (com.badlogic.gdx.utils.IntArray)2