Search in sources :

Example 6 with ParticleEffectDescriptor

use of com.talosvfx.talos.runtime.ParticleEffectDescriptor in project talos by rockbite.

the class BvBWorkspace method addParticle.

public BoundEffect addParticle(FileHandle handle) {
    if (skeletonContainer.getSkeleton() == null)
        return null;
    pathMap.put(handle.name(), handle.path());
    registerTalosAssets(handle);
    String name = handle.nameWithoutExtension();
    ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
    descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
    descriptor.load(handle);
    vfxLibrary.put(name, descriptor);
    BoundEffect effect = skeletonContainer.addEffect(name, descriptor);
    effect.setPositionAttachment(skeletonContainer.getSkeleton().getRootBone().toString());
    bvb.getTimeline().updateEffectList(skeletonContainer.getBoundEffects());
    TalosMain.Instance().ProjectController().setDirty();
    return effect;
}
Also used : ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor)

Example 7 with ParticleEffectDescriptor

use of com.talosvfx.talos.runtime.ParticleEffectDescriptor in project talos by rockbite.

the class ParticleControlTest method create.

@Override
public void create() {
    orthographicCamera = new OrthographicCamera();
    float width = 2000f;
    float aspect = (float) Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight();
    orthographicCamera.setToOrtho(false, width, width / aspect);
    shapeRenderer = new ShapeRenderer();
    batch = new SpriteBatch();
    particleRenderer = new SpriteBatchParticleRenderer(batch);
    cameraController = new CameraController(orthographicCamera);
    ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
    TextureAtlas atlas = new TextureAtlas();
    atlas.addRegion("fire", new TextureRegion(new TextureRegion(new Texture(Gdx.files.internal("fire.png")))));
    descriptor.setAssetProvider(new TestAssetProvider(atlas));
    descriptor.load(Gdx.files.internal("test.p"));
    particleEffectInstance = descriptor.createEffectInstance();
    particleEffectInstance.loopable = true;
    stage = new Stage();
    VisUI.load();
    VisTextButton start = new VisTextButton("Start/Resume");
    VisTextButton pause = new VisTextButton("Pause");
    VisTextButton restart = new VisTextButton("Restart");
    VisTextButton allowCompletion = new VisTextButton("Allow Completion");
    start.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.resume();
        }
    });
    pause.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.pause();
        }
    });
    restart.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.restart();
        }
    });
    allowCompletion.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.allowCompletion();
        }
    });
    Table table = new Table();
    table.setFillParent(true);
    table.defaults().pad(10).top().left();
    table.top().left();
    table.add(start);
    table.row();
    table.add(pause);
    table.row();
    table.add(restart);
    table.row();
    table.add(allowCompletion);
    stage.addActor(table);
    Gdx.input.setInputProcessor(new InputMultiplexer(stage, cameraController));
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) CameraController(com.talosvfx.talos.runtime.test.utils.CameraController) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) TestAssetProvider(com.talosvfx.talos.runtime.test.utils.TestAssetProvider) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Stage(com.badlogic.gdx.scenes.scene2d.Stage) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) SpriteBatchParticleRenderer(com.talosvfx.talos.runtime.render.SpriteBatchParticleRenderer)

Example 8 with ParticleEffectDescriptor

use of com.talosvfx.talos.runtime.ParticleEffectDescriptor in project talos by rockbite.

the class TalosDemo method create.

@Override
public void create() {
    /**
     * We need a viewport for proper camerawork
     */
    viewport = new FitViewport(10f, 10f);
    viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    /**
     * We may need polygon sprite batch to render more complex VFX such us beams
     */
    batch = new PolygonSpriteBatch();
    /**
     * Prepare the texture atlas.
     * Normally just load Texture Atlas,  but for the sake of demo this will be creating fake atlas from just one texture.
     */
    TextureRegion textureRegion = new TextureRegion(new Texture(Gdx.files.internal("fire.png")));
    TextureAtlas textureAtlas = new TextureAtlas();
    textureAtlas.addRegion("fire", textureRegion);
    /**
     * Creating particle effect instance from particle effect descriptor
     */
    ParticleEffectDescriptor effectDescriptor = new ParticleEffectDescriptor(Gdx.files.internal("fire.p"), textureAtlas);
    effect = effectDescriptor.createEffectInstance();
    defaultRenderer = new SpriteBatchParticleRenderer();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) PolygonSpriteBatch(com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) FitViewport(com.badlogic.gdx.utils.viewport.FitViewport) SpriteBatchParticleRenderer(com.talosvfx.talos.runtime.render.SpriteBatchParticleRenderer)

Example 9 with ParticleEffectDescriptor

use of com.talosvfx.talos.runtime.ParticleEffectDescriptor in project HyperLap2D by rednblackgames.

the class ResourceManager method loadCurrentProjectTalosVFXs.

private void loadCurrentProjectTalosVFXs(String path) {
    talosVFXs.clear();
    talosResPath = path;
    FileHandle sourceDir = new FileHandle(path);
    for (FileHandle entry : sourceDir.list()) {
        File file = entry.file();
        String filename = file.getName();
        if (file.isDirectory() || filename.endsWith(".DS_Store") || !filename.endsWith("p"))
            continue;
        ResourceRetrieverAssetProvider assetProvider = new ResourceRetrieverAssetProvider(this);
        assetProvider.setAssetHandler(ShaderDescriptor.class, this::findShaderDescriptorOnLoad);
        assetProvider.setAssetHandler(VectorField.class, this::findVectorFieldDescriptorOnLoad);
        ParticleEffectDescriptor effectDescriptor = new ParticleEffectDescriptor();
        effectDescriptor.setAssetProvider(assetProvider);
        effectDescriptor.load(Gdx.files.internal(file.getAbsolutePath()));
        talosVFXs.put(filename, effectDescriptor);
    }
}
Also used : ResourceRetrieverAssetProvider(games.rednblack.h2d.extension.talos.ResourceRetrieverAssetProvider) FileHandle(com.badlogic.gdx.files.FileHandle) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) File(java.io.File)

Aggregations

ParticleEffectDescriptor (com.talosvfx.talos.runtime.ParticleEffectDescriptor)9 FileHandle (com.badlogic.gdx.files.FileHandle)3 Texture (com.badlogic.gdx.graphics.Texture)2 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 SpriteBatchParticleRenderer (com.talosvfx.talos.runtime.render.SpriteBatchParticleRenderer)2 File (java.io.File)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PolygonSpriteBatch (com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 FitViewport (com.badlogic.gdx.utils.viewport.FitViewport)1 VisTextButton (com.kotcrab.vis.ui.widget.VisTextButton)1