trackballer demo pre polish

This commit is contained in:
spatialfree 2022-10-19 21:30:14 -04:00
parent ffd8fbb3d8
commit 95b1bd3918
5 changed files with 54 additions and 58 deletions

Binary file not shown.

View file

@ -69,13 +69,14 @@ public class Mono {
matHolo.DepthWrite = false;
matHolo.DepthTest = DepthTest.Always;
matHolo.FaceCull = Cull.None;
matHolo.SetTexture("diffuse", Tex.DevTex);
// matHolo.SetTexture("diffuse", Tex.DevTex);
matHolo.Wireframe = true;
}
public void Frame() {
// Input.HandClearOverride(Handed.Left);
Input.HandClearOverride(Handed.Right);
// Input.HandClearOverride(Handed.Right);
// store hand pre override in rig
rig.Step();
@ -108,24 +109,6 @@ public class Mono {
lwc.Demo(ltb.ori);
rwc.Demo(rtb.ori);
Mesh.Cube.Draw(Mono.inst.matHolo,
Matrix.TRS(
lwc.cursor.position,
Quat.Identity, // ltb.ori,
0.015f
),
new Color(0, 1, 1)
);
Mesh.Cube.Draw(Mono.inst.matHolo,
Matrix.TRS(
rwc.cursor.position,
Quat.Identity, // rtb.ori,
0.015f
),
new Color(0, 1, 1)
);
// rBlock.Step(); lBlock.Step();
// cubicCon.Step();
@ -175,7 +158,7 @@ public class Mono {
UI.WindowEnd();
}
public float trailLen = 0.666f;
public float trailScl = 0.2f;
public float trailScl = 0.333f;
public float stretchStr = 0.5f;
public float playerY = 0;

View file

@ -2,8 +2,15 @@ namespace Oriels;
class WaveCursor : dof {
public class Cursor
{
public Vec3 raw;
public Vec3 pos;
public Vec3 smooth;
}
// data
public Pose cursor = Pose.Identity;
public Cursor cursor = new Cursor();
PullRequest.OneEuroFilter xF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
PullRequest.OneEuroFilter yF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
PullRequest.OneEuroFilter zF = new PullRequest.OneEuroFilter(0.001f, 0.1f);
@ -25,15 +32,15 @@ class WaveCursor : dof {
hand.Get(FingerId.Index, JointId.KnuckleMajor).position
);
Vec3 rawPos = hand.Get(FingerId.Index, JointId.Tip).position + dir * stretch * strength * Mono.inst.stretchStr;
Mesh.Cube.Draw(Mono.inst.matHolo, Matrix.TRS(rawPos, Quat.Identity, 0.01f), new Color(1, 0, 0));
cursor.raw = hand.Get(FingerId.Index, JointId.Tip).position + dir * stretch * strength * Mono.inst.stretchStr;
cursor.pos.x = (float)xF.Filter(cursor.raw.x, (double)Time.Elapsedf);
cursor.pos.y = (float)yF.Filter(cursor.raw.y, (double)Time.Elapsedf);
cursor.pos.z = (float)zF.Filter(cursor.raw.z, (double)Time.Elapsedf);
cursor.smooth = Vec3.Lerp(cursor.smooth, cursor.pos, Time.Elapsedf * 6f);
rawPos.x = (float)xF.Filter(rawPos.x, (double)Time.Elapsedf);
rawPos.y = (float)yF.Filter(rawPos.y, (double)Time.Elapsedf);
rawPos.z = (float)zF.Filter(rawPos.z, (double)Time.Elapsedf);
cursor.position = rawPos; // Vec3.Lerp(cursor.position, rawPos, Time.Elapsedf * 6f);
cursor.orientation = hand.palm.orientation;
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(cursor.raw, Quat.Identity, 0.01f), new Color(1, 0, 0));
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(cursor.pos, Quat.Identity, 0.01f), new Color(0, 1, 0));
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(cursor.smooth, Quat.Identity, 0.01f), new Color(0, 0, 1));
}
}
@ -58,16 +65,16 @@ class WaveCursor : dof {
}
Vec3[] mm = new Vec3[64];
Vec3[] mm = new Vec3[81];
Vec3[] xL = new Vec3[64];
Vec3[] xR = new Vec3[64];
Vec3[] yL = new Vec3[64];
Vec3[] yR = new Vec3[64];
Vec3[] zL = new Vec3[64];
Vec3[] zR = new Vec3[64];
Vec3[] xL = new Vec3[81];
Vec3[] xR = new Vec3[81];
Vec3[] yL = new Vec3[81];
Vec3[] yR = new Vec3[81];
Vec3[] zL = new Vec3[81];
Vec3[] zR = new Vec3[81];
public void Demo(Quat ori) {
Trail(mm, cursor.position); // + ori * new Vec3(0, 0, 0.04f));
Trail(mm, cursor.smooth + ori * new Vec3(0, 0, 0.08f));
// Trail(xL, smoothPos + cursor.orientation * new Vec3(-1, 0, 0) * 0.1f);
// Trail(xR, smoothPos + cursor.orientation * new Vec3( 1, 0, 0) * 0.1f);
@ -78,19 +85,27 @@ class WaveCursor : dof {
}
void Trail(Vec3[] points, Vec3 nextPos) {
points[0] = nextPos;
int len = (int)(points.Length * Mono.inst.trailLen);
for (int i = 0; i < len; i++) {
if (i > 0) {
Vec3 dir = Vec3.Forward;
if (points[i].v != points[i - 1].v) {
dir = PullRequest.Direction(points[i], points[i - 1]);
while (Vec3.Distance(points[0], nextPos) > 0.03f * Mono.inst.trailScl) {
for (int i = points.Length - 1; i > 0; i--) {
points[i] = points[i - 1];
}
points[i] = points[i - 1] + dir * 0.02f * Mono.inst.trailScl;
points[0] += Vec3.Direction(nextPos, points[0]) * 0.02f * Mono.inst.trailScl;
}
// points[0] = nextPos;
int len = (int)(points.Length * Mono.inst.trailLen);
for (int i = 0; i < len; i++) {
// if (i > 0) {
// Vec3 dir = Vec3.Forward;
// if (points[i].v != points[i - 1].v) {
// dir = PullRequest.Direction(points[i], points[i - 1]);
// }
// // points[i] = points[i - 1] + dir * 0.02f * Mono.inst.trailScl;
// }
Vec3 from = i > 0 ? points[i - 1] : nextPos;
Quat ori = Quat.LookDir(PullRequest.Direction(points[i], from));
Quat ori = Quat.LookDir(Vec3.Direction(points[i], from));
Mesh.Cube.Draw(
Mono.inst.matHolo,
Matrix.TRS(

View file

@ -39,7 +39,7 @@ class Trackballer : dof {
thumbRot,
new Vec3(handed == Handed.Left ? -1f : 1f, 1f, 1f) * 0.1666f
);
mesh.Draw(Mono.inst.matHolo, mMesh, new Color(0, 0, 1));
mesh.Draw(Mono.inst.matHolo, mMesh, new Color(0, 1, 1));
// closest to anchor
float closest = 100000f;
@ -84,7 +84,7 @@ class Trackballer : dof {
// Lines.Add(thumbTip, thumbKnuckle, Color.White, 0.002f);
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(mAnchor.Transform(localPad), hand.palm.orientation, 0.004f), new Color(0, 1, 0));
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(mAnchor.Transform(localPad), hand.palm.orientation, 0.002f), new Color(0, 1, 1));
// if (btnIn.held) {
@ -118,8 +118,8 @@ class Trackballer : dof {
}
// Draw
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(inT, 0, 0));
Mesh.Cube.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(0, outT * 0.2f, 0));
Mesh.Sphere.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, layer[1] * 2), new Color(inT, 0, 0));
// Mesh.Cube.Draw(Mono.inst.matHolo, Matrix.TRS(anchor, ori, 0.04f), new Color(0, outT * 0.2f, 0));
}
Quat newOri = momentum * ori;
@ -139,14 +139,12 @@ class Trackballer : dof {
COMMENTS
distinct interactions to account for (relative to palm orientation)
w/rating assuming perfect tracking
y swipe (10/10)
z swipe (05/10)
x spin (02/10)
y swipe
z swipe
x spin
how reliable is the provided palm orientation?
show when you are about to boolean
more boolean visual and audio feeback
2d pad?
*/

Binary file not shown.