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