Search in sources :

Example 11 with GameObject

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

the class SEPropertyPanel method showPanel.

@Override
public void showPanel(IPropertyHolder target, Iterable<IPropertyProvider> propertyProviders) {
    super.showPanel(target, propertyProviders);
    if (target instanceof GameObject) {
        // add part with custom components
        container.row();
        Table table = new Table();
        Label label = new Label("Add Component", TalosMain.Instance().getSkin());
        SquareButton button = new SquareButton(TalosMain.Instance().getSkin(), label);
        button.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                Popup popup = new Popup();
                popup.show(button, (GameObject) target);
            }
        });
        table.add(button).height(30).growX();
        container.add(button).pad(10).growX();
    }
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) SquareButton(com.talosvfx.talos.editor.widgets.ui.common.SquareButton) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 12 with GameObject

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

the class MainRenderer method render.

// todo: do fancier logic later
public void render(Batch batch, GameObject root) {
    updateLayerOrderLookup(root);
    list.clear();
    list = root.getChildrenByComponent(RendererComponent.class, list);
    sort(list);
    for (GameObject gameObject : list) {
        TransformComponent transformComponent = getWorldTransform(gameObject);
        if (gameObject.hasComponent(SpriteRendererComponent.class)) {
            renderSprite(batch, gameObject);
        } else if (gameObject.hasComponent(ParticleComponent.class)) {
            renderParticle(batch, gameObject);
        } else if (gameObject.hasComponent(SpineRendererComponent.class)) {
            renderSpine(batch, gameObject);
        }
    }
}
Also used : GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject)

Example 13 with GameObject

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

the class TransformComponent method worldToLocal.

public static Vector2 worldToLocal(GameObject gameObject, Vector2 vector) {
    if (gameObject.parent == null)
        return vector;
    tmp.clear();
    tmp = getRootChain(gameObject, tmp);
    for (int i = tmp.size - 1; i >= 0; i--) {
        GameObject item = tmp.get(i);
        if (item.hasComponent(TransformComponent.class)) {
            TransformComponent transform = item.getComponent(TransformComponent.class);
            vector.sub(transform.position);
            vector.rotateDeg(-transform.rotation);
            vector.scl(1f / transform.scale.x, 1f / transform.scale.y);
        }
    }
    return vector;
}
Also used : GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject)

Example 14 with GameObject

use of com.talosvfx.talos.editor.addons.scene.logic.GameObject 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

GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)14 Vector2 (com.badlogic.gdx.math.Vector2)5 SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)5 Array (com.badlogic.gdx.utils.Array)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 Prefab (com.talosvfx.talos.editor.addons.scene.logic.Prefab)2 SpriteRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent)2 EventHandler (com.talosvfx.talos.editor.notifications.EventHandler)2 FilteredTree (com.talosvfx.talos.editor.widgets.ui.FilteredTree)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 Texture (com.badlogic.gdx.graphics.Texture)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 XmlReader (com.badlogic.gdx.utils.XmlReader)1 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)1 PopupMenu (com.kotcrab.vis.ui.widget.PopupMenu)1 MainRenderer (com.talosvfx.talos.editor.addons.scene.MainRenderer)1 ComponentUpdated (com.talosvfx.talos.editor.addons.scene.events.ComponentUpdated)1 ParticleComponent (com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent)1