use of com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent in project talos by rockbite.
the class SceneEditorWorkspace method createObjectByTypeName.
public GameObject createObjectByTypeName(String idName, Vector2 position, GameObject parent) {
GameObject gameObject = new GameObject();
XmlReader.Element template = templateListPopup.getTemplate(idName);
String name = getUniqueGOName(template.getAttribute("nameTemplate", "gameObject"), true);
gameObject.setName(name);
initComponentsFromTemplate(gameObject, templateListPopup.getTemplate(idName));
if (position != null && gameObject.hasComponent(TransformComponent.class)) {
// oh boi always special case with this fuckers
TransformComponent transformComponent = gameObject.getComponent(TransformComponent.class);
transformComponent.position.set(position.x, position.y);
}
if (parent == null) {
currentContainer.addGameObject(gameObject);
} else {
parent.addGameObject(gameObject);
}
initGizmos(gameObject);
Notifications.fireEvent(Notifications.obtainEvent(GameObjectCreated.class).setTarget(gameObject));
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
selectGameObjectExternally(gameObject);
}
});
return gameObject;
}
use of com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent in project talos by rockbite.
the class SceneEditorWorkspace method createFromPrefab.
public GameObject createFromPrefab(Prefab prefab, Vector2 position, GameObject parent) {
GameObject gameObject = prefab.root;
String name = getUniqueGOName(prefab.name, true);
gameObject.setName(name);
if (position != null && gameObject.hasComponent(TransformComponent.class)) {
TransformComponent transformComponent = gameObject.getComponent(TransformComponent.class);
transformComponent.position.set(position.x, position.y);
transformComponent.rotation = 0;
transformComponent.scale.set(1, 1);
}
if (parent == null) {
currentContainer.addGameObject(gameObject);
} else {
parent.addGameObject(gameObject);
}
initGizmos(gameObject);
Notifications.fireEvent(Notifications.obtainEvent(GameObjectCreated.class).setTarget(gameObject));
selectGameObjectExternally(gameObject);
return gameObject;
}
use of com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent in project talos by rockbite.
the class Gizmo method getTransformPosition.
public Vector2 getTransformPosition(Vector2 pos) {
if (gameObject.hasComponent(TransformComponent.class)) {
TransformComponent transformComponent = gameObject.getComponent(TransformComponent.class);
pos.set(transformComponent.position);
return pos;
} else {
pos.set(0, 0);
}
return pos;
}
use of com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent in project talos by rockbite.
the class SmartTransformGizmo method transformOldToNew.
protected void transformOldToNew() {
TransformComponent transform = gameObject.getComponent(TransformComponent.class);
float xDiff = getPintsAngle(nextPoints[RT], nextPoints[LT]) - getPintsAngle(prevPoints[RT], prevPoints[LT]);
float yDiff = getPintsAngle(nextPoints[LT], nextPoints[LB]) - getPintsAngle(prevPoints[LT], prevPoints[LB]);
// bring old next points to local space
for (int i = 0; i < 4; i++) {
TransformComponent.worldToLocal(gameObject.parent, nextPoints[i]);
}
float xSign = transform.scale.x < 0 ? -1 : 1;
float ySign = transform.scale.y < 0 ? -1 : 1;
transform.scale.set(nextPoints[RB].dst(nextPoints[LB]) * xSign, nextPoints[LB].dst(nextPoints[LT]) * ySign);
if (xDiff != 0) {
transform.scale.x = transform.scale.x * -1f;
}
if (yDiff != 0) {
transform.scale.y = transform.scale.y * -1f;
}
transform.scale = lowerPrecision(transform.scale);
// this is midpoint
tmp.set(nextPoints[RT]).sub(nextPoints[LB]).scl(0.5f).add(nextPoints[LB]);
if (!Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) {
// lol, this is a funny story actually
transform.position.set(tmp);
}
transform.position = lowerPrecision(transform.position);
}
use of com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent in project talos by rockbite.
the class SmartTransformGizmo method reportResizeUpdated.
protected void reportResizeUpdated(boolean isRapid) {
TransformComponent transform = gameObject.getComponent(TransformComponent.class);
Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(transform, isRapid));
}
Aggregations