con mesh and snap to hand
This commit is contained in:
parent
afa2e0db98
commit
ba6fc33a40
5 changed files with 26 additions and 14 deletions
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
Binary file not shown.
|
@ -2,8 +2,8 @@
|
|||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dofdev.dofdemo"
|
||||
android:versionCode="10"
|
||||
android:versionName="1.10"
|
||||
android:versionCode="17"
|
||||
android:versionName="1.17"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />
|
||||
|
|
10
src/Arts.cs
10
src/Arts.cs
|
@ -76,13 +76,15 @@ static class Arts
|
|||
|
||||
// stretch_cursor
|
||||
{
|
||||
Mesh.Cube.Draw(
|
||||
float flip_x = Stretch.to_grab.Held && Stretch.to_grab.held_by.handed == Handed.Left ? -1 : 1;
|
||||
meshes["con"].Draw(
|
||||
mat_mono,
|
||||
Stretch.to_grab.pose.ToMatrix(5 * U.cm)
|
||||
Stretch.to_grab.pose.ToMatrix(V.XYZ(flip_x, 1, 1) * 1.5f * U.cm)
|
||||
);
|
||||
Mesh.Cube.Draw(
|
||||
flip_x = Stretch.from_grab.Held && Stretch.from_grab.held_by.handed == Handed.Left ? -1 : 1;
|
||||
meshes["con"].Draw(
|
||||
mat_mono,
|
||||
Stretch.from_grab.pose.ToMatrix(4 * U.cm)
|
||||
Stretch.from_grab.pose.ToMatrix(V.XYZ(flip_x, 1, 1) * 1.5f * U.cm)
|
||||
);
|
||||
|
||||
Mesh.Cube.Draw(
|
||||
|
|
18
src/Data.cs
18
src/Data.cs
|
@ -13,14 +13,16 @@ public class Grab
|
|||
public Pose pose;
|
||||
private Vec3 pos_offset;
|
||||
private Quat ori_offset;
|
||||
private Hand? held_by;
|
||||
public Hand? held_by;
|
||||
private bool snap_to_hand = false;
|
||||
|
||||
public Grab(float x, float y, float z)
|
||||
public Grab(float x, float y, float z, bool snap_to_hand = false)
|
||||
{
|
||||
pose = new Pose(x, y, z);
|
||||
pos_offset = Vec3.Zero;
|
||||
ori_offset = Quat.Identity;
|
||||
held_by = null;
|
||||
this.snap_to_hand = snap_to_hand;
|
||||
}
|
||||
|
||||
public bool OnGrab(ref Hand hand, ref Grab grab_ref)
|
||||
|
@ -50,8 +52,16 @@ public class Grab
|
|||
{
|
||||
if (Held)
|
||||
{
|
||||
pose.orientation = held_by.palm.orientation * ori_offset;
|
||||
pose.position = held_by.palm.position - held_by.palm.orientation * pos_offset;
|
||||
if (snap_to_hand)
|
||||
{
|
||||
pose.orientation = held_by.palm.orientation;
|
||||
pose.position = held_by.palm.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
pose.orientation = held_by.palm.orientation * ori_offset;
|
||||
pose.position = held_by.palm.position - held_by.palm.orientation * pos_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@ static class Stretch
|
|||
|
||||
public static void Init()
|
||||
{
|
||||
to_grab = new(-0.3f, 0, 0);
|
||||
from_grab = new(-0.3f, 0, 0.1f);
|
||||
to_grab = new(-0.3f, 0, 0, true);
|
||||
from_grab = new(-0.3f, 0, 0.1f, true);
|
||||
}
|
||||
|
||||
public static void Frame()
|
||||
|
|
Loading…
Add table
Reference in a new issue