refactor to make way for rest of dofs
This commit is contained in:
parent
f8b13ff533
commit
19f90b9633
4 changed files with 67 additions and 62 deletions
74
src/Arts.cs
74
src/Arts.cs
|
@ -46,8 +46,8 @@ static class Arts
|
||||||
// Input.HandVisible(Handed.Max, false);
|
// Input.HandVisible(Handed.Max, false);
|
||||||
|
|
||||||
// world
|
// world
|
||||||
Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
// Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
||||||
Hierarchy.Push(m4_dof);
|
// Hierarchy.Push(m4_dof);
|
||||||
|
|
||||||
// mesh test
|
// mesh test
|
||||||
// meshes["Food"].Draw(
|
// meshes["Food"].Draw(
|
||||||
|
@ -66,57 +66,35 @@ static class Arts
|
||||||
// Color.Hex(0x13180AFF).ToLinear()
|
// Color.Hex(0x13180AFF).ToLinear()
|
||||||
// );
|
// );
|
||||||
|
|
||||||
//// dof
|
//// dofs
|
||||||
// design
|
|
||||||
float deadzone = 0.1f;
|
|
||||||
float strength = 3;
|
|
||||||
|
|
||||||
// input
|
// stretch_cursor
|
||||||
// controls you can pick up (double grip to drop)
|
{
|
||||||
// if (!Mono.to_grab.Held)
|
Mesh.Cube.Draw(
|
||||||
// {
|
mat_mono,
|
||||||
// Pose to_pose = new Pose(
|
Stretch.to_grab.pose.ToMatrix(5 * U.cm)
|
||||||
// V.XYZ(0, 0, 0)
|
);
|
||||||
// );
|
Mesh.Cube.Draw(
|
||||||
// }
|
mat_mono,
|
||||||
// else
|
Stretch.from_grab.pose.ToMatrix(4 * U.cm)
|
||||||
// {
|
);
|
||||||
// to_pose = Rig.r_hld;
|
|
||||||
// }
|
|
||||||
// if (!Mono.from_grab.Held)
|
|
||||||
// {
|
|
||||||
// Pose from_pose = new Pose(
|
|
||||||
// to_pose.position + V.XYZ(0, 0, (deadzone + Maths.u_scalar(SKMath.Sin(Time.Totalf)) * deadzone))
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// data
|
Mesh.Cube.Draw(
|
||||||
float stretch = 0.0f;
|
mat_mono,
|
||||||
Pose cursor = new Pose();
|
Stretch.cursor.ToMatrix(3 * U.cm)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// frame
|
// reach cursor
|
||||||
Vec3 delta = Mono.to_grab.pose.position - Mono.from_grab.pose.position;
|
// pos = trackedPoint
|
||||||
stretch = Maths.max(delta.Magnitude - deadzone, 0);
|
// if down
|
||||||
|
// pullPoint = pos
|
||||||
|
|
||||||
Vec3 dir = delta.Normalized;
|
// stretch = distance(pullPoint, pos)
|
||||||
cursor.position = Mono.to_grab.pose.position + dir * stretch * strength;
|
// dir = (pos - pullPoint).normalized
|
||||||
|
// cursor = pos + dir * stretch * 3
|
||||||
|
|
||||||
Mesh.Cube.Draw(
|
// Hierarchy.Pop();
|
||||||
mat_mono,
|
|
||||||
Mono.to_grab.pose.ToMatrix(0.1f)
|
|
||||||
);
|
|
||||||
Mesh.Cube.Draw(
|
|
||||||
mat_mono,
|
|
||||||
Mono.from_grab.pose.ToMatrix(0.05f)
|
|
||||||
);
|
|
||||||
|
|
||||||
Mesh.Cube.Draw(
|
|
||||||
mat_mono,
|
|
||||||
cursor.ToMatrix(0.05f)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
Hierarchy.Pop();
|
|
||||||
|
|
||||||
|
|
||||||
// particles
|
// particles
|
||||||
|
|
|
@ -50,9 +50,6 @@ public class Grab
|
||||||
{
|
{
|
||||||
if (Held)
|
if (Held)
|
||||||
{
|
{
|
||||||
Log.Info(held_by.palm.position.ToString());
|
|
||||||
|
|
||||||
// Apply position and rotation logic here
|
|
||||||
pose.position = held_by.palm.position - pos_offset;
|
pose.position = held_by.palm.position - pos_offset;
|
||||||
pose.orientation = held_by.palm.orientation * ori_offset;
|
pose.orientation = held_by.palm.orientation * ori_offset;
|
||||||
}
|
}
|
||||||
|
|
32
src/Dofs.cs
Normal file
32
src/Dofs.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using StereoKit;
|
||||||
|
|
||||||
|
namespace dofdemo;
|
||||||
|
|
||||||
|
static class Stretch
|
||||||
|
{
|
||||||
|
public static Grab to_grab;
|
||||||
|
public static Grab from_grab;
|
||||||
|
|
||||||
|
// data
|
||||||
|
public static float stretch = 0.0f;
|
||||||
|
public static Pose cursor;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
to_grab = new();
|
||||||
|
from_grab = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Frame()
|
||||||
|
{
|
||||||
|
Vec3 delta = to_grab.pose.position - from_grab.pose.position;
|
||||||
|
stretch = Maths.max(delta.Magnitude - deadzone, 0);
|
||||||
|
|
||||||
|
Vec3 dir = delta.Normalized;
|
||||||
|
cursor.position = to_grab.pose.position + dir * stretch * strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
// design
|
||||||
|
static float deadzone = 0.1f;
|
||||||
|
static float strength = 3;
|
||||||
|
}
|
20
src/Mono.cs
20
src/Mono.cs
|
@ -10,11 +10,8 @@ static class Mono
|
||||||
public static int score;
|
public static int score;
|
||||||
|
|
||||||
// to be wrapped in a dof base class
|
// to be wrapped in a dof base class
|
||||||
public static Pose dof_pose;
|
// public static Pose dof_pose;
|
||||||
public static float dof_scl;
|
// public static float dof_scl;
|
||||||
// custom inside data/class
|
|
||||||
public static Grab to_grab;
|
|
||||||
public static Grab from_grab;
|
|
||||||
|
|
||||||
public static DeltaBool menu;
|
public static DeltaBool menu;
|
||||||
public static Pose menu_pose;
|
public static Pose menu_pose;
|
||||||
|
@ -36,10 +33,9 @@ static class Mono
|
||||||
menu_scale = 1 * U.cm;
|
menu_scale = 1 * U.cm;
|
||||||
mode = Mode.Mount;
|
mode = Mode.Mount;
|
||||||
|
|
||||||
dof_pose = new(0, 0, 0); // new(0, -1, -2);
|
// dof_pose = new(0, 0, 0); // new(0, -1, -2);
|
||||||
dof_scl = 1.0f; // 0.1f;
|
// dof_scl = 1.0f; // 0.1f;
|
||||||
to_grab = new();
|
Stretch.Init();
|
||||||
from_grab = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Frame()
|
public static void Frame()
|
||||||
|
@ -102,8 +98,8 @@ static class Mono
|
||||||
|
|
||||||
Grab[] grabs = new Grab[]
|
Grab[] grabs = new Grab[]
|
||||||
{
|
{
|
||||||
to_grab,
|
Stretch.to_grab,
|
||||||
from_grab
|
Stretch.from_grab
|
||||||
};
|
};
|
||||||
foreach (var grab in grabs)
|
foreach (var grab in grabs)
|
||||||
{
|
{
|
||||||
|
@ -152,5 +148,7 @@ static class Mono
|
||||||
|
|
||||||
grab.Frame();
|
grab.Frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stretch.Frame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue