magnum opus stretch-cursor

This commit is contained in:
spatialfree 2022-10-03 17:48:38 -04:00
parent ec595d9e20
commit df2b8da7ab
2 changed files with 14 additions and 15 deletions

View file

@ -2,20 +2,19 @@ namespace Oriels;
class StretchCursor : dof {
// input
public Pose to, from;
public Vec3 vTo, vFrom;
// data
// data
public Vec3 cursor;
public void Init() {}
public void Frame() {
Vec3 vec = to.position - from.position;
float len = vec.Length;
Vec3 dir = vec / len;
float mag = (vTo - vFrom).Magnitude;
float stretch = Math.Max(mag - deadzone, 0f);
float stretch = Math.Max(len - deadzone, 0f);
cursor = to.position + dir * stretch * strength;
Vec3 dir = PullRequest.Direction(vTo, vFrom);
cursor = vTo + dir * stretch * strength;
Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor, 0.01f));
}

View file

@ -1,17 +1,17 @@
input
tipTo = [pos, ori]
tipFrom = [pos, ori]
vTo
vFrom
data
cursor = [0, 0, 0]
stretch
cursor
frame
vector = tipTo.pos - tipFrom.pos
length = vec.length
dir = vector / length
mag = (vTo - vFrom).mag
stretch = max(mag - deadzone, 0)
stretch = max(length - deadzone, 0)
cursor = to.pos + dir * stretch * strength
dir = dir(vTo, vFrom)
cursor = vTo + dir * stretch * strength
design
deadzone = 0.1