Search in sources :

Example 11 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 12 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 13 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 14 with ParticleController

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

the class DynamicsInfluencerPanel method deleteVelocity.

protected void deleteVelocity() {
    int row = velocityTable.getSelectedRow();
    if (row == -1)
        return;
    //Remove the velocity from the table
    ParticleController controller = editor.getEmitter();
    DynamicsInfluencer influencer = (DynamicsInfluencer) controller.findInfluencer(DynamicsInfluencer.class);
    influencer.velocities.removeValue(velocities.removeIndex(row).velocityValue, true);
    velocityTableModel.removeRow(row);
    //Restart the effect and reinit the controller
    editor.restart();
    selectedVelocityPanel.setVisible(false);
    selectedVelocityPanel = null;
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

Example 15 with ParticleController

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

the class DynamicsInfluencerPanel method velocityChecked.

protected void velocityChecked(int index, boolean isChecked) {
    ParticleController controller = editor.getEmitter();
    DynamicsInfluencer influencer = (DynamicsInfluencer) controller.findInfluencer(DynamicsInfluencer.class);
    influencer.velocities.clear();
    velocities.get(index).isActive = isChecked;
    for (VelocityWrapper wrapper : velocities) {
        if (wrapper.isActive)
            influencer.velocities.add(wrapper.velocityValue);
    }
    //Restart the effect and reinit the controller
    editor.restart();
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController)

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