From 9c7b1f35b3c012860f34fb0cce7f0b8cbdc981f7 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sat, 7 Dec 2024 13:41:56 -0500 Subject: [PATCH] render/test stretch cursor --- Platforms/Android/AndroidManifest.xml | 4 +- dofdemo.csproj | 1 + readme.md | 14 ++- src/Arts.cs | 157 ++++++++++---------------- src/Program.cs | 2 +- 5 files changed, 70 insertions(+), 108 deletions(-) diff --git a/Platforms/Android/AndroidManifest.xml b/Platforms/Android/AndroidManifest.xml index a089cde..bc82f06 100644 --- a/Platforms/Android/AndroidManifest.xml +++ b/Platforms/Android/AndroidManifest.xml @@ -2,8 +2,8 @@ diff --git a/dofdemo.csproj b/dofdemo.csproj index 13d68ea..92e727c 100644 --- a/dofdemo.csproj +++ b/dofdemo.csproj @@ -2,6 +2,7 @@ net7.0 Exe + enable Platforms\Net\App.ico diff --git a/readme.md b/readme.md index fc6e770..c6c35ce 100644 --- a/readme.md +++ b/readme.md @@ -47,13 +47,15 @@ todo peers to get a feel of some of our interactions without in a time efficient manner send and forget (perfect ux / no confusion or hand holding needed) + iterate version on dotnet publish using shell script + featuring: - [] stretch_cursor - [] color_cube - [] orbital_view - [] fullstick - [] twist_cursor - [] cubic_flow + [x] stretch_cursor + [ ] color_cube // move cube around picker which is constrained by cube limits + [ ] orbital_view // same dis/mount system as snake in a box + [ ] fullstick + [ ] twist_cursor + [ ] cubic_flow bug(s) ... diff --git a/src/Arts.cs b/src/Arts.cs index 4d7d53e..bb5ddeb 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -13,11 +13,7 @@ static class Arts static Material mat_backface = new Material("backface.hlsl"); static Material mat_justcolor = new Material("justcolor.hlsl"); - static Material mat_dofdemo = new Material("unlit.hlsl"); - public static Vec3 shake = new(0, 0, 0); - // static Quat spin_ori = Quat.Identity; - public static Vec3 last_tip_pos = new(0, 0, 0); static TextStyle text_style; @@ -43,8 +39,6 @@ static class Arts mat_backface.DepthWrite = false; mat_both.Chain = mat_backface; - - mat_dofdemo.FaceCull = Cull.None; } public static void Frame() @@ -52,28 +46,18 @@ static class Arts // Input.HandVisible(Handed.Max, false); // world - Matrix m4_world = Mono.world_pose.ToMatrix(); - Hierarchy.Push(m4_world); + Matrix m4_dof = Mono.dof_pose.ToMatrix(Mono.dof_scl); + Hierarchy.Push(m4_dof); // mesh test - meshes["Food"].Draw( - mat_mono, - Matrix.TRS( - V.XYZ(0, 0, -1), - Quat.Identity, - 0.1f - ) - ); - - // bamboo - Mesh.Cube.Draw( - mat_unlit, - Matrix.TS( - V.XYZ(0, 1, -2), - V.XYZ(0.1f, 2, 0.1f) - ), - Color.Hex(0xB9E7AFFF) - ); + // meshes["Food"].Draw( + // mat_mono, + // Matrix.TRS( + // V.XYZ(0, 0, -1), + // Quat.Identity, + // 0.1f + // ) + // ); // unit cube // Mesh.Cube.Draw( @@ -82,80 +66,58 @@ static class Arts // Color.Hex(0x13180AFF).ToLinear() // ); - // enemy - Vec3 enemy_pos = V.XYZ(SKMath.Sin(Time.Totalf * 1f) * 1.0f, 0.5f, -3.0f); - float enemy_rad = 0.5f; - Mesh.Sphere.Draw( - mat_unlit, - Matrix.TS(enemy_pos, enemy_rad * 2.0f), - 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; + + Mesh.Cube.Draw( + mat_mono, + Mono.to_grab.pose.ToMatrix(0.1f) + ); + Mesh.Cube.Draw( + mat_mono, + Mono.from_grab.pose.ToMatrix(0.05f) ); - // eyes - // Mesh.Cube.Draw( - // mat_unlit, - // Rig.head.ToMatrix().Transform(), - // Color.Hex(0x13180AFF).ToLinear() - // ); - - // blade - Mesh mesh = new(); - Quat blade_ori = Rig.r_hld.orientation; - Vec3 blade_pos = Rig.r_hld.position; - Vec3 tip_pos = blade_pos + blade_ori * V.XYZ(0, 0, 1); - mesh.SetData( - new Vertex[] { - new( blade_pos, V.XYZ(0,0,1)), - new( tip_pos, V.XYZ(0,0,1)), - new(last_tip_pos, V.XYZ(0,0,1)) - }, - new uint[] { - 0, 1, 2 - } - ); - mesh.Draw( - mat_dofdemo, - Matrix.Identity, - Color.Hex(0xF9BF05FF).ToLinear() - ); - last_tip_pos = Vec3.Lerp(last_tip_pos, tip_pos, Time.Stepf / 0.1f); - - // revolver - Quat rvolv_ori = Rig.l_aim.orientation; - Vec3 rvolv_pos = Rig.l_aim.position; - - Lines.Add( - rvolv_pos, - rvolv_pos + rvolv_ori * V.XYZ(0, 0, -10), - Color.Hex(0xF9BF05FF).ToLinear(), - U.cm + Mesh.Cube.Draw( + mat_mono, + cursor.ToMatrix(0.05f) ); - if (true) // hit test - { - Vec3 hit_delta = rvolv_ori.Inverse * (enemy_pos - rvolv_pos); - float flat_z = hit_delta.z; - hit_delta.z = 0; - float hit_mag = hit_delta.Magnitude; - bool hit = hit_mag < enemy_rad; - if (hit) - { - float hit_dist = flat_z + (Maths.smooth_stop((enemy_rad - hit_mag) / enemy_rad) * enemy_rad); - Vec3 hit_pos = rvolv_pos + rvolv_ori * V.XYZ(0, 0, hit_dist); - Mesh.Sphere.Draw( - mat_unlit, - Matrix.TS( - hit_pos, - 4 * U.cm - ), - Color.White - ); - if (Rig.btn_select.delta == +1) - { - VFX.Play(hit_pos); - } - } - } + + Hierarchy.Pop(); + // particles Particle[] particles = VFX.particles; @@ -173,9 +135,6 @@ static class Arts ); } - Hierarchy.Pop(); - - // menu Matrix m4_menu = Mono.menu_pose.ToMatrix(Mono.menu_scale); Hierarchy.Push(m4_menu); diff --git a/src/Program.cs b/src/Program.cs index 44cf822..50e3a76 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -19,7 +19,7 @@ class Program // overlayApp = true, // overlayPriority = 1, depthMode = DepthMode.D32, - disableFlatscreenMRSim = true, + // disableFlatscreenMRSim = true, renderScaling = 2, renderMultisample = 0, // mode = AppMode.Simulator,