Search in sources :

Example 16 with TransformComponent

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

the class SmartTransformGizmo method applyRotationChange.

private void applyRotationChange(float x, float y) {
    // midpoint
    tmp.set(points[RT]).sub(points[LB]).scl(0.5f).add(points[LB]);
    tmp2.set(prevDragLocation).sub(tmp);
    tmp3.set(x, y).sub(tmp);
    float a1 = tmp2.angleDeg();
    float a2 = tmp3.angleDeg();
    float angleDiff = a2 - a1;
    TransformComponent transform = gameObject.getComponent(TransformComponent.class);
    transform.rotation += angleDiff;
}
Also used : TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 17 with TransformComponent

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

the class TransformGizmo method touchDragged.

@Override
public void touchDragged(float x, float y) {
    tmp.set(x, y).sub(prevTouch);
    // render position
    TransformComponent transform = gameObject.getComponent(TransformComponent.class);
    vec1.set(0, 0);
    transform.localToWorld(gameObject.parent, vec1);
    // change diff
    vec1.add(tmp);
    transform.worldToLocal(gameObject.parent, vec1);
    // vec1 is diff
    transform.position.add(vec1);
    prevTouch.set(x, y);
    wasDragged = true;
    Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(transform, true));
}
Also used : TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 18 with TransformComponent

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

the class TransformGizmo method touchUp.

@Override
public void touchUp(float x, float y) {
    if (wasDragged) {
        TransformComponent transform = gameObject.getComponent(TransformComponent.class);
        Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(transform));
    }
}
Also used : TransformComponent(com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)

Example 19 with TransformComponent

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

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