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
58
src/Arts.cs
58
src/Arts.cs
|
@ -46,8 +46,8 @@ static class Arts
|
|||
// Input.HandVisible(Handed.Max, false);
|
||||
|
||||
// world
|
||||
Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
||||
Hierarchy.Push(m4_dof);
|
||||
// Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl);
|
||||
// Hierarchy.Push(m4_dof);
|
||||
|
||||
// mesh test
|
||||
// meshes["Food"].Draw(
|
||||
|
@ -66,57 +66,35 @@ static class Arts
|
|||
// Color.Hex(0x13180AFF).ToLinear()
|
||||
// );
|
||||
|
||||
//// dof
|
||||
// design
|
||||
float deadzone = 0.1f;
|
||||
float strength = 3;
|
||||
|
||||
// input
|
||||
// controls you can pick up (double grip to drop)
|
||||
// if (!Mono.to_grab.Held)
|
||||
// {
|
||||
// Pose to_pose = new Pose(
|
||||
// V.XYZ(0, 0, 0)
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// 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
|
||||
float stretch = 0.0f;
|
||||
Pose cursor = new Pose();
|
||||
|
||||
// frame
|
||||
Vec3 delta = Mono.to_grab.pose.position - Mono.from_grab.pose.position;
|
||||
stretch = Maths.max(delta.Magnitude - deadzone, 0);
|
||||
|
||||
Vec3 dir = delta.Normalized;
|
||||
cursor.position = Mono.to_grab.pose.position + dir * stretch * strength;
|
||||
//// dofs
|
||||
|
||||
// stretch_cursor
|
||||
{
|
||||
Mesh.Cube.Draw(
|
||||
mat_mono,
|
||||
Mono.to_grab.pose.ToMatrix(0.1f)
|
||||
Stretch.to_grab.pose.ToMatrix(5 * U.cm)
|
||||
);
|
||||
Mesh.Cube.Draw(
|
||||
mat_mono,
|
||||
Mono.from_grab.pose.ToMatrix(0.05f)
|
||||
Stretch.from_grab.pose.ToMatrix(4 * U.cm)
|
||||
);
|
||||
|
||||
Mesh.Cube.Draw(
|
||||
mat_mono,
|
||||
cursor.ToMatrix(0.05f)
|
||||
Stretch.cursor.ToMatrix(3 * U.cm)
|
||||
);
|
||||
}
|
||||
|
||||
// reach cursor
|
||||
// pos = trackedPoint
|
||||
// if down
|
||||
// pullPoint = pos
|
||||
|
||||
Hierarchy.Pop();
|
||||
// stretch = distance(pullPoint, pos)
|
||||
// dir = (pos - pullPoint).normalized
|
||||
// cursor = pos + dir * stretch * 3
|
||||
|
||||
// Hierarchy.Pop();
|
||||
|
||||
|
||||
// particles
|
||||
|
|
|
@ -50,9 +50,6 @@ public class Grab
|
|||
{
|
||||
if (Held)
|
||||
{
|
||||
Log.Info(held_by.palm.position.ToString());
|
||||
|
||||
// Apply position and rotation logic here
|
||||
pose.position = held_by.palm.position - pos_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;
|
||||
|
||||
// to be wrapped in a dof base class
|
||||
public static Pose dof_pose;
|
||||
public static float dof_scl;
|
||||
// custom inside data/class
|
||||
public static Grab to_grab;
|
||||
public static Grab from_grab;
|
||||
// public static Pose dof_pose;
|
||||
// public static float dof_scl;
|
||||
|
||||
public static DeltaBool menu;
|
||||
public static Pose menu_pose;
|
||||
|
@ -36,10 +33,9 @@ static class Mono
|
|||
menu_scale = 1 * U.cm;
|
||||
mode = Mode.Mount;
|
||||
|
||||
dof_pose = new(0, 0, 0); // new(0, -1, -2);
|
||||
dof_scl = 1.0f; // 0.1f;
|
||||
to_grab = new();
|
||||
from_grab = new();
|
||||
// dof_pose = new(0, 0, 0); // new(0, -1, -2);
|
||||
// dof_scl = 1.0f; // 0.1f;
|
||||
Stretch.Init();
|
||||
}
|
||||
|
||||
public static void Frame()
|
||||
|
@ -102,8 +98,8 @@ static class Mono
|
|||
|
||||
Grab[] grabs = new Grab[]
|
||||
{
|
||||
to_grab,
|
||||
from_grab
|
||||
Stretch.to_grab,
|
||||
Stretch.from_grab
|
||||
};
|
||||
foreach (var grab in grabs)
|
||||
{
|
||||
|
@ -152,5 +148,7 @@ static class Mono
|
|||
|
||||
grab.Frame();
|
||||
}
|
||||
|
||||
Stretch.Frame();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue