use of com.badlogic.gdx.graphics.g3d.particles.ParticleEffect in project libgdx by libgdx.
the class FlameMain method openEffect.
public ParticleEffect openEffect(File file, boolean replaceCurrentWorkspace) {
try {
ParticleEffect loadedEffect = load(file.getAbsolutePath(), ParticleEffect.class, null, new ParticleEffectLoader.ParticleEffectLoadParameter(particleSystem.getBatches()));
loadedEffect = loadedEffect.copy();
loadedEffect.init();
if (replaceCurrentWorkspace) {
effect = loadedEffect;
controllersData.clear();
particleSystem.removeAll();
particleSystem.add(effect);
for (ParticleController controller : effect.getControllers()) controllersData.add(new ControllerData(controller));
rebuildActiveControllers();
}
reloadRows();
return loadedEffect;
} catch (Exception ex) {
System.out.println("Error loading effect: " + file.getAbsolutePath());
ex.printStackTrace();
JOptionPane.showMessageDialog(this, "Error opening effect.");
}
return null;
}
use of com.badlogic.gdx.graphics.g3d.particles.ParticleEffect in project libgdx by libgdx.
the class FlameMain method getParticleEffects.
public Array<ParticleEffect> getParticleEffects(Array<ParticleController> controllers, Array<ParticleEffect> out) {
out.clear();
assetManager.getAll(ParticleEffect.class, out);
for (int i = 0; i < out.size; ) {
ParticleEffect effect = out.get(i);
Array<ParticleController> effectControllers = effect.getControllers();
boolean remove = true;
for (ParticleController controller : controllers) {
if (effectControllers.contains(controller, true)) {
remove = false;
break;
}
}
if (remove) {
out.removeIndex(i);
continue;
}
++i;
}
return out;
}
use of com.badlogic.gdx.graphics.g3d.particles.ParticleEffect in project libgdx by libgdx.
the class ParticleControllerInfluencerPanel method reloadControllers.
private void reloadControllers() {
Array<ParticleEffect> effects = new Array<ParticleEffect>();
Array<ParticleController> controllers = new Array<ParticleController>();
editor.assetManager.getAll(ParticleEffect.class, effects);
for (ParticleEffect effect : effects) {
controllers.addAll(effect.getControllers());
}
controllerPicker.setLoadedTemplates(controllers);
}
use of com.badlogic.gdx.graphics.g3d.particles.ParticleEffect 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)));
}
}
}
use of com.badlogic.gdx.graphics.g3d.particles.ParticleEffect 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);
}
Aggregations