render/test stretch cursor

This commit is contained in:
ethan merchant 2024-12-07 13:41:56 -05:00
parent b182017f12
commit 9c7b1f35b3
5 changed files with 70 additions and 108 deletions

View file

@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dofdev.dofdemo"
android:versionCode="1"
android:versionName="1.01"
android:versionCode="9"
android:versionName="1.09"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />

View file

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ApplicationIcon>Platforms\Net\App.ico</ApplicationIcon>
</PropertyGroup>

View file

@ -47,10 +47,12 @@ 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
[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

View file

@ -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;
// eyes
// Mesh.Cube.Draw(
// mat_unlit,
// Rig.head.ToMatrix().Transform(),
// Color.Hex(0x13180AFF).ToLinear()
// 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))
// );
// }
// 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
}
// 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.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,
Mono.from_grab.pose.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
Mesh.Cube.Draw(
mat_mono,
cursor.ToMatrix(0.05f)
);
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);

View file

@ -19,7 +19,7 @@ class Program
// overlayApp = true,
// overlayPriority = 1,
depthMode = DepthMode.D32,
disableFlatscreenMRSim = true,
// disableFlatscreenMRSim = true,
renderScaling = 2,
renderMultisample = 0,
// mode = AppMode.Simulator,