Search in sources :

Example 1 with ModuleWrapper

use of com.talosvfx.talos.editor.wrappers.ModuleWrapper in project talos by rockbite.

the class ModuleWrapperGroup method recalculateTransform.

private void recalculateTransform() {
    posMin.set(wrappers.first().getX(), wrappers.first().getY());
    posMax.set(wrappers.first().getX() + wrappers.first().getWidth(), wrappers.first().getY() + wrappers.first().getHeight());
    for (ModuleWrapper wrapper : wrappers) {
        if (wrapper.getX() < posMin.x)
            posMin.x = wrapper.getX();
        if (wrapper.getY() < posMin.y)
            posMin.y = wrapper.getY();
        if (wrapper.getX() + wrapper.getWidth() > posMax.x)
            posMax.x = wrapper.getX() + wrapper.getWidth();
        if (wrapper.getY() + wrapper.getHeight() > posMax.y)
            posMax.y = wrapper.getY() + wrapper.getHeight();
    }
    pos.set(posMin).sub(PADDING, PADDING);
    size.set(posMax).sub(posMin).add(PADDING * 2, PADDING * 2);
}
Also used : ModuleWrapper(com.talosvfx.talos.editor.wrappers.ModuleWrapper)

Example 2 with ModuleWrapper

use of com.talosvfx.talos.editor.wrappers.ModuleWrapper in project talos by rockbite.

the class TalosProject method setToExportData.

private void setToExportData(ExportData data, ModuleBoardWidget moduleBoardWidget) {
    final ObjectMap<ParticleEmitterWrapper, Array<ModuleWrapper>> moduleWrappers = moduleBoardWidget.moduleWrappers;
    final ObjectMap<ParticleEmitterWrapper, Array<ModuleBoardWidget.NodeConnection>> nodeConnections = moduleBoardWidget.nodeConnections;
    for (ParticleEmitterWrapper key : moduleWrappers.keys()) {
        final ExportData.EmitterExportData emitterData = new ExportData.EmitterExportData();
        emitterData.name = key.getName();
        for (ModuleWrapper wrapper : moduleWrappers.get(key)) {
            emitterData.modules.add(wrapper.getModule());
            if (wrapper.getModule() instanceof TextureModule) {
                TextureModule textureModule = (TextureModule) wrapper.getModule();
                String name = textureModule.regionName;
                if (name == null)
                    name = "fire";
                if (!data.metadata.resources.contains(name, false)) {
                    data.metadata.resources.add(name);
                }
            }
            if (wrapper.getModule() instanceof PolylineModule) {
                PolylineModule module = (PolylineModule) wrapper.getModule();
                String name = module.regionName;
                if (name == null)
                    name = "fire";
                if (!data.metadata.resources.contains(name, false)) {
                    data.metadata.resources.add(name);
                }
            }
            if (wrapper.getModule() instanceof VectorFieldModule) {
                VectorFieldModule vectorFieldModule = (VectorFieldModule) wrapper.getModule();
                String fgaFileName = vectorFieldModule.fgaFileName;
                if (fgaFileName == null) {
                    return;
                }
                fgaFileName = fgaFileName + ".fga";
                if (!data.metadata.resources.contains(fgaFileName, false)) {
                    data.metadata.resources.add(fgaFileName);
                }
            }
        }
        final Array<ModuleBoardWidget.NodeConnection> nodeConns = nodeConnections.get(key);
        if (nodeConns != null) {
            for (ModuleBoardWidget.NodeConnection nodeConn : nodeConns) {
                emitterData.connections.add(new ConnectionData(nodeConn.fromModule.getModule().getIndex(), nodeConn.toModule.getModule().getIndex(), nodeConn.fromSlot, nodeConn.toSlot));
            }
        }
        data.emitters.add(emitterData);
    }
}
Also used : TextureModule(com.talosvfx.talos.runtime.modules.TextureModule) VectorFieldModule(com.talosvfx.talos.runtime.modules.VectorFieldModule) Array(com.badlogic.gdx.utils.Array) PolylineModule(com.talosvfx.talos.runtime.modules.PolylineModule) ModuleBoardWidget(com.talosvfx.talos.editor.widgets.ui.ModuleBoardWidget) ModuleWrapper(com.talosvfx.talos.editor.wrappers.ModuleWrapper) ExportData(com.talosvfx.talos.runtime.serialization.ExportData) ConnectionData(com.talosvfx.talos.runtime.serialization.ConnectionData) ParticleEmitterWrapper(com.talosvfx.talos.editor.ParticleEmitterWrapper)

Example 3 with ModuleWrapper

use of com.talosvfx.talos.editor.wrappers.ModuleWrapper 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 4 with ModuleWrapper

use of com.talosvfx.talos.editor.wrappers.ModuleWrapper in project talos by rockbite.

the class ProjectData method setFrom.

public void setFrom(ModuleBoardWidget moduleBoardWidget) {
    final ObjectMap<ParticleEmitterWrapper, Array<ModuleWrapper>> moduleWrappers = moduleBoardWidget.moduleWrappers;
    final ObjectMap<ParticleEmitterWrapper, Array<ModuleBoardWidget.NodeConnection>> nodeConnections = moduleBoardWidget.nodeConnections;
    emitters.clear();
    for (ParticleEmitterWrapper key : moduleWrappers.keys()) {
        final EmitterData emitterData = new EmitterData();
        emitterData.name = key.getName();
        emitterData.sortPosition = key.getEmitter().getSortPosition();
        emitterData.modules.addAll(moduleWrappers.get(key));
        emitterData.isMuted = key.isMuted;
        final Array<ModuleBoardWidget.NodeConnection> nodeConns = nodeConnections.get(key);
        if (nodeConns != null) {
            for (ModuleBoardWidget.NodeConnection nodeConn : nodeConns) {
                emitterData.connections.add(new ConnectionData(nodeConn.fromModule.getId(), nodeConn.toModule.getId(), nodeConn.fromSlot, nodeConn.toSlot));
            }
        }
        // add groups
        for (ModuleWrapperGroup group : moduleBoardWidget.getGroups(key)) {
            GroupData groupData = new GroupData();
            groupData.text = group.getText();
            groupData.modules = new Array<>();
            groupData.color = group.getFrameColor().toFloatBits();
            for (ModuleWrapper wrapper : group.getModuleWrappers()) {
                groupData.modules.add(wrapper.getId());
            }
            emitterData.groups.add(groupData);
        }
        emitters.add(emitterData);
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) ModuleBoardWidget(com.talosvfx.talos.editor.widgets.ui.ModuleBoardWidget) ModuleWrapper(com.talosvfx.talos.editor.wrappers.ModuleWrapper) ConnectionData(com.talosvfx.talos.runtime.serialization.ConnectionData) ParticleEmitterWrapper(com.talosvfx.talos.editor.ParticleEmitterWrapper) ModuleWrapperGroup(com.talosvfx.talos.editor.data.ModuleWrapperGroup)

Aggregations

ModuleWrapper (com.talosvfx.talos.editor.wrappers.ModuleWrapper)4 ParticleEmitterWrapper (com.talosvfx.talos.editor.ParticleEmitterWrapper)3 Array (com.badlogic.gdx.utils.Array)2 ModuleWrapperGroup (com.talosvfx.talos.editor.data.ModuleWrapperGroup)2 ModuleBoardWidget (com.talosvfx.talos.editor.widgets.ui.ModuleBoardWidget)2 ConnectionData (com.talosvfx.talos.runtime.serialization.ConnectionData)2 Color (com.badlogic.gdx.graphics.Color)1 IntMap (com.badlogic.gdx.utils.IntMap)1 ObjectSet (com.badlogic.gdx.utils.ObjectSet)1 ParticleEmitterDescriptor (com.talosvfx.talos.runtime.ParticleEmitterDescriptor)1 PolylineModule (com.talosvfx.talos.runtime.modules.PolylineModule)1 TextureModule (com.talosvfx.talos.runtime.modules.TextureModule)1 VectorFieldModule (com.talosvfx.talos.runtime.modules.VectorFieldModule)1 ExportData (com.talosvfx.talos.runtime.serialization.ExportData)1