-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add visual gizmo when paint fails due to NoPaintZone
- Loading branch information
Showing
7 changed files
with
708 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
// e009d5ca-2f39-41dc-91cf-116ddd58134b 636548576660325877 | ||
// dadb192f-7f29-48c7-ac20-ab0789c7bc72 636548622047207485 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,086 changes: 563 additions & 523 deletions
1,086
Assets/archives/LeapPaint (v3 archive)/zzOld_LeapPaint/Scenes/LeapPaint.unity
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...ives/LeapPaint (v3 archive)/zzOld_LeapPaint/Scripts/Upgrades/NoPaintZoneFeedbackDrawer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using InteractionEngineUtility; | ||
using Leap.Unity.RuntimeGizmos; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Leap.Unity.LeapPaint_v3 { | ||
|
||
public class NoPaintZoneFeedbackDrawer : MonoBehaviour, IRuntimeGizmoComponent { | ||
|
||
private AnimationCurve _curve = DefaultCurve.SigmoidUp; | ||
|
||
private static NoPaintZoneFeedbackDrawer _instance = null; | ||
public static NoPaintZoneFeedbackDrawer instance { | ||
get { return _instance; } | ||
} | ||
|
||
private void Awake() { | ||
if (_instance == null) _instance = this; | ||
} | ||
|
||
public static void DrawFailedPaintGizmo(Vector3 pinchPos, Collider dueToCollider) { | ||
instance.Draw(pinchPos, dueToCollider); | ||
} | ||
|
||
public void Draw(Vector3 pinchPos, Collider dueToCollider) { | ||
var collider = dueToCollider; | ||
|
||
//var surfacePos = collider.transform.TransformPoint(collider.ClosestPointOnSurface( | ||
// collider.transform.InverseTransformPoint(pinchPos))); | ||
//var normal = surfacePos - dueToCollider.transform.position; | ||
var normal = collider.transform.position - pinchPos; | ||
|
||
var newGizmo = new FailedPaintGizmo() { | ||
position = pinchPos, | ||
normal = normal, | ||
colliderPos = dueToCollider.transform.position, | ||
initRingSize = 0.01f, | ||
finalRingSize = 0.06f, | ||
duration = 0.6f, | ||
t = 0f | ||
}; | ||
|
||
_failedPaintGizmos.Add(newGizmo); | ||
} | ||
|
||
private List<FailedPaintGizmo> _failedPaintGizmos = new List<FailedPaintGizmo>(); | ||
|
||
public struct FailedPaintGizmo { | ||
public Vector3 position; | ||
public Vector3 normal; | ||
public Vector3 colliderPos; | ||
public float initRingSize; | ||
public float finalRingSize; | ||
public float duration; | ||
public float t; | ||
|
||
public bool isFinished; | ||
} | ||
|
||
public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer) { | ||
drawer.color = LeapColor.cyan; | ||
|
||
var rDelta = 0.008f; | ||
var dt = Time.deltaTime; | ||
FailedPaintGizmo gizmo; | ||
for (int i = 0; i < _failedPaintGizmos.Count; i++) { | ||
gizmo = _failedPaintGizmos[i]; | ||
|
||
gizmo.t += dt; | ||
if (gizmo.t > gizmo.duration) { | ||
gizmo.t = gizmo.duration; | ||
gizmo.isFinished = true; | ||
} | ||
|
||
var progress = _curve.Evaluate(gizmo.t / gizmo.duration); | ||
drawer.color = drawer.color.WithAlpha(Mathf.Sin(progress * Mathf.PI)); | ||
|
||
for (int j = 0; j < 3; j++) { | ||
var r = Mathf.Lerp(gizmo.initRingSize, gizmo.finalRingSize, progress) | ||
- rDelta * j; | ||
|
||
if (r > 0f) { | ||
drawer.DrawWireArc(gizmo.position, gizmo.normal, gizmo.normal.Perpendicular(), | ||
r, 1f, 32); | ||
} | ||
} | ||
drawer.DrawDashedLine(gizmo.position, gizmo.colliderPos, segmentsPerMeter: 128); | ||
|
||
_failedPaintGizmos[i] = gizmo; | ||
} | ||
|
||
_failedPaintGizmos.RemoveAll((g) => g.isFinished); | ||
} | ||
|
||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...LeapPaint (v3 archive)/zzOld_LeapPaint/Scripts/Upgrades/NoPaintZoneFeedbackDrawer.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.