Skip to content

Commit 87bcce5

Browse files
authored
Merge pull request #33 from Yellow-Dog-Man/frooxius/feat/improve-avatar-gizmos
Improve hand & feet gizmos further
2 parents 98954cf + d6cd720 commit 87bcce5

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

Assets/ResoniteSDK/Processors/Avatar/BipedAvatarDescriptor.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ void OnDrawGizmos()
9999
}
100100

101101
if (LeftHandReference != null)
102-
DrawHand(LeftHandReference, Color.cyan);
102+
DrawHand(LeftHandReference, Color.cyan, false);
103103

104104
if (RightHandReference != null)
105-
DrawHand(RightHandReference, Color.red);
105+
DrawHand(RightHandReference, Color.red, true);
106106

107107
if (LeftFootReference != null)
108108
DrawFoot(LeftFootReference, Color.cyan);
@@ -119,11 +119,24 @@ void OnDrawGizmos()
119119
}
120120
}
121121

122-
void DrawHand(Transform transform, Color handColor)
122+
void DrawHand(Transform transform, Color handColor, bool isRight)
123123
{
124+
var sideMul = isRight ? 1 : -1;
125+
124126
Gizmos.color = handColor;
125-
DrawCube(transform, new Vector3(0.05f, 0.02f, 0.1f));
126127

128+
DrawCube(transform, new Vector3(0.05f, 0.02f, 0.05f));
129+
130+
// Crude fingers. This is just to better indicate that it's supposed to represent a hand
131+
for (int i = 0; i < 4; i++)
132+
{
133+
var offset = (i / 4.0f) - 0.4f;
134+
DrawCube(transform, new Vector3(0.0075f, 0.0075f, 0.05f), new Vector3(offset * 0.05f, 0f, 0.05f), Quaternion.identity);
135+
}
136+
137+
// Thumb
138+
DrawCube(transform, new Vector3(0.015f, 0.015f, 0.04f), new Vector3(-0.025f * sideMul, 0f, 0.01f), Quaternion.AngleAxis(-45f * sideMul, Vector3.up));
139+
127140
DrawAxes(transform);
128141
}
129142

@@ -135,9 +148,17 @@ void DrawFoot(Transform transform, Color footColor)
135148
DrawAxes(transform);
136149
}
137150

138-
void DrawCube(Transform transform, Vector3 size)
151+
void DrawCube(Transform transform, Vector3 size) => DrawCube(transform, size, Vector3.zero, Quaternion.identity);
152+
void DrawCube(Transform transform, Vector3 size, Vector3 offset, Quaternion rotationOffset)
139153
{
140-
Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
154+
var rotation = transform.rotation * rotationOffset;
155+
offset = transform.rotation * offset;
156+
157+
// We want to move the cube along the forward axis, because the transform represents the "root"
158+
var axisOffset = rotation * Vector3.forward * size.z * 0.4f;
159+
160+
Gizmos.matrix = Matrix4x4.TRS(transform.position + offset + axisOffset, rotation, Vector3.one);
161+
141162
Gizmos.DrawWireCube(Vector3.zero, size);
142163
Gizmos.matrix = Matrix4x4.identity;
143164
}

0 commit comments

Comments
 (0)