Search in sources :

Example 1 with ParticleComponent

use of com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent in project talos by rockbite.

the class TlsImporter method makeInstance.

@Override
public void makeInstance(FileHandle asset, GameObject parent) {
    if (!AssetImporter.getMetadataHandleFor(asset).exists()) {
        createMetadataFor(asset);
    }
    TlsMetadata metadata = AssetImporter.readMetadataFor(asset, TlsMetadata.class);
    if (asset.extension().equals("tls")) {
        // if p doesnot exist, create it
        FileHandle pHandle = AssetImporter.makeSimilar(asset, "p");
        if (!pHandle.exists()) {
            // create
            exportTlsFile(asset);
        }
        asset = pHandle;
    }
    SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    Vector2 sceneCords = workspace.getMouseCordsOnScene();
    GameObject gameObject = workspace.createObjectByTypeName("particle", sceneCords, parent);
    ParticleComponent component = gameObject.getComponent(ParticleComponent.class);
    component.path = AssetImporter.relative(AssetImporter.makeSimilar(asset, "p").path());
    component.linkedTo = AssetImporter.relative(AssetImporter.makeSimilar(asset, "tls").path());
    component.reloadDescriptor();
}
Also used : ParticleComponent(com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent) SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) Vector2(com.badlogic.gdx.math.Vector2) TlsMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata) FileHandle(com.badlogic.gdx.files.FileHandle) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)1 Vector2 (com.badlogic.gdx.math.Vector2)1 SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)1 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)1 ParticleComponent (com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent)1 TlsMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)1