Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(handSetup): Automatic hand setup
- Loading branch information
Showing
19 changed files
with
1,031 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
|
||
namespace HPTK.Helpers | ||
{ | ||
public static class BasicHelpers | ||
{ | ||
public static void SetLocalRotForHierarchy(Transform t, Vector3 newLocalRot) | ||
{ | ||
t.localRotation = Quaternion.Euler(newLocalRot); | ||
for (int i = 0; i < t.childCount; i++) | ||
{ | ||
SetLocalRotForHierarchy(t.GetChild(i), newLocalRot); | ||
} | ||
} | ||
|
||
public static bool IsCleanBranch(Transform t) | ||
{ | ||
if (t.childCount > 1) | ||
return false; | ||
else if (t.childCount == 0) | ||
return true; | ||
else | ||
return IsCleanBranch(t.GetChild(0)); | ||
} | ||
|
||
public static GameObject InstantiateEmptyChild(GameObject parent) | ||
{ | ||
GameObject newObj = new GameObject(); | ||
newObj.transform.parent = parent.transform; | ||
newObj.transform.localPosition = Vector3.zero; | ||
newObj.transform.localRotation = Quaternion.identity; | ||
|
||
return newObj; | ||
} | ||
|
||
public static Vector3 FurthestPoint(Vector3 from, Vector3[] points) | ||
{ | ||
Vector3 furthestPoint = from; | ||
float maxDistance = 0.0f; | ||
float d; | ||
for (int i = 0; i < points.Length; i++) | ||
{ | ||
d = Vector3.Distance(from, points[i]); | ||
|
||
if (d > maxDistance) | ||
{ | ||
maxDistance = d; | ||
furthestPoint = points[i]; | ||
} | ||
} | ||
|
||
return furthestPoint; | ||
} | ||
|
||
public static Vector3 ClosestPoint(Vector3 to, Vector3[] points) | ||
{ | ||
Vector3 closestPoint = to; | ||
float minDistance = Mathf.Infinity; | ||
float d; | ||
for (int i = 0; i < points.Length; i++) | ||
{ | ||
d = Vector3.Distance(to, points[i]); | ||
|
||
if (d < minDistance) | ||
{ | ||
minDistance = d; | ||
closestPoint = points[i]; | ||
} | ||
} | ||
|
||
return closestPoint; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
changelog.txt.meta → ...efabs/HandSetups/OculusHand_L.prefab.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Empty file.