GuiObjectManager now allows users to set Keyframes for Transformations

Fixed a bug in KeyframeList#getClosestKeyframeForTimestamp that made it only work with AdvancedPosition Keyframes
This commit is contained in:
CrushedPixel
2015-07-11 14:26:43 +02:00
parent 3fb0d87824
commit 28f7d77800
5 changed files with 184 additions and 33 deletions

View File

@@ -13,6 +13,4 @@ public class Transformation {
private Position scale;
private double opacity;
private float width, height;
}

View File

@@ -3,17 +3,43 @@ package eu.crushedpixel.replaymod.holders;
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Transformations {
private KeyframeList<Position> anchorKeyframes, positionKeyframes,
orientationKeyframes, scaleKeyframes;
private KeyframeList<NumberValue> opacityKeyframes;
private KeyframeList<Position> anchorKeyframes = new KeyframeList<Position>();
private KeyframeList<Position> positionKeyframes = new KeyframeList<Position>();
private KeyframeList<Position> orientationKeyframes = new KeyframeList<Position>();
private KeyframeList<Position> scaleKeyframes = new KeyframeList<Position>();
private KeyframeList<NumberValue> opacityKeyframes = new KeyframeList<NumberValue>();
public KeyframeList getKeyframeListByID(int id) {
switch(id) {
case 0:
return anchorKeyframes;
case 1:
return positionKeyframes;
case 2:
return orientationKeyframes;
case 3:
return scaleKeyframes;
case 4:
return opacityKeyframes;
default:
return null;
}
}
public Transformation getTransformationForTimestamp(int timestamp) {
return null;
return new Transformation(
anchorKeyframes.getInterpolatedValueForTimestamp(timestamp, true),
positionKeyframes.getInterpolatedValueForTimestamp(timestamp, true),
orientationKeyframes.getInterpolatedValueForTimestamp(timestamp, true),
scaleKeyframes.getInterpolatedValueForTimestamp(timestamp, true),
opacityKeyframes.getInterpolatedValueForTimestamp(timestamp, true).value);
}
}