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)));
}
}
}
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;
}
}
}
}
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);
}
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;
}
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();
}
Aggregations