From 31a6f5e0c44890371c53633c85ff63a066e1bf23 Mon Sep 17 00:00:00 2001 From: Tom Wojciechowski Date: Thu, 3 Oct 2024 19:42:18 +0100 Subject: [PATCH] Add transform and bone debug for world an dlocation transforms when we have a BoneCOmponent Add editor timescale property for testing animation speeds in editor Rotate inital velocity by the effect velocity --- .../BoneComponentProvider.java | 21 ++++++++ .../GameObjectPropertyHolder.java | 54 +++++++++---------- .../SpineComponentProvider.java | 8 +++ .../TransformComponentProvider.java | 7 +++ .../propertyWidgets/PropertyWidget.java | 15 ++++++ .../components/SpineRendererComponent.java | 3 ++ .../talosvfx/talos/runtime/vfx/Particle.java | 10 ++++ 7 files changed, 90 insertions(+), 28 deletions(-) diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/BoneComponentProvider.java b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/BoneComponentProvider.java index 2afb61d01..ed6fa4638 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/BoneComponentProvider.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/BoneComponentProvider.java @@ -2,7 +2,9 @@ import com.badlogic.gdx.utils.Array; import com.talosvfx.talos.editor.widgets.propertyWidgets.PropertyWidget; +import com.talosvfx.talos.editor.widgets.propertyWidgets.WidgetFactory; import com.talosvfx.talos.runtime.scene.components.BoneComponent; +import com.talosvfx.talos.runtime.scene.components.TransformComponent; public class BoneComponentProvider extends AComponentProvider { @@ -14,6 +16,25 @@ public BoneComponentProvider (BoneComponent component) { public Array getListOfProperties () { Array properties = new Array<>(); + if (component.getGameObject().hasComponent(TransformComponent.class)) { + + TransformComponent transformComponent = component.getGameObject().getComponent(TransformComponent.class); + + PropertyWidget positionWidget = WidgetFactory.generate(transformComponent, "worldPosition", "World Position"); + PropertyWidget rotationWidget = WidgetFactory.generate(transformComponent, "worldRotation", "World Rotation"); + PropertyWidget scaleWidget = WidgetFactory.generate(transformComponent, "worldScale", "World Scale"); + + positionWidget.setReadOnly(); + rotationWidget.setReadOnly(); + scaleWidget.setReadOnly(); + + properties.add(positionWidget); + properties.add(rotationWidget); + properties.add(scaleWidget); + + } + + return properties; } diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/GameObjectPropertyHolder.java b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/GameObjectPropertyHolder.java index b33b5c049..1b1c76fc3 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/GameObjectPropertyHolder.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/GameObjectPropertyHolder.java @@ -9,32 +9,30 @@ import lombok.Getter; public class GameObjectPropertyHolder extends PropertyWrapperProviders.ObjectPropertyHolder { - @Getter - private final GameObject gameObject; - private final GameObjectPropertyProvider gameObjectPropertyProvider; - - public GameObjectPropertyHolder (GameObject gameObject) { - this.gameObject = gameObject; - gameObjectPropertyProvider = new GameObjectPropertyProvider(gameObject); - } - - @Override - public Iterable getPropertyProviders () { - Array list = new Array<>(); - - if (!gameObject.hasComponent(BoneComponent.class)) { - list.add(gameObjectPropertyProvider); - - for (AComponent component : gameObject.getComponents()) { - list.add(PropertyWrapperProviders.getOrCreateProvider(component)); - } - } - - return list; - } - - @Override - public String getName () { - return gameObject.getName(); - } + @Getter + private final GameObject gameObject; + private final GameObjectPropertyProvider gameObjectPropertyProvider; + + public GameObjectPropertyHolder (GameObject gameObject) { + this.gameObject = gameObject; + gameObjectPropertyProvider = new GameObjectPropertyProvider(gameObject); + } + + @Override + public Iterable getPropertyProviders () { + Array list = new Array<>(); + + list.add(gameObjectPropertyProvider); + + for (AComponent component : gameObject.getComponents()) { + list.add(PropertyWrapperProviders.getOrCreateProvider(component)); + } + + return list; + } + + @Override + public String getName () { + return gameObject.getName(); + } } diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/SpineComponentProvider.java b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/SpineComponentProvider.java index 527a2ef20..3f6988ea8 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/SpineComponentProvider.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/SpineComponentProvider.java @@ -90,6 +90,14 @@ public void report (GameAsset value) { properties.add(atlasWidget); properties.add(WidgetFactory.generate(component, "scale", "Scale")); + PropertyWidget generate = WidgetFactory.generate(component, "editorAnimationSpeed", "Editor Anim Speed"); + generate.addListener(new ChangeListener() { + @Override + public void changed (ChangeEvent event, Actor actor) { + component.animationState.setTimeScale(((float) generate.getValue())); + } + }); + properties.add(generate); PropertyWidget colorWidget = WidgetFactory.generate(component, "color", "Color"); properties.add(colorWidget); diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/TransformComponentProvider.java b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/TransformComponentProvider.java index b4ecce7ef..f696d076a 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/TransformComponentProvider.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/logic/componentwrappers/TransformComponentProvider.java @@ -3,6 +3,7 @@ import com.badlogic.gdx.utils.Array; import com.talosvfx.talos.editor.widgets.propertyWidgets.PropertyWidget; import com.talosvfx.talos.editor.widgets.propertyWidgets.WidgetFactory; +import com.talosvfx.talos.runtime.scene.components.BoneComponent; import com.talosvfx.talos.runtime.scene.components.TransformComponent; public class TransformComponentProvider extends AComponentProvider { @@ -19,6 +20,12 @@ public Array getListOfProperties () { PropertyWidget rotationWidget = WidgetFactory.generate(component, "rotation", "Rotation"); PropertyWidget scaleWidget = WidgetFactory.generate(component, "scale", "Scale"); + if (component.getGameObject().hasComponent(BoneComponent.class)) { + positionWidget.setReadOnly(); + rotationWidget.setReadOnly(); + scaleWidget.setReadOnly(); + } + properties.add(positionWidget); properties.add(rotationWidget); properties.add(scaleWidget); diff --git a/editor/src/com/talosvfx/talos/editor/widgets/propertyWidgets/PropertyWidget.java b/editor/src/com/talosvfx/talos/editor/widgets/propertyWidgets/PropertyWidget.java index bbcd9b4ec..6d57dacc0 100644 --- a/editor/src/com/talosvfx/talos/editor/widgets/propertyWidgets/PropertyWidget.java +++ b/editor/src/com/talosvfx/talos/editor/widgets/propertyWidgets/PropertyWidget.java @@ -54,6 +54,8 @@ public abstract class PropertyWidget extends Table { @Setter public ChangeListener injectedChangeListener; + protected boolean readOnly; + public void toggleHide (boolean hidden) { //Check if we are in a cell if (getParent() instanceof Table) { @@ -80,6 +82,11 @@ public Object getParentObject () { return parent; } + public void setReadOnly () { + readOnly = true; + }; + + public interface ValueChanged { void report(T value); } @@ -139,6 +146,14 @@ public void updateValue() { updateWidget(value); } + @Override + public void act (float delta) { + super.act(delta); + if (readOnly) { + updateValue(); + } + } + public abstract void updateWidget(T value); diff --git a/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/scene/components/SpineRendererComponent.java b/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/scene/components/SpineRendererComponent.java index 062f7c319..6706f1503 100644 --- a/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/scene/components/SpineRendererComponent.java +++ b/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/scene/components/SpineRendererComponent.java @@ -33,6 +33,9 @@ public class SpineRendererComponent extends RendererComponent implements Json.Se @ValueProperty(prefix = {"scale"}) public float scale = 1f; + @ValueProperty(prefix = {"x"}, min = 0, step = 0.01f, max = 10) + public float editorAnimationSpeed = 1f; + @Getter@Setter private String skin; diff --git a/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/vfx/Particle.java b/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/vfx/Particle.java index 7aa7b10ef..1f5635ee4 100644 --- a/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/vfx/Particle.java +++ b/runtimes/talos/src/main/java/com/talosvfx/talos/runtime/vfx/Particle.java @@ -82,7 +82,17 @@ public void init(IEmitter emitterReference, float seed) { localPosition.set(particleModule.getSpawnPosition()); rotation.set(particleModule.getSpawnRotation()); acceleration.set(0, 0, 0); + velocity.set(particleModule.getInitialVelocity()); + + //rotate it by origin rotation + float worldRotation = emitterReference.getWorldRotation(); + Vector2 worldScale = emitterReference.getWorldScale(); + + + velocity.rotate(worldRotation, 0, 0, 1).scl(worldScale.x, worldScale.y, 0); + + spinVelocity.set(particleModule.getInitialSpinVelocity());