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;
}
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);
}
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;
}
}
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;
}
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;
}
}
Aggregations