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