Skip to content

Commit 390432a

Browse files
authored
CU-868fbqk0h: Better direction visuals of the MonoCircularUserAreaProvider avatar (#24)
Gizmos added to display the following: - a blue VR headset on the avatar head - a green colored 90 degree sector in the forward direction
2 parents 70343fb + 1fa5a7e commit 390432a

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

Assets/MXRUS/Embeddings/GizmosX.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,27 @@ public static void DrawCircleXZ(Vector3 center, float radius, int perimeterSegme
2626
prevPoint = nextPoint;
2727
}
2828
}
29+
30+
public static void DrawSectorXZ(Vector3 center, Vector3 direction, float angle, int arcSegments, float radius) {
31+
float dirAngle = Mathf.Atan2(direction.z, direction.x) * Mathf.Rad2Deg;
32+
float halfAngle = angle * 0.5f;
33+
float angleStep = angle / arcSegments;
34+
35+
// First spoke
36+
float startAngle = dirAngle - halfAngle;
37+
Vector3 prevPoint = center + new Vector3(Mathf.Cos(startAngle * Mathf.Deg2Rad), 0, Mathf.Sin(startAngle * Mathf.Deg2Rad)) * radius;
38+
Gizmos.DrawLine(center, prevPoint);
39+
40+
// Arc edges and remaining spokes
41+
for (int i = 1; i <= arcSegments; i++) {
42+
float currentAngle = startAngle + angleStep * i;
43+
Vector3 nextPoint = center + new Vector3(Mathf.Cos(currentAngle * Mathf.Deg2Rad), 0, Mathf.Sin(currentAngle * Mathf.Deg2Rad)) * radius;
44+
45+
Gizmos.DrawLine(prevPoint, nextPoint);
46+
Gizmos.DrawLine(center, nextPoint);
47+
48+
prevPoint = nextPoint;
49+
}
50+
}
2951
}
3052
}

Assets/MXRUS/Embeddings/Providers/MonoCircularUserAreaProvider.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ private void OnDrawGizmos() {
4949
Gizmos.color = Color.yellow;
5050
GizmosX.DrawConcentricCirclesXZ(Vector3.zero, walkableRadius, PERIMETER_SEGMENTS, RING_COUNT);
5151

52-
// Draw lines to show forward and right directions relative to the avatars rotation
53-
Gizmos.color = Color.white;
54-
Gizmos.DrawLine(Vector3.zero, Vector3.forward * 2);
55-
Gizmos.DrawLine(Vector3.zero, Vector3.right * 2);
52+
// Draw a sector in the direction of the avatar
53+
Gizmos.color = Color.green;
54+
GizmosX.DrawSectorXZ(Vector3.zero, Vector3.forward, 90, 10, walkableRadius);
5655

5756
// Draw avatar body
5857
Gizmos.color = Color.cyan;
@@ -67,6 +66,13 @@ private void OnDrawGizmos() {
6766
);
6867
Gizmos.DrawSphere(Vector3.up * BODY_HEIGHT + (transform.up * HEAD_RADIUS), HEAD_RADIUS);
6968

69+
// Draw a VR headset
70+
Gizmos.color = new Color(.4f, .4f, 1);
71+
Gizmos.DrawCube(
72+
(Vector3.up * (BODY_HEIGHT + HEAD_RADIUS * 1.25f)) + (.66f * HEAD_RADIUS * Vector3.forward),
73+
new Vector3(HEAD_RADIUS * 1.5f, HEAD_RADIUS * .5f, HEAD_RADIUS)
74+
);
75+
7076
// Reset Gizmos class
7177
Gizmos.color = Color.white;
7278
Gizmos.matrix = Matrix4x4.identity;

0 commit comments

Comments
 (0)