Search in sources :

Example 1 with ParticleEmitterDescriptor

use of com.talosvfx.talos.runtime.ParticleEmitterDescriptor 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 ParticleEmitterDescriptor

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

the class TalosProject method loadProject.

public void loadProject(FileHandle projectFileHandle, String data, boolean fromMemory) {
    TalosMain.Instance().UIStage().PreviewWidget().getGLProfiler().reset();
    cleanData();
    projectSerializer.prereadhack(data);
    projectData = projectSerializer.read(data);
    readMetaData = projectData.metaData;
    ParticleEmitterWrapper firstEmitter = null;
    for (EmitterData emitterData : projectData.getEmitters()) {
        IntMap<ModuleWrapper> map = new IntMap<>();
        ParticleEmitterWrapper emitterWrapper = loadEmitter(emitterData.name, emitterData.sortPosition);
        TalosMain.Instance().NodeStage().moduleBoardWidget.loadEmitterToBoard(emitterWrapper, emitterData);
        final ParticleEmitterDescriptor graph = emitterWrapper.getGraph();
        for (ModuleWrapper module : emitterData.modules) {
            map.put(module.getId(), module);
            graph.addModule(module.getModule());
            module.getModule().setModuleGraph(graph);
        }
        // important
        particleEffectDescriptor.setEffectReference(particleEffect);
        particleEffectDescriptor.addEmitter(graph);
        particleEffect.init();
        // configure emitter visibility
        emitterWrapper.isMuted = emitterData.isMuted;
        particleEffect.getEmitter(emitterWrapper.getGraph()).setVisible(!emitterData.isMuted);
        // time to load groups here
        for (GroupData group : emitterData.groups) {
            ObjectSet<ModuleWrapper> childWrappers = new ObjectSet<>();
            for (Integer id : group.modules) {
                if (map.get(id) != null) {
                    childWrappers.add(map.get(id));
                }
            }
            ModuleWrapperGroup moduleWrapperGroup = TalosMain.Instance().NodeStage().moduleBoardWidget.createGroupForWrappers(childWrappers);
            Color clr = new Color();
            Color.abgr8888ToColor(clr, group.color);
            moduleWrapperGroup.setData(group.text, clr);
        }
    }
    sortEmitters();
    if (activeWrappers.size > 0) {
        firstEmitter = activeWrappers.first();
    }
    if (firstEmitter != null) {
        TalosMain.Instance().TalosProject().setCurrentEmitterWrapper(firstEmitter);
        TalosMain.Instance().NodeStage().moduleBoardWidget.setCurrentEmitter(firstEmitter);
    }
    TalosMain.Instance().UIStage().setEmitters(activeWrappers);
    TalosMain.Instance().NodeStage().getStage().setKeyboardFocus(null);
}
Also used : ParticleEmitterDescriptor(com.talosvfx.talos.runtime.ParticleEmitterDescriptor) Color(com.badlogic.gdx.graphics.Color) IntMap(com.badlogic.gdx.utils.IntMap) ModuleWrapper(com.talosvfx.talos.editor.wrappers.ModuleWrapper) ObjectSet(com.badlogic.gdx.utils.ObjectSet) ParticleEmitterWrapper(com.talosvfx.talos.editor.ParticleEmitterWrapper) ModuleWrapperGroup(com.talosvfx.talos.editor.data.ModuleWrapperGroup)

Example 3 with ParticleEmitterDescriptor

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

the class BoundEffect method getDurationTwo.

@Override
public float getDurationTwo() {
    if (particleEffectDescriptor.isContinuous()) {
        return BvBWorkspace.getInstance().getSkeletonContainer().getCurrentAnimation().getDuration();
    } else {
        float maxLife = 0;
        Array<ParticleEmitterDescriptor> emitterModuleGraphs = particleEffectDescriptor.emitterModuleGraphs;
        if (particleEffectDescriptor.getInstanceReference() == null)
            return 0;
        for (ParticleEmitterDescriptor descriptor : emitterModuleGraphs) {
            float life = descriptor.getParticleModule().getLife();
            if (maxLife < life) {
                maxLife = life;
            }
        }
        return maxLife;
    }
}
Also used : ParticleEmitterDescriptor(com.talosvfx.talos.runtime.ParticleEmitterDescriptor)

Example 4 with ParticleEmitterDescriptor

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

the class TalosProject method initEmitter.

private ParticleEmitterWrapper initEmitter(String emitterName) {
    ParticleEmitterWrapper emitterWrapper = new ParticleEmitterWrapper();
    emitterWrapper.setName(emitterName);
    ParticleEmitterDescriptor moduleGraph = TalosMain.Instance().TalosProject().particleEffectDescriptor.createEmitterDescriptor();
    emitterWrapper.setModuleGraph(moduleGraph);
    // particleEffect.addAdvancedEmitter(moduleGraph);
    particleEffect.addEmitter(moduleGraph);
    return emitterWrapper;
}
Also used : ParticleEmitterDescriptor(com.talosvfx.talos.runtime.ParticleEmitterDescriptor) ParticleEmitterWrapper(com.talosvfx.talos.editor.ParticleEmitterWrapper)

Example 5 with ParticleEmitterDescriptor

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

the class BoundEffect method getDurationOne.

@Override
public float getDurationOne() {
    if (particleEffectDescriptor.isContinuous()) {
        return BvBWorkspace.getInstance().getSkeletonContainer().getCurrentAnimation().getDuration();
    } else {
        float maxDuration = 0;
        Array<ParticleEmitterDescriptor> emitterModuleGraphs = particleEffectDescriptor.emitterModuleGraphs;
        if (particleEffectDescriptor.getInstanceReference() == null)
            return 0;
        for (ParticleEmitterDescriptor descriptor : emitterModuleGraphs) {
            float duration = descriptor.getEmitterModule().getDuration();
            if (maxDuration < duration) {
                maxDuration = duration;
            }
        }
        return maxDuration;
    }
}
Also used : ParticleEmitterDescriptor(com.talosvfx.talos.runtime.ParticleEmitterDescriptor)

Aggregations

ParticleEmitterDescriptor (com.talosvfx.talos.runtime.ParticleEmitterDescriptor)5 ParticleEmitterWrapper (com.talosvfx.talos.editor.ParticleEmitterWrapper)2 Color (com.badlogic.gdx.graphics.Color)1 IntMap (com.badlogic.gdx.utils.IntMap)1 ObjectSet (com.badlogic.gdx.utils.ObjectSet)1 ModuleWrapperGroup (com.talosvfx.talos.editor.data.ModuleWrapperGroup)1 ModuleWrapper (com.talosvfx.talos.editor.wrappers.ModuleWrapper)1 ParticleEffectDescriptor (com.talosvfx.talos.runtime.ParticleEffectDescriptor)1 ExportMapperVO (games.rednblack.h2d.common.vo.ExportMapperVO)1 TalosVO (games.rednblack.h2d.extension.talos.TalosVO)1 File (java.io.File)1