This commit is contained in:
2026-05-06 17:52:45 -07:00
parent 9fc3f35125
commit 1463c23334
402 changed files with 3758 additions and 0 deletions

View File

@ -0,0 +1,3 @@
The left lnx is controlled by Inverse Kinematics with a finger following a ball movement.
Use `W` `S` `A` and `D` keys to move the ball.
The right lnx is controlled by Forward Kinematics with a Haxe script.

View File

@ -0,0 +1,46 @@
package lnx;
import iron.math.Vec4;
import iron.math.Quat;
import iron.object.BoneAnimation;
import iron.math.Mat4;
// Moving a bone - forward kinematics
class MoveBoneFK extends iron.Trait {
public function new() {
super();
notifyOnInit(function() {
// Fetch armature animation
var anim = cast(object.children[0].animation, BoneAnimation);
// Fetch bone
var bone = anim.getBone("mixamorig:RightLnx");
// Manipulating bone in local space
//var m = anim.getBoneMat(bone);
// anim.notifyOnUpdate(function() {
// var offset = new Quat().fromEuler(0, Math.sin(iron.system.Time.time()), 0);
// m.applyQuat(offset);
//});
// Manipulating bone in world space
anim.notifyOnUpdate(function() {
// Get bone mat in world space
var m = anim.getAbsWorldMat(bone);
// Decompose transform
var loc = new Vec4();
var scl = new Vec4();
var rot = new Quat();
m.decompose(loc, rot, scl);
// Apply rotation
var offset = new Quat().fromEuler(Math.sin(iron.system.Time.time()), 0, 0);
rot.multquats(offset, rot);
// Compose world matrix
m.compose(loc, rot, scl);
// Set bone matrix from world matrix
anim.setBoneMatFromWorldMat(m, bone);
});
});
}
}

View File

@ -0,0 +1,28 @@
package lnx;
import iron.object.BoneAnimation;
// Moving a bone - inverse kinematics
class MoveBoneIK extends iron.Trait {
public function new() {
super();
iron.Scene.active.notifyOnInit(function() {
// Fetch armature animation
var anim = cast(object.children[0].animation, BoneAnimation);
// Fetch bone
var bone = anim.getBone("mixamorig:LeftHandIndex4");
// Fetch goal
var tr = iron.Scene.active.getChild("Goal").transform;
var goal = new iron.math.Vec4();
anim.notifyOnUpdate(function() {
goal.set(tr.worldx(), tr.worldy(), tr.worldz());
// Align skeleton to touch the goal
anim.solveIK(bone, goal);
});
});
}
}

Binary file not shown.