Trackballer 1st draft

This commit is contained in:
spatialfree 2022-10-02 18:23:48 -04:00
parent 00bc0224ce
commit ace7385db8
5 changed files with 323 additions and 275 deletions

View file

@ -6,4 +6,9 @@
**mapped out by:** **mapped out by:**
<a href='https://ethanmerchant.com'>@spatialfree</a> &times; <a href='https://twitter.com/opendegree'>@opendegree</a> <a href='https://ethanmerchant.com'>@spatialfree</a> &times; <a href='https://twitter.com/opendegree'>@opendegree</a>
<a href='https://dofdev.org'>
<img src='zrc/channel-icon-tranparent.png' width="64px"> <img src='zrc/channel-icon-tranparent.png' width="64px">
</a>
<a href='https://stereokit.net'>
<img src='zrc/StereoKitLogoLight.svg' width="32px">
</a>

View file

@ -61,6 +61,8 @@ public static class PullRequest {
).Normalized; ).Normalized;
} }
// Quat q;
// public static void Relative(Quat to) => q = to * q * to.Inverse;
public static Quat Relative(Quat to, Quat delta) { public static Quat Relative(Quat to, Quat delta) {
return (to * delta * to.Inverse).Normalized; return (to * delta * to.Inverse).Normalized;
} }

View file

@ -1,15 +1,13 @@
namespace Oriels; namespace Oriels;
class StretchCursor : dof { class StretchCursor : dof {
Pose p0, p1; // input
public StretchCursor() { public Pose p0, p1;
}
// data
public Pose cursor; public Pose cursor;
public void Init() {
} public void Init() {}
public void Frame() { public void Frame() {
Vec3 vec = p0.position - p1.position; Vec3 vec = p0.position - p1.position;
@ -22,6 +20,7 @@ class StretchCursor : dof {
Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor.position, 0.01f)); Mesh.Cube.Draw(Material.Default, Matrix.TS(cursor.position, 0.01f));
} }
// design
public bool backhand = true; public bool backhand = true;
public float deadzone = 0.1f; public float deadzone = 0.1f;
public float strength = 3f; public float strength = 3f;

View file

@ -6,9 +6,11 @@ class WaveCursor : dof {
} }
Vec3 oldLocalPad; Vec3 oldLocalPad;
Quat delta;
public Pose cursor = Pose.Identity; public Pose cursor = Pose.Identity;
Material mat = Material.Default;
public void Init() { public void Init() {
mat.SetTexture("diffuse", Tex.DevTex);
} }
bool isTracking = false; bool isTracking = false;
@ -49,25 +51,28 @@ class WaveCursor : dof {
Vec3 pad = Vec3.Lerp( Vec3 pad = Vec3.Lerp(
hand.Get(FingerId.Thumb, JointId.Tip).position,
hand.Get(FingerId.Thumb, JointId.KnuckleMinor).position, hand.Get(FingerId.Thumb, JointId.KnuckleMinor).position,
hand.Get(FingerId.Thumb, JointId.Tip).position,
0.5f 0.5f
); );
Vec3 localPad = mAnchorInv.Transform(pad);
Color color = Color.White; Color color = Color.White;
if (Vec3.Distance(pad, anchor) < 0.02f) { if (localPad.Length < 0.015f) {
color = new Color(1, 0, 0); color = new Color(1, 0, 0);
} }
Vec3 localPad = mAnchorInv.Transform(pad); if (localPad.Length < 0.03f && isTracking) {
if (Vec3.Distance(pad, anchor) < 0.04f && isTracking) { // localPad.Length < 0.04f delta = PullRequest.Relative(
// one of the dirs is 0
// they are the same
//
cursor.orientation = PullRequest.Relative(
hand.palm.orientation, hand.palm.orientation,
PullRequest.Delta(localPad.Normalized, oldLocalPad.Normalized) PullRequest.Delta(localPad.Normalized, oldLocalPad.Normalized)
) * cursor.orientation; ).Normalized;
} }
if (isTracking) {
cursor.orientation = delta * cursor.orientation;
}
// Lines.Add( // Lines.Add(
// mAnchor.Transform(padIn), // mAnchor.Transform(padIn),
// mAnchor.Transform(padOut), // mAnchor.Transform(padOut),
@ -80,8 +85,8 @@ class WaveCursor : dof {
Mesh.Sphere.Draw(Material.Default, Matrix.TS(anchor, 0.02f), color); Mesh.Sphere.Draw(mat, Matrix.TRS(anchor, cursor.orientation, 0.045f), color);
Mesh.Cube.Draw(Material.Default, Matrix.TRS(anchor, cursor.orientation, 0.02f)); // Mesh.Cube.Draw(Material.Default, Matrix.TRS(anchor, cursor.orientation, 0.02f));
if (isTracking) { Demo(); } if (isTracking) { Demo(); }

View file

@ -0,0 +1,37 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="none" x="0px" y="0px" width="400px" height="400px" viewBox="0 0 400 400">
<defs>
<g id="Symbol_15_0_Layer0_0_FILL">
<path fill="#FF0000" stroke="none" d="
M 104.65 0.2
Q 102 0.05 99.3 0.05 58.15 0.05 29.05 29.1 0 58.2 0 99.35 0 140.5 29.05 169.55 58 198.5 98.95 198.65 65.35 194.95 40.5 170.1 11.35 140.95 11.35 99.65 11.35 58.35 40.5 29.15 67.45 2.25 104.65 0.2
M 169 157.5
Q 193.1 133.45 193.1 99.4 193.1 65.35 169 41.25 144.95 17.2 110.9 17.2 108.15 17.2 105.5 17.35 135.5 19.4 157.25 41.15 181.3 65.2 181.3 99.2 181.3 133.2 157.25 157.2 134.35 180.15 102.3 181.2 106.5 181.6 110.9 181.6 144.95 181.6 169 157.5 Z"/>
<path fill="#FFFFFF" stroke="none" d="
M 169.5 169.55
Q 198.6 140.5 198.6 99.35 198.6 58.2 169.5 29.1 142.35 1.95 104.65 0.2 67.45 2.25 40.5 29.15 11.35 58.35 11.35 99.65 11.35 140.95 40.5 170.1 65.35 194.95 98.95 198.65 99.1 198.65 99.3 198.65 140.45 198.65 169.5 169.55
M 193.1 99.4
Q 193.1 133.45 169 157.5 144.95 181.6 110.9 181.6 106.5 181.6 102.3 181.2 100.8 181.25 99.25 181.25 65.25 181.25 41.2 157.2 17.2 133.2 17.2 99.2 17.2 65.2 41.2 41.15 65.25 17.15 99.25 17.15 102.4 17.15 105.5 17.35 108.15 17.2 110.9 17.2 144.95 17.2 169 41.25 193.1 65.35 193.1 99.4
M 96.05 87.35
L 96.05 74.85
Q 89.05 72.2 80.35 72.2 75.3 72.2 70.7 73.45 66.05 74.6 62.4 76.95 58.8 79.35 56.55 82.85 54.45 86.35 54.45 91 54.45 94.65 55.4 97.45 56.55 100.25 58.65 102.5 60.75 104.6 63.8 106.4 66.9 108.1 70.85 109.6 74.05 110.9 76.6 111.75 79.1 112.7 81.05 113.85 82.9 115.1 84 116.65 85.15 118.05 85.15 120.3 85.15 128 72.1 128 62.4 128 54.3 121.8
L 54.3 135.15
Q 62 138.65 72.35 138.65 77.85 138.65 82.6 137.5 87.5 136.25 91.15 133.9 94.95 131.65 97.2 128 99.45 124.35 99.45 119.6 99.45 115.65 98.15 112.7 96.9 109.9 94.65 107.65 92.3 105.4 89.05 103.75 85.85 101.9 81.75 100.25 78.7 99.25 76.3 98.4 73.9 97.45 72.25 96.45 70.4 95.35 69.55 93.8 68.75 92.4 68.75 90.4 68.75 88.75 69.55 87.35 70.4 85.95 71.95 84.95 73.5 83.95 75.75 83.4 78 82.85 80.65 82.85 89.35 82.85 96.05 87.35
M 116.15 43.2
L 101.75 43.2 101.75 137.1 116.15 137.1 116.15 106.7 116.45 106.7 141 137.1 159.2 137.1 130.75 104.3 156.95 73.6 139.7 73.6 116.45 102.75 116.15 102.75 116.15 43.2 Z"/>
<path fill="#00CCFF" stroke="none" d="
M 105.5 17.35
Q 102.4 17.15 99.25 17.15 65.25 17.15 41.2 41.15 17.2 65.2 17.2 99.2 17.2 133.2 41.2 157.2 65.25 181.25 99.25 181.25 100.8 181.25 102.3 181.2 73.75 178.5 52.75 157.5 28.7 133.45 28.7 99.4 28.7 65.35 52.75 41.25 74.9 19.15 105.5 17.35
M 198.6 99.35
Q 198.6 140.5 169.5 169.55 140.45 198.65 99.3 198.65 99.1 198.65 98.95 198.65 104.85 199.3 111 199.3 152.3 199.3 181.45 170.1 210.65 140.95 210.65 99.65 210.65 58.35 181.45 29.15 152.3 0 111 0 107.8 0 104.65 0.2 142.35 1.95 169.5 29.1 198.6 58.2 198.6 99.35 Z"/>
</g>
</defs>
<g transform="matrix( 1.6823883056640625, 0, 0, 1.6823883056640625, 22.8,32.35) ">
<g transform="matrix( 1, 0, 0, 1, 0,0) ">
<use xlink:href="#Symbol_15_0_Layer0_0_FILL"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3 KiB