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;
}
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));
}
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));
}
}
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;
}
}
}
Aggregations