Search in sources :

Example 1 with ParticleEffectDescriptor

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

the class TalosVFXAsset method exportAsset.

@Override
public boolean exportAsset(MainItemVO item, ExportMapperVO exportMapperVO, File tmpDir) throws IOException {
    super.exportAsset(item, exportMapperVO, tmpDir);
    TalosVO talosVO = (TalosVO) item;
    File fileSrc = new File(currentProjectPath + ProjectManager.TALOS_VFX_DIR_PATH + File.separator + talosVO.particleName);
    FileUtils.copyFileToDirectory(fileSrc, tmpDir);
    exportMapperVO.mapper.add(new ExportMapperVO.ExportedAsset(AssetsUtils.TYPE_TALOS_VFX, fileSrc.getName()));
    ParticleEffectDescriptor particleEffect = resourceManager.getProjectTalosList().get(talosVO.particleName);
    for (ParticleEmitterDescriptor emitter : new Array.ArrayIterator<>(particleEffect.emitterModuleGraphs)) {
        for (AbstractModule module : new Array.ArrayIterator<>(emitter.getModules())) {
            if (module instanceof TextureModule) {
                String path = ((TextureModule) module).regionName + ".png";
                File f = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + path);
                FileUtils.copyFileToDirectory(f, tmpDir);
            }
            if (module instanceof PolylineModule) {
                String path = ((PolylineModule) module).regionName + ".png";
                File f = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + path);
                FileUtils.copyFileToDirectory(f, tmpDir);
            }
            if (module instanceof FlipbookModule) {
                String path = ((FlipbookModule) module).regionName + ".png";
                File f = new File(currentProjectPath + ProjectManager.IMAGE_DIR_PATH + File.separator + path);
                FileUtils.copyFileToDirectory(f, tmpDir);
            }
            if (module instanceof ShadedSpriteModule) {
                String path = ((ShadedSpriteModule) module).shdrFileName;
                File f = new File(currentProjectPath + ProjectManager.TALOS_VFX_DIR_PATH + File.separator + path);
                FileUtils.copyFileToDirectory(f, tmpDir);
            }
        }
    }
    return true;
}
Also used : TalosVO(games.rednblack.h2d.extension.talos.TalosVO) ParticleEmitterDescriptor(com.talosvfx.talos.runtime.ParticleEmitterDescriptor) ExportMapperVO(games.rednblack.h2d.common.vo.ExportMapperVO) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) File(java.io.File)

Example 2 with ParticleEffectDescriptor

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

the class BvBWorkspace method updateParticle.

public void updateParticle(FileHandle handle) {
    String name = handle.nameWithoutExtension();
    if (vfxLibrary.containsKey(name)) {
        ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
        descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
        descriptor.load(handle);
        vfxLibrary.put(name, descriptor);
        skeletonContainer.updateEffect(name, descriptor);
    }
}
Also used : ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor)

Example 3 with ParticleEffectDescriptor

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

the class ParticleComponent method reloadDescriptor.

public void reloadDescriptor() {
    FileHandle handle = AssetImporter.get(path);
    if (handle.exists() && handle.extension().equals("p")) {
        try {
            descriptor = new ParticleEffectDescriptor();
            descriptor.setAssetProvider(SceneEditorAddon.get().assetProvider);
            descriptor.load(handle);
        } catch (Exception e) {
        }
    } else {
        // load default
        descriptor = new ParticleEffectDescriptor();
        descriptor.setAssetProvider(SceneEditorAddon.get().assetProvider);
        descriptor.load(Gdx.files.internal("addons/scene/missing/sample.p"));
    }
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor)

Example 4 with ParticleEffectDescriptor

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

the class TalosProject method cleanData.

private void cleanData() {
    TalosMain.Instance().UIStage().PreviewWidget().resetToDefaults();
    TalosMain.Instance().NodeStage().moduleBoardWidget.clearAll();
    activeWrappers.clear();
    particleEffectDescriptor = new ParticleEffectDescriptor();
    particleEffectDescriptor.setAssetProvider(projectAssetProvider);
    particleEffect = new ParticleEffectInstance(particleEffectDescriptor);
    particleEffect.setScope(TalosMain.Instance().globalScope);
    particleEffect.loopable = true;
}
Also used : ParticleEffectInstance(com.talosvfx.talos.runtime.ParticleEffectInstance) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor)

Example 5 with ParticleEffectDescriptor

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

the class BoundEffect method read.

@Override
public void read(Json json, JsonValue jsonData) {
    String effectName = jsonData.getString("effectName");
    String effectPath = parent.getWorkspace().getPath(effectName + ".p");
    FileHandle effectHandle = TalosMain.Instance().ProjectController().findFile(effectPath);
    this.name = effectName;
    if (effectHandle == null || !effectHandle.exists()) {
        throw new GdxRuntimeException("Particle effect not found");
    }
    parent.getWorkspace().registerTalosAssets(effectHandle);
    // TODO: refactor this
    ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
    descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
    descriptor.load(effectHandle);
    parent.getWorkspace().getVfxLibrary().put(name, descriptor);
    // track this file
    TalosMain.Instance().FileTracker().trackFile(effectHandle, parent.getWorkspace().bvb.particleTracker);
    this.particleEffectDescriptor = descriptor;
    positionAttachment = json.readValue(AttachmentPoint.class, jsonData.get("positionAttachment"));
    JsonValue valueAttachmentsJson = jsonData.get("valueAttachments");
    for (JsonValue valueAttachmentJson : valueAttachmentsJson) {
        AttachmentPoint point = json.readValue(AttachmentPoint.class, valueAttachmentJson);
        valueAttachments.add(point);
    }
    setStartEvent(jsonData.getString("startEvent", ""));
    setCompleteEvent(jsonData.getString("completeEvent", ""));
    isStandalone = jsonData.getBoolean("isStandalone", false);
    isBehind = jsonData.getBoolean("isBehind");
    isNested = jsonData.getBoolean("isNested");
// setForever(startEvent.equals("") && completeEvent.equals(""));
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) FileHandle(com.badlogic.gdx.files.FileHandle) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) JsonValue(com.badlogic.gdx.utils.JsonValue)

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