Skip to content

Commit

Permalink
Add transform and bone debug for world an dlocation transforms when w…
Browse files Browse the repository at this point in the history
…e have a BoneCOmponent

Add editor timescale property for testing animation speeds in editor

Rotate inital velocity by the effect velocity
  • Loading branch information
Tom-Ski committed Oct 3, 2024
1 parent 1dd8dbc commit 31a6f5e
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<BoneComponent> {

Expand All @@ -14,6 +16,25 @@ public BoneComponentProvider (BoneComponent component) {
public Array<PropertyWidget> getListOfProperties () {
Array<PropertyWidget> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@
import lombok.Getter;

public class GameObjectPropertyHolder extends PropertyWrapperProviders.ObjectPropertyHolder<GameObject> {
@Getter
private final GameObject gameObject;
private final GameObjectPropertyProvider gameObjectPropertyProvider;

public GameObjectPropertyHolder (GameObject gameObject) {
this.gameObject = gameObject;
gameObjectPropertyProvider = new GameObjectPropertyProvider(gameObject);
}

@Override
public Iterable<IPropertyProvider> getPropertyProviders () {
Array<IPropertyProvider> 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<IPropertyProvider> getPropertyProviders () {
Array<IPropertyProvider> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public void report (GameAsset<SkeletonData> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TransformComponent> {
Expand All @@ -19,6 +20,12 @@ public Array<PropertyWidget> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public abstract class PropertyWidget<T> 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) {
Expand All @@ -80,6 +82,11 @@ public Object getParentObject () {
return parent;
}

public void setReadOnly () {
readOnly = true;
};


public interface ValueChanged<T> {
void report(T value);
}
Expand Down Expand Up @@ -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);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());


Expand Down

0 comments on commit 31a6f5e

Please sign in to comment.