-
-
Notifications
You must be signed in to change notification settings - Fork 74
Accessing Animation Data #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.20
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import org.figuramc.figura.lua.docs.LuaTypeDoc; | ||
import org.figuramc.figura.model.FiguraModelPart; | ||
import org.luaj.vm2.LuaError; | ||
import org.luaj.vm2.LuaTable; | ||
import org.luaj.vm2.LuaValue; | ||
|
||
import java.util.*; | ||
|
@@ -140,6 +141,25 @@ public void playCode(float minTime, float maxTime) { | |
// -- lua methods -- // | ||
|
||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("animation.getChannels") | ||
public LuaTable getChannels() { | ||
LuaTable ret = new LuaTable(); | ||
for (Map.Entry<FiguraModelPart, List<Animation.AnimationChannel>> entry : animationParts) { | ||
FiguraModelPart part = entry.getKey(); | ||
List<Animation.AnimationChannel> value = new ArrayList<Animation.AnimationChannel>(); | ||
for (Animation.AnimationChannel channel : entry.getValue()) { | ||
value.add(channel); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any need to iterate over all channels instead of initializing the list with the collection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk |
||
|
||
LuaValue lPart = (LuaValue) owner.luaRuntime.typeManager.javaToLua(part); | ||
LuaValue lValue = (LuaValue) owner.luaRuntime.typeManager.javaToLua(value); | ||
ret.set(lPart, lValue); | ||
} | ||
System.out.println(); | ||
return ret; | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("animation.is_playing") | ||
public boolean isPlaying() { | ||
|
@@ -607,5 +627,17 @@ public enum LoopMode { | |
HOLD | ||
} | ||
|
||
public record AnimationChannel(TransformType type, Keyframe... keyframes) {} | ||
@LuaWhitelist | ||
@LuaTypeDoc( | ||
name = "AnimationChannel", | ||
value = "animation_channel" | ||
) | ||
public record AnimationChannel(TransformType type, Keyframe... keyframes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhhhh idk lol There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i jsut forgot to add it i think |
||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("animation.get_keyframes") | ||
public List<Keyframe> getKeyframes() { | ||
return List.of(keyframes); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,19 @@ | |
import com.mojang.datafixers.util.Pair; | ||
import org.figuramc.figura.FiguraMod; | ||
import org.figuramc.figura.avatar.Avatar; | ||
import org.figuramc.figura.lua.LuaWhitelist; | ||
import org.figuramc.figura.lua.docs.LuaMethodDoc; | ||
import org.figuramc.figura.lua.docs.LuaTypeDoc; | ||
import org.figuramc.figura.math.vector.FiguraVec3; | ||
import org.luaj.vm2.LuaError; | ||
import org.luaj.vm2.LuaValue; | ||
import org.luaj.vm2.Varargs; | ||
|
||
@LuaWhitelist | ||
@LuaTypeDoc( | ||
name = "Keyframe", | ||
value = "keyframe" | ||
) | ||
public class Keyframe implements Comparable<Keyframe> { | ||
|
||
private final Avatar owner; | ||
|
@@ -36,14 +44,19 @@ public Keyframe(Avatar owner, Animation animation, float time, Interpolation int | |
this.bezierRightTime = bezierRightTime; | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.get_target_a") | ||
public FiguraVec3 getTargetA(float delta) { | ||
return targetA != null ? targetA.copy() : FiguraVec3.of(parseStringData(aCode[0], delta), parseStringData(aCode[1], delta), parseStringData(aCode[2], delta)); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.get_target_b") | ||
public FiguraVec3 getTargetB(float delta) { | ||
return targetB != null ? targetB.copy() : FiguraVec3.of(parseStringData(bCode[0], delta), parseStringData(bCode[1], delta), parseStringData(bCode[2], delta)); | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just an extra empty line? |
||
private float parseStringData(String data, float delta) { | ||
FiguraMod.pushProfiler(data); | ||
try { | ||
|
@@ -83,26 +96,43 @@ private float parseStringData(String data, float delta) { | |
return FiguraMod.popReturnProfiler(0f); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what i can tell thats required to have it show up in the docs command, they're all pretty self explanatory, so documentation shouldnt really be necessary imo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "setPos" and "setRot" are also self-explanatory but still are documented, and it's better to have consistent documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugh fine ill add docs |
||
public float getTime() { | ||
return time; | ||
} | ||
|
||
|
||
public Interpolation getInterpolation() { | ||
return interpolation; | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
public String getInterpolate() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, forgot about this, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so uhhhh, that is different from the existing getInterpolation and idk how to get around that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having the same name is fine, maybe add a Void argument? or no, LuaValue arg? don't know which, but |
||
return interpolation.toString(); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
public FiguraVec3 getBezierLeft() { | ||
return bezierLeft.copy(); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
public FiguraVec3 getBezierRight() { | ||
return bezierRight.copy(); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
public FiguraVec3 getBezierLeftTime() { | ||
return bezierLeftTime.copy(); | ||
} | ||
|
||
@LuaWhitelist | ||
@LuaMethodDoc("keyframe.ph") | ||
public FiguraVec3 getBezierRightTime() { | ||
return bezierRightTime.copy(); | ||
} | ||
|
This comment was marked as resolved.
Sorry, something went wrong. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -828,7 +828,13 @@ | |
"figura.docs.animation.get_speed": "Gets the animation's speed", | ||
"figura.docs.animation.set_speed": "Sets the animation's playback speed\nNegative numbers can be used for an inverted animation", | ||
"figura.docs.animation.get_name": "Returns this animation's name", | ||
"figura.docs.animation.get_channels": "Returns a table containing all the animation channels for this animation\nThis table is structured {ModelPart = {AnimationChannel, AnimationChannel}}", | ||
|
||
"figura.docs.animation_channel.get_keyframes": "Returns a list of keyframes that are in this channel", | ||
|
||
"figura.docs.keyframe.get_target_a": "Gets target 'A' of this keyframe\n I have no idea what 'A' means", | ||
"figura.docs.keyframe.get_target_b": "Gets target 'B' of this keyframe\n I have no idea what 'B' means", | ||
"figura.docs.keyframe.ph": "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :> |
||
|
||
"figura.docs.avatar": "A global API containing functions to interact with your avatar's metadata, and also to get information about the current script environment", | ||
"figura.docs.avatar.store": "Store the given key-value pair inside your current avatar's metadata\nSomeone else can get this information from a different script with the avatarVars() function in World\nThe key must be a string", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this is because it is called "channel" in BlockBench?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its because thats what figura refers to them as (AnimationChannel)