Search in sources :

Example 1 with SaveData

use of com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData 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 SaveData

use of com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData 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 3 with SaveData

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

the class MeshSpawnShapeValue method load.

@Override
public void load(AssetManager manager, ResourceData data) {
    SaveData saveData = data.getSaveData();
    AssetDescriptor descriptor = saveData.loadAsset();
    if (descriptor != null) {
        Model model = (Model) manager.get(descriptor);
        setMesh(model.meshes.get((Integer) saveData.load("index")), model);
    }
}
Also used : Model(com.badlogic.gdx.graphics.g3d.Model) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 4 with SaveData

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

the class BillboardParticleBatch method load.

@Override
public void load(AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData("billboardBatch");
    if (data != null) {
        setTexture((Texture) manager.get(data.loadAsset()));
        Config cfg = (Config) data.load("cfg");
        setUseGpu(cfg.useGPU);
        setAlignMode(cfg.mode);
    }
}
Also used : SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)

Example 5 with SaveData

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

the class ModelInfluencer method load.

@Override
public void load(AssetManager manager, ResourceData resources) {
    SaveData data = resources.getSaveData();
    AssetDescriptor descriptor;
    while ((descriptor = data.loadAsset()) != null) {
        Model model = (Model) manager.get(descriptor);
        if (model == null)
            throw new RuntimeException("Model is null");
        models.add(model);
    }
}
Also used : Model(com.badlogic.gdx.graphics.g3d.Model) SaveData(com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Aggregations

SaveData (com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData)8 AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)3 Model (com.badlogic.gdx.graphics.g3d.Model)2 ParticleController (com.badlogic.gdx.graphics.g3d.particles.ParticleController)2 ParticleEffect (com.badlogic.gdx.graphics.g3d.particles.ParticleEffect)2 IntArray (com.badlogic.gdx.utils.IntArray)2 Array (com.badlogic.gdx.utils.Array)1