Search in sources :

Example 6 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class CameraPreview method drawPreview.

private void drawPreview() {
    SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    GameObject rootGO = workspace.getRootGO();
    MainRenderer renderer = SceneEditorAddon.get().workspace.getRenderer();
    renderer.render(spriteBatch, rootGO);
}
Also used : SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) MainRenderer(com.talosvfx.talos.editor.addons.scene.MainRenderer) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject)

Example 7 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class SpriteImporter method makeInstance.

@Override
public void makeInstance(FileHandle asset, GameObject parent) {
    if (!AssetImporter.getMetadataHandleFor(asset).exists()) {
        createMetadataFor(asset);
    }
    SpriteMetadata metadata = AssetImporter.readMetadataFor(asset, SpriteMetadata.class);
    SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    Vector2 sceneCords = workspace.getMouseCordsOnScene();
    GameObject gameObject = workspace.createSpriteObject(asset, sceneCords, parent);
    if (metadata.borderData != null) {
        SpriteRendererComponent component = gameObject.getComponent(SpriteRendererComponent.class);
        component.renderMode = SpriteRendererComponent.RenderMode.sliced;
    } else {
        if (gameObject.hasComponent(TransformComponent.class)) {
            TransformComponent component = gameObject.getComponent(TransformComponent.class);
            Texture texture = new Texture(asset);
            component.scale.x = texture.getWidth() / metadata.pixelsPerUnit;
            component.scale.y = texture.getHeight() / metadata.pixelsPerUnit;
        }
    }
}
Also used : SpriteRendererComponent(com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent) SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) Vector2(com.badlogic.gdx.math.Vector2) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject) SpriteMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.SpriteMetadata) TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)7 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)5 Vector2 (com.badlogic.gdx.math.Vector2)4 FileHandle (com.badlogic.gdx.files.FileHandle)3 Texture (com.badlogic.gdx.graphics.Texture)1 MainRenderer (com.talosvfx.talos.editor.addons.scene.MainRenderer)1 Prefab (com.talosvfx.talos.editor.addons.scene.logic.Prefab)1 ParticleComponent (com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent)1 SkeletonComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SkeletonComponent)1 SpineRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpineRendererComponent)1 SpriteRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent)1 TransformComponent (com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)1 SpineMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.SpineMetadata)1 SpriteMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.SpriteMetadata)1 TlsMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)1