Search in sources :

Example 11 with ParticleEffectInstance

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();
    }
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance)

Example 12 with ParticleEffectInstance

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);
    }
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance) Color(com.badlogic.gdx.graphics.Color) Slot(com.esotericsoftware.spine.Slot) Bone(com.esotericsoftware.spine.Bone)

Example 13 with ParticleEffectInstance

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.
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance)

Example 14 with ParticleEffectInstance

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);
        }
    }
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance)

Example 15 with 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();
    }
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance) TalosComponent(games.rednblack.h2d.extension.talos.TalosComponent)

Aggregations

ParticleEffectInstance (com.talosvfx.talos.runtime.ParticleEffectInstance)15 Vector2 (com.badlogic.gdx.math.Vector2)3 Color (com.badlogic.gdx.graphics.Color)2 Slot (com.esotericsoftware.spine.Slot)2 NumericalValue (com.talosvfx.talos.runtime.values.NumericalValue)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 Texture (com.badlogic.gdx.graphics.Texture)1 FloatArray (com.badlogic.gdx.utils.FloatArray)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ObjectMap (com.badlogic.gdx.utils.ObjectMap)1 ShortArray (com.badlogic.gdx.utils.ShortArray)1 BlendMode (com.esotericsoftware.spine.BlendMode)1 Bone (com.esotericsoftware.spine.Bone)1 Skeleton (com.esotericsoftware.spine.Skeleton)1 Attachment (com.esotericsoftware.spine.attachments.Attachment)1 ClippingAttachment (com.esotericsoftware.spine.attachments.ClippingAttachment)1 MeshAttachment (com.esotericsoftware.spine.attachments.MeshAttachment)1 RegionAttachment (com.esotericsoftware.spine.attachments.RegionAttachment)1 SkeletonAttachment (com.esotericsoftware.spine.attachments.SkeletonAttachment)1 BoundEffect (com.talosvfx.talos.editor.addons.bvb.BoundEffect)1