use of com.talosvfx.talos.runtime.ParticleEffectInstance in project talos by rockbite.
the class PreviewWidget method drawContent.
@Override
public void drawContent(Batch batch, float parentAlpha) {
if (previewController.isGridVisible()) {
batch.end();
drawGrid(batch, parentAlpha * 0.5f);
batch.begin();
}
mid.set(0, 0);
float imagePrefWidth = previewImage.getPrefWidth();
float imagePrefHeight = previewImage.getPrefHeight();
float scale = imagePrefHeight / imagePrefWidth;
float imageWidth = previewController.getImageWidth();
float imageHeight = imageWidth * scale;
previewController.getPreviewBoxWidth();
previewImage.setPosition(mid.x - imageWidth / 2, mid.y - imageHeight / 2);
previewImage.setSize(imageWidth, imageHeight);
if (previewController.isBackground()) {
previewImage.draw(batch, parentAlpha);
}
spriteBatchParticleRenderer.setBatch(batch);
batch.flush();
glProfiler.enable();
long timeBefore = TimeUtils.nanoTime();
final ParticleEffectInstance particleEffect = TalosMain.Instance().TalosProject().getParticleEffect();
particleEffect.render(particleRenderer);
batch.flush();
renderTime.put(TimeUtils.timeSinceNanos(timeBefore));
trisCount = (int) (glProfiler.getVertexCount().value / 3f);
glProfiler.disable();
if (!previewController.isBackground()) {
previewImage.draw(batch, parentAlpha);
}
// now for the drag points
if (dragPoints.size > 0) {
batch.end();
tmpColor.set(Color.ORANGE);
tmpColor.a = 0.8f;
Gdx.gl.glLineWidth(1f);
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(tmpColor);
for (DragPoint point : dragPoints) {
shapeRenderer.circle(point.position.x, point.position.y, 0.1f * camera.zoom, 15);
}
shapeRenderer.end();
batch.begin();
}
}
use of com.talosvfx.talos.runtime.ParticleEffectInstance in project talos by rockbite.
the class BoundEffect method update.
public void update(float delta) {
// value attachments
for (AttachmentPoint attachmentPoint : valueAttachments) {
if (attachmentPoint.isStatic()) {
scopePayload.setDynamicValue(attachmentPoint.getSlotId(), attachmentPoint.getStaticValue());
} else {
Bone bone = parent.getBoneByName(attachmentPoint.getBoneName());
attachmentPoint.setBoneScale(bone.getWorldScaleX());
float rotation = bone.getWorldRotationX();
Color color = Color.WHITE;
for (Slot slot : parent.getSkeleton().getSlots()) {
if (slot.getBone().getData().getName().equals(bone.getData().getName())) {
// can be many
color = slot.getColor();
break;
}
}
tmpVec.set(attachmentPoint.getWorldOffsetX(), attachmentPoint.getWorldOffsetY());
tmpVec.rotate(rotation);
tmpVec.add(parent.getBonePosX(attachmentPoint.getBoneName()), parent.getBonePosY(attachmentPoint.getBoneName()));
if (attachmentPoint.getAttachmentType() == AttachmentPoint.AttachmentType.POSITION) {
val.set(tmpVec.x, tmpVec.y);
} else if (attachmentPoint.getAttachmentType() == AttachmentPoint.AttachmentType.ROTATION) {
val.set(rotation);
} else if (attachmentPoint.getAttachmentType() == AttachmentPoint.AttachmentType.TRANSPARENCY) {
val.set(color.a);
} else if (attachmentPoint.getAttachmentType() == AttachmentPoint.AttachmentType.COLOR) {
val.set(color.r, color.g, color.b);
}
scopePayload.setDynamicValue(attachmentPoint.getSlotId(), val);
}
}
// update position for each instance and update effect itself
removeList.clear();
for (ParticleEffectInstance instance : particleEffects) {
if (instance.isComplete()) {
removeList.add(instance);
}
if (positionAttachment != null) {
if (positionAttachment.isStatic()) {
instance.setPosition(positionAttachment.getStaticValue().get(0), positionAttachment.getStaticValue().get(1));
} else {
Bone bone = parent.getBoneByName(positionAttachment.getBoneName());
positionAttachment.setBoneScale(bone.getWorldScaleX());
tmpVec.set(positionAttachment.getWorldOffsetX(), positionAttachment.getWorldOffsetY());
float rotation = bone.getWorldRotationX();
tmpVec.rotate(rotation);
tmpVec.add(parent.getBonePosX(positionAttachment.getBoneName()), parent.getBonePosY(positionAttachment.getBoneName()));
instance.setPosition(tmpVec.x, tmpVec.y);
}
instance.update(delta);
}
}
for (ParticleEffectInstance instance : removeList) {
particleEffects.removeValue(instance, true);
}
}
use of com.talosvfx.talos.runtime.ParticleEffectInstance in project talos by rockbite.
the class BoundEffect method updateEffect.
public void updateEffect(ParticleEffectDescriptor descriptor) {
particleEffectDescriptor = descriptor;
if (forever) {
particleEffects.clear();
ParticleEffectInstance instance = spawnEffect();
// this is evil
instance.loopable = true;
}
// else this will get auto-spawned on next event call anyway.
}
use of com.talosvfx.talos.runtime.ParticleEffectInstance in project talos by rockbite.
the class BvBWorkspace method drawVFX.
private void drawVFX(Batch batch, float parentAlpha) {
Skeleton skeleton = skeletonContainer.getSkeleton();
if (skeleton == null)
return;
talosRenderer.setBatch(batch);
for (BoundEffect effect : skeletonContainer.getBoundEffects()) {
if (effect.isNested() || effect.isBehind())
continue;
for (ParticleEffectInstance particleEffectInstance : effect.getParticleEffects()) {
talosRenderer.render(particleEffectInstance);
}
}
}
use of com.talosvfx.talos.runtime.ParticleEffectInstance in project HyperLap2D by rednblackgames.
the class TalosContinuousSystem method process.
@Override
protected void process(int entity) {
super.process(entity);
TalosComponent talosComponent = particleComponentMapper.get(entity);
ParticleEffectInstance effect = talosComponent.effect;
if (!effect.isContinuous() && effect.isComplete()) {
effect.restart();
}
}
Aggregations