Search in sources :

Example 1 with TransformComponent

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

the class SceneEditorWorkspace method createSpriteObject.

public GameObject createSpriteObject(FileHandle importedAsset, Vector2 sceneCords, GameObject parent) {
    GameObject spriteObject = createObjectByTypeName("sprite", sceneCords, parent);
    SpriteRendererComponent component = spriteObject.getComponent(SpriteRendererComponent.class);
    component.path = AssetImporter.relative(importedAsset);
    component.reloadTexture();
    TextureRegion texture = component.texture;
    float aspect = (float) texture.getRegionWidth() / texture.getRegionHeight();
    TransformComponent transformComponent = spriteObject.getComponent(TransformComponent.class);
    transformComponent.scale.x *= aspect;
    return spriteObject;
}
Also used : SpriteRendererComponent(com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 2 with TransformComponent

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

the class SceneEditorWorkspace method pasteFromClipboard.

private void pasteFromClipboard() {
    String clipboard = Gdx.app.getClipboard().getContents();
    Json json = new Json();
    try {
        ClipboardPayload payload = json.fromJson(ClipboardPayload.class, clipboard);
        Vector3 camPosAtPaste = getCamera().position;
        Vector2 offset = new Vector2(camPosAtPaste.x, camPosAtPaste.y);
        offset.sub(payload.cameraPositionAtCopy);
        clearSelection();
        for (GameObject gameObject : payload.objects) {
            String name = getUniqueGOName(gameObject.getName(), false);
            gameObject.setName(name);
            currentContainer.addGameObject(gameObject);
            TransformComponent transformComponent = gameObject.getComponent(TransformComponent.class);
            transformComponent.position.add(offset);
            initGizmos(gameObject);
            Notifications.fireEvent(Notifications.obtainEvent(GameObjectCreated.class).setTarget(gameObject));
            addToSelection(gameObject);
        }
        Notifications.fireEvent(Notifications.obtainEvent(GameObjectSelectionChanged.class).set(selection));
    } catch (Exception e) {
    }
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) Vector3(com.badlogic.gdx.math.Vector3) TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent) IOException(java.io.IOException)

Example 3 with TransformComponent

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

the class CameraTransformGizmo method reportResizeUpdated.

@Override
protected void reportResizeUpdated(boolean isRapid) {
    TransformComponent transform = gameObject.getComponent(TransformComponent.class);
    Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(transform, isRapid));
    CameraComponent camera = gameObject.getComponent(CameraComponent.class);
    Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(camera, isRapid));
}
Also used : CameraComponent(com.talosvfx.talos.editor.addons.scene.logic.components.CameraComponent) TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 4 with TransformComponent

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

the class CameraTransformGizmo method transformOldToNew.

@Override
protected void transformOldToNew() {
    TransformComponent transform = gameObject.getComponent(TransformComponent.class);
    CameraComponent cameraComponent = gameObject.getComponent(CameraComponent.class);
    // bring old next points to local space
    for (int i = 0; i < 4; i++) {
        TransformComponent.worldToLocal(gameObject.parent, nextPoints[i]);
    }
    cameraComponent.size.set(nextPoints[RB].dst(nextPoints[LB]), nextPoints[LB].dst(nextPoints[LT]));
    cameraComponent.size = lowerPrecision(cameraComponent.size);
    // this is midpoint
    tmp.set(nextPoints[RT]).sub(nextPoints[LB]).scl(0.5f).add(nextPoints[LB]);
    transform.position = lowerPrecision(transform.position);
}
Also used : CameraComponent(com.talosvfx.talos.editor.addons.scene.logic.components.CameraComponent) TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 5 with TransformComponent

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

the class Gizmo method act.

public void act(float delta) {
    super.act(delta);
    if (gameObject.hasComponent(TransformComponent.class)) {
        TransformComponent transform = gameObject.getComponent(TransformComponent.class);
        tmp.set(0, 0);
        transform.localToWorld(gameObject, tmp);
        setPosition(tmp.x, tmp.y);
    }
}
Also used : TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Aggregations

TransformComponent (com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)19 CameraComponent (com.talosvfx.talos.editor.addons.scene.logic.components.CameraComponent)3 Vector2 (com.badlogic.gdx.math.Vector2)2 SpriteRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent)2 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 Texture (com.badlogic.gdx.graphics.Texture)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector3 (com.badlogic.gdx.math.Vector3)1 SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)1 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)1 SpriteMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.SpriteMetadata)1 IOException (java.io.IOException)1