use of com.talosvfx.talos.editor.ParticleEmitterWrapper 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);
}
}
use of com.talosvfx.talos.editor.ParticleEmitterWrapper in project talos by rockbite.
the class TalosProject method estimateTotalEffectDuration.
public float estimateTotalEffectDuration() {
Array<ParticleEmitterWrapper> activeWrappers = getActiveWrappers();
if (particleEffectDescriptor.isContinuous()) {
float maxWindow = 0;
for (ParticleEmitterWrapper wrapper : activeWrappers) {
if (wrapper.getEmitter().getEmitterModule() != null) {
float duration = wrapper.getEmitter().getEmitterModule().getDuration();
float totalWaitTime = duration;
if (maxWindow < totalWaitTime) {
maxWindow = totalWaitTime;
}
}
}
return maxWindow;
} else {
float furthestPoint = 0;
for (ParticleEmitterWrapper wrapper : activeWrappers) {
if (wrapper.getEmitter().getEmitterModule() != null && wrapper.getEmitter().getParticleModule() != null) {
float delay = wrapper.getEmitter().getEmitterModule().getDelay();
float duration = wrapper.getEmitter().getEmitterModule().getDuration();
float life = wrapper.getEmitter().getParticleModule().getLife();
float point = delay + duration + life;
if (furthestPoint < point) {
furthestPoint = point;
}
}
}
return furthestPoint;
}
}
use of com.talosvfx.talos.editor.ParticleEmitterWrapper 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);
}
use of com.talosvfx.talos.editor.ParticleEmitterWrapper in project talos by rockbite.
the class TalosProject method loadEmitter.
public ParticleEmitterWrapper loadEmitter(String emitterName, int sortPosition) {
ParticleEmitterWrapper emitterWrapper = initEmitter(emitterName);
activeWrappers.add(emitterWrapper);
currentEmitterWrapper = emitterWrapper;
emitterWrapper.getEmitter().setSortPosition(sortPosition);
emitterWrapper.setPosition(sortPosition);
TalosMain.Instance().NodeStage().moduleBoardWidget.setCurrentEmitter(currentEmitterWrapper);
return emitterWrapper;
}
use of com.talosvfx.talos.editor.ParticleEmitterWrapper in project talos by rockbite.
the class EmitterList method moveItemSorting.
private void moveItemSorting(float moveBy) {
ParticleEmitterWrapper selectedItem = getSelectedItem();
if (selectedItem != null) {
float sortPosition = selectedItem.getEmitter().getSortPosition() + moveBy;
selectedItem.setPosition(sortPosition);
TalosMain.Instance().TalosProject().sortEmitters();
Array<ParticleEmitterWrapper> activeWrappers = TalosMain.Instance().TalosProject().getActiveWrappers();
// activeWrappers.reverse();
setData(activeWrappers);
setSelected(selectedItem);
}
}
Aggregations