Squid, dildos and bezier curves
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 51f55e42e1231024babca647e599138b
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1463688993
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a7df1a42a1caa924e94005298a889190
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1463688993
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+263
@@ -0,0 +1,263 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
[CustomEditor(typeof(BezierCurve))]
|
||||||
|
public class BezierCurveEditor : Editor
|
||||||
|
{
|
||||||
|
BezierCurve curve;
|
||||||
|
SerializedProperty resolutionProp;
|
||||||
|
SerializedProperty closeProp;
|
||||||
|
SerializedProperty pointsProp;
|
||||||
|
SerializedProperty colorProp;
|
||||||
|
|
||||||
|
private static bool showPoints = true;
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
curve = (BezierCurve)target;
|
||||||
|
|
||||||
|
resolutionProp = serializedObject.FindProperty("resolution");
|
||||||
|
closeProp = serializedObject.FindProperty("_close");
|
||||||
|
pointsProp = serializedObject.FindProperty("points");
|
||||||
|
colorProp = serializedObject.FindProperty("drawColor");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
serializedObject.Update();
|
||||||
|
|
||||||
|
EditorGUILayout.PropertyField(resolutionProp);
|
||||||
|
EditorGUILayout.PropertyField(closeProp);
|
||||||
|
EditorGUILayout.PropertyField(colorProp);
|
||||||
|
|
||||||
|
showPoints = EditorGUILayout.Foldout(showPoints, "Points");
|
||||||
|
|
||||||
|
if(showPoints)
|
||||||
|
{
|
||||||
|
int pointCount = pointsProp.arraySize;
|
||||||
|
|
||||||
|
for(int i = 0; i < pointCount; i++)
|
||||||
|
{
|
||||||
|
DrawPointInspector(curve[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GUILayout.Button("Add Point"))
|
||||||
|
{
|
||||||
|
Undo.RegisterSceneUndo("Add Point");
|
||||||
|
|
||||||
|
GameObject pointObject = new GameObject("Point "+pointsProp.arraySize);
|
||||||
|
pointObject.transform.parent = curve.transform;
|
||||||
|
pointObject.transform.localPosition = Vector3.zero;
|
||||||
|
BezierPoint newPoint = pointObject.AddComponent<BezierPoint>();
|
||||||
|
|
||||||
|
newPoint.curve = curve;
|
||||||
|
newPoint.handle1 = Vector3.right*0.1f;
|
||||||
|
newPoint.handle2 = -Vector3.right*0.1f;
|
||||||
|
|
||||||
|
pointsProp.InsertArrayElementAtIndex(pointsProp.arraySize);
|
||||||
|
pointsProp.GetArrayElementAtIndex(pointsProp.arraySize - 1).objectReferenceValue = newPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GUI.changed)
|
||||||
|
{
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSceneGUI()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < curve.pointCount; i++)
|
||||||
|
{
|
||||||
|
DrawPointSceneGUI(curve[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawPointInspector(BezierPoint point, int index)
|
||||||
|
{
|
||||||
|
SerializedObject serObj = new SerializedObject(point);
|
||||||
|
|
||||||
|
SerializedProperty handleStyleProp = serObj.FindProperty("handleStyle");
|
||||||
|
SerializedProperty handle1Prop = serObj.FindProperty("_handle1");
|
||||||
|
SerializedProperty handle2Prop = serObj.FindProperty("_handle2");
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
|
||||||
|
if(GUILayout.Button("X", GUILayout.Width(20)))
|
||||||
|
{
|
||||||
|
Undo.RegisterSceneUndo("Remove Point");
|
||||||
|
pointsProp.MoveArrayElement(curve.GetPointIndex(point), curve.pointCount - 1);
|
||||||
|
pointsProp.arraySize--;
|
||||||
|
DestroyImmediate(point.gameObject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.ObjectField(point.gameObject, typeof(GameObject), true);
|
||||||
|
|
||||||
|
if(index != 0 && GUILayout.Button(@"/\", GUILayout.Width(25)))
|
||||||
|
{
|
||||||
|
UnityEngine.Object other = pointsProp.GetArrayElementAtIndex(index - 1).objectReferenceValue;
|
||||||
|
pointsProp.GetArrayElementAtIndex(index - 1).objectReferenceValue = point;
|
||||||
|
pointsProp.GetArrayElementAtIndex(index).objectReferenceValue = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(index != pointsProp.arraySize - 1 && GUILayout.Button(@"\/", GUILayout.Width(25)))
|
||||||
|
{
|
||||||
|
UnityEngine.Object other = pointsProp.GetArrayElementAtIndex(index + 1).objectReferenceValue;
|
||||||
|
pointsProp.GetArrayElementAtIndex(index + 1).objectReferenceValue = point;
|
||||||
|
pointsProp.GetArrayElementAtIndex(index).objectReferenceValue = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
|
||||||
|
int newType = (int)((object)EditorGUILayout.EnumPopup("Handle Type", (BezierPoint.HandleStyle)handleStyleProp.enumValueIndex));
|
||||||
|
|
||||||
|
if(newType != handleStyleProp.enumValueIndex)
|
||||||
|
{
|
||||||
|
handleStyleProp.enumValueIndex = newType;
|
||||||
|
if(newType == 0)
|
||||||
|
{
|
||||||
|
if(handle1Prop.vector3Value != Vector3.zero) handle2Prop.vector3Value = -handle1Prop.vector3Value;
|
||||||
|
else if(handle2Prop.vector3Value != Vector3.zero) handle1Prop.vector3Value = -handle2Prop.vector3Value;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = new Vector3(0.1f, 0, 0);
|
||||||
|
handle2Prop.vector3Value = new Vector3(-0.1f, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(newType == 1)
|
||||||
|
{
|
||||||
|
if(handle1Prop.vector3Value == Vector3.zero && handle2Prop.vector3Value == Vector3.zero)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = new Vector3(0.1f, 0, 0);
|
||||||
|
handle2Prop.vector3Value = new Vector3(-0.1f, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(newType == 2)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = Vector3.zero;
|
||||||
|
handle2Prop.vector3Value = Vector3.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 newPointPos = EditorGUILayout.Vector3Field("Position : ", point.transform.localPosition);
|
||||||
|
if(newPointPos != point.transform.localPosition)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(point.transform, "Move Bezier Point");
|
||||||
|
point.transform.localPosition = newPointPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(handleStyleProp.enumValueIndex == 0)
|
||||||
|
{
|
||||||
|
Vector3 newPosition;
|
||||||
|
|
||||||
|
newPosition = EditorGUILayout.Vector3Field("Handle 1", handle1Prop.vector3Value);
|
||||||
|
if(newPosition != handle1Prop.vector3Value)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = newPosition;
|
||||||
|
handle2Prop.vector3Value = -newPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
newPosition = EditorGUILayout.Vector3Field("Handle 2", handle2Prop.vector3Value);
|
||||||
|
if(newPosition != handle2Prop.vector3Value)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = -newPosition;
|
||||||
|
handle2Prop.vector3Value = newPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(handleStyleProp.enumValueIndex == 1)
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField(handle1Prop);
|
||||||
|
EditorGUILayout.PropertyField(handle2Prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
|
||||||
|
if(GUI.changed)
|
||||||
|
{
|
||||||
|
serObj.ApplyModifiedProperties();
|
||||||
|
EditorUtility.SetDirty(serObj.targetObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawPointSceneGUI(BezierPoint point)
|
||||||
|
{
|
||||||
|
Handles.Label(point.position + new Vector3(0, HandleUtility.GetHandleSize(point.position) * 0.4f, 0), point.gameObject.name);
|
||||||
|
|
||||||
|
Handles.color = Color.green;
|
||||||
|
Vector3 newPosition = Handles.FreeMoveHandle(point.position, point.transform.rotation, HandleUtility.GetHandleSize(point.position)*0.1f, Vector3.zero, Handles.RectangleCap);
|
||||||
|
|
||||||
|
if(newPosition != point.position)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(point.transform, "Move Point");
|
||||||
|
point.transform.position = newPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(point.handleStyle != BezierPoint.HandleStyle.None)
|
||||||
|
{
|
||||||
|
Handles.color = Color.cyan;
|
||||||
|
Vector3 newGlobal1 = Handles.FreeMoveHandle(point.globalHandle1, point.transform.rotation, HandleUtility.GetHandleSize(point.globalHandle1)*0.075f, Vector3.zero, Handles.CircleCap);
|
||||||
|
if(point.globalHandle1 != newGlobal1)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(point, "Move Handle");
|
||||||
|
point.globalHandle1 = newGlobal1;
|
||||||
|
if(point.handleStyle == BezierPoint.HandleStyle.Connected) point.globalHandle2 = -(newGlobal1 - point.position) + point.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 newGlobal2 = Handles.FreeMoveHandle(point.globalHandle2, point.transform.rotation, HandleUtility.GetHandleSize(point.globalHandle2)*0.075f, Vector3.zero, Handles.CircleCap);
|
||||||
|
if(point.globalHandle2 != newGlobal2)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(point, "Move Handle");
|
||||||
|
point.globalHandle2 = newGlobal2;
|
||||||
|
if(point.handleStyle == BezierPoint.HandleStyle.Connected) point.globalHandle1 = -(newGlobal2 - point.position) + point.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handles.color = Color.yellow;
|
||||||
|
Handles.DrawLine(point.position, point.globalHandle1);
|
||||||
|
Handles.DrawLine(point.position, point.globalHandle2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawOtherPoints(BezierCurve curve, BezierPoint caller)
|
||||||
|
{
|
||||||
|
foreach(BezierPoint p in curve.GetAnchorPoints())
|
||||||
|
{
|
||||||
|
if(p != caller) DrawPointSceneGUI(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/Create Other/Bezier Curve")]
|
||||||
|
public static void CreateCurve(MenuCommand command)
|
||||||
|
{
|
||||||
|
GameObject curveObject = new GameObject("BezierCurve");
|
||||||
|
Undo.RegisterUndo(curveObject, "Undo Create Curve");
|
||||||
|
BezierCurve curve = curveObject.AddComponent<BezierCurve>();
|
||||||
|
|
||||||
|
BezierPoint p1 = curve.AddPointAt(Vector3.forward * 0.5f);
|
||||||
|
p1.handleStyle = BezierPoint.HandleStyle.Connected;
|
||||||
|
p1.handle1 = new Vector3(-0.28f, 0, 0);
|
||||||
|
|
||||||
|
BezierPoint p2 = curve.AddPointAt(Vector3.right * 0.5f);
|
||||||
|
p2.handleStyle = BezierPoint.HandleStyle.Connected;
|
||||||
|
p2.handle1 = new Vector3(0, 0, 0.28f);
|
||||||
|
|
||||||
|
BezierPoint p3 = curve.AddPointAt(-Vector3.forward * 0.5f);
|
||||||
|
p3.handleStyle = BezierPoint.HandleStyle.Connected;
|
||||||
|
p3.handle1 = new Vector3(0.28f, 0, 0);
|
||||||
|
|
||||||
|
BezierPoint p4 = curve.AddPointAt(-Vector3.right * 0.5f);
|
||||||
|
p4.handleStyle = BezierPoint.HandleStyle.Connected;
|
||||||
|
p4.handle1 = new Vector3(0, 0, -0.28f);
|
||||||
|
|
||||||
|
curve.close = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 076c82ebe1ea6b249b4e66e85cdf269a
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+152
@@ -0,0 +1,152 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
[CustomEditor(typeof(BezierPoint))]
|
||||||
|
[CanEditMultipleObjects]
|
||||||
|
public class BezierPointEditor : Editor {
|
||||||
|
|
||||||
|
BezierPoint point;
|
||||||
|
|
||||||
|
SerializedProperty handleTypeProp;
|
||||||
|
SerializedProperty handle1Prop;
|
||||||
|
SerializedProperty handle2Prop;
|
||||||
|
|
||||||
|
private delegate void HandleFunction(BezierPoint p);
|
||||||
|
private HandleFunction[] handlers = new HandleFunction[] { HandleConnected, HandleBroken, HandleAbsent };
|
||||||
|
|
||||||
|
void OnEnable(){
|
||||||
|
point = (BezierPoint)target;
|
||||||
|
|
||||||
|
handleTypeProp = serializedObject.FindProperty("handleStyle");
|
||||||
|
handle1Prop = serializedObject.FindProperty("_handle1");
|
||||||
|
handle2Prop = serializedObject.FindProperty("_handle2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI (){
|
||||||
|
|
||||||
|
serializedObject.Update();
|
||||||
|
|
||||||
|
BezierPoint.HandleStyle newHandleType = (BezierPoint.HandleStyle)EditorGUILayout.EnumPopup("Handle Type", (BezierPoint.HandleStyle)handleTypeProp.intValue);
|
||||||
|
|
||||||
|
if(newHandleType != (BezierPoint.HandleStyle)handleTypeProp.intValue)
|
||||||
|
{
|
||||||
|
handleTypeProp.intValue = (int)newHandleType;
|
||||||
|
|
||||||
|
if((int)newHandleType == 0)
|
||||||
|
{
|
||||||
|
if(handle1Prop.vector3Value != Vector3.zero) handle2Prop.vector3Value = -handle1Prop.vector3Value;
|
||||||
|
else if(handle2Prop.vector3Value != Vector3.zero) handle1Prop.vector3Value = -handle2Prop.vector3Value;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = new Vector3(0.1f, 0, 0);
|
||||||
|
handle2Prop.vector3Value = new Vector3(-0.1f, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if((int)newHandleType == 1)
|
||||||
|
{
|
||||||
|
if(handle1Prop.vector3Value == Vector3.zero && handle2Prop.vector3Value == Vector3.zero)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = new Vector3(0.1f, 0, 0);
|
||||||
|
handle2Prop.vector3Value = new Vector3(-0.1f, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if((int)newHandleType == 2)
|
||||||
|
{
|
||||||
|
handle1Prop.vector3Value = Vector3.zero;
|
||||||
|
handle2Prop.vector3Value = Vector3.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(handleTypeProp.intValue != 2)
|
||||||
|
{
|
||||||
|
Vector3 newHandle1 = EditorGUILayout.Vector3Field("Handle 1", handle1Prop.vector3Value);
|
||||||
|
Vector3 newHandle2 = EditorGUILayout.Vector3Field("Handle 2", handle2Prop.vector3Value);
|
||||||
|
|
||||||
|
if(handleTypeProp.intValue == 0){
|
||||||
|
if(newHandle1 != handle1Prop.vector3Value){
|
||||||
|
handle1Prop.vector3Value = newHandle1;
|
||||||
|
handle2Prop.vector3Value = -newHandle1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(newHandle2 != handle2Prop.vector3Value){
|
||||||
|
handle1Prop.vector3Value = -newHandle2;
|
||||||
|
handle2Prop.vector3Value = newHandle2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
handle1Prop.vector3Value = newHandle1;
|
||||||
|
handle2Prop.vector3Value = newHandle2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GUI.changed){
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSceneGUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
Handles.color = Color.green;
|
||||||
|
Vector3 newPosition = Handles.FreeMoveHandle(point.position, point.transform.rotation, HandleUtility.GetHandleSize(point.position)*0.2f, Vector3.zero, Handles.CubeCap);
|
||||||
|
if(point.position != newPosition) point.position = newPosition;
|
||||||
|
|
||||||
|
handlers[(int)point.handleStyle](point);
|
||||||
|
|
||||||
|
Handles.color = Color.yellow;
|
||||||
|
Handles.DrawLine(point.position, point.globalHandle1);
|
||||||
|
Handles.DrawLine(point.position, point.globalHandle2);
|
||||||
|
|
||||||
|
BezierCurveEditor.DrawOtherPoints(point.curve, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleConnected(BezierPoint p){
|
||||||
|
Handles.color = Color.cyan;
|
||||||
|
|
||||||
|
Vector3 newGlobal1 = Handles.FreeMoveHandle(p.globalHandle1, p.transform.rotation, HandleUtility.GetHandleSize(p.globalHandle1)*0.15f, Vector3.zero, Handles.SphereCap);
|
||||||
|
|
||||||
|
if(newGlobal1 != p.globalHandle1){
|
||||||
|
Undo.RegisterUndo(p, "Move Handle");
|
||||||
|
p.globalHandle1 = newGlobal1;
|
||||||
|
p.globalHandle2 = -(newGlobal1 - p.position) + p.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 newGlobal2 = Handles.FreeMoveHandle(p.globalHandle2, p.transform.rotation, HandleUtility.GetHandleSize(p.globalHandle2)*0.15f, Vector3.zero, Handles.SphereCap);
|
||||||
|
|
||||||
|
if(newGlobal2 != p.globalHandle2){
|
||||||
|
Undo.RegisterUndo(p, "Move Handle");
|
||||||
|
p.globalHandle1 = -(newGlobal2 - p.position) + p.position;
|
||||||
|
p.globalHandle2 = newGlobal2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleBroken(BezierPoint p){
|
||||||
|
Handles.color = Color.cyan;
|
||||||
|
|
||||||
|
Vector3 newGlobal1 = Handles.FreeMoveHandle(p.globalHandle1, Quaternion.identity, HandleUtility.GetHandleSize(p.globalHandle1)*0.15f, Vector3.zero, Handles.SphereCap);
|
||||||
|
Vector3 newGlobal2 = Handles.FreeMoveHandle(p.globalHandle2, Quaternion.identity, HandleUtility.GetHandleSize(p.globalHandle2)*0.15f, Vector3.zero, Handles.SphereCap);
|
||||||
|
|
||||||
|
if(newGlobal1 != p.globalHandle1)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(p, "Move Handle");
|
||||||
|
p.globalHandle1 = newGlobal1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newGlobal2 != p.globalHandle2)
|
||||||
|
{
|
||||||
|
Undo.RegisterUndo(p, "Move Handle");
|
||||||
|
p.globalHandle2 = newGlobal2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HandleAbsent(BezierPoint p)
|
||||||
|
{
|
||||||
|
p.handle1 = Vector3.zero;
|
||||||
|
p.handle2 = Vector3.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f40a14ecad007949831de4081a5a58e
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b3fe768c68c21647b45cad53f1d7c06
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d7e57956b99d2b4e81efd36ef46eea1
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1463688993
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+555
@@ -0,0 +1,555 @@
|
|||||||
|
#region UsingStatements
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Class for describing and drawing Bezier Curves
|
||||||
|
/// - Efficiently handles approximate length calculation through 'dirty' system
|
||||||
|
/// - Has static functions for getting points on curves constructed by Vector3 parameters (GetPoint, GetCubicPoint, GetQuadraticPoint, and GetLinearPoint)
|
||||||
|
/// </summary>
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[Serializable]
|
||||||
|
public class BezierCurve : MonoBehaviour {
|
||||||
|
|
||||||
|
#region PublicVariables
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - the number of mid-points calculated for each pair of bezier points
|
||||||
|
/// - used for drawing the curve in the editor
|
||||||
|
/// - used for calculating the "length" variable
|
||||||
|
/// </summary>
|
||||||
|
public int resolution = 30;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this <see cref="BezierCurve"/> is dirty.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// <c>true</c> if dirty; otherwise, <c>false</c>.
|
||||||
|
/// </value>
|
||||||
|
public bool dirty { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - color this curve will be drawn with in the editor
|
||||||
|
/// - set in the editor
|
||||||
|
/// </summary>
|
||||||
|
public Color drawColor = Color.white;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PublicProperties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - set in the editor
|
||||||
|
/// - used to determine if the curve should be drawn as "closed" in the editor
|
||||||
|
/// - used to determine if the curve's length should include the curve between the first and the last points in "points" array
|
||||||
|
/// - setting this value will cause the curve to become dirty
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField] private bool _close;
|
||||||
|
public bool close
|
||||||
|
{
|
||||||
|
get { return _close; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(_close == value) return;
|
||||||
|
_close = value;
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - set internally
|
||||||
|
/// - gets point corresponding to "index" in "points" array
|
||||||
|
/// - does not allow direct set
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='index'>
|
||||||
|
/// - the index
|
||||||
|
/// </param>
|
||||||
|
public BezierPoint this[int index]
|
||||||
|
{
|
||||||
|
get { return points[index]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - number of points stored in 'points' variable
|
||||||
|
/// - set internally
|
||||||
|
/// - does not include "handles"
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// - The point count
|
||||||
|
/// </value>
|
||||||
|
public int pointCount
|
||||||
|
{
|
||||||
|
get { return points.Length; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - The approximate length of the curve
|
||||||
|
/// - recalculates if the curve is "dirty"
|
||||||
|
/// </summary>
|
||||||
|
private float _length;
|
||||||
|
public float length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(dirty)
|
||||||
|
{
|
||||||
|
_length = 0;
|
||||||
|
for(int i = 0; i < points.Length - 1; i++){
|
||||||
|
_length += ApproximateLength(points[i], points[i + 1], resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(close) _length += ApproximateLength(points[points.Length - 1], points[0], resolution);
|
||||||
|
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PrivateVariables
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Array of point objects that make up this curve
|
||||||
|
/// - Populated through editor
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField] private BezierPoint[] points = new BezierPoint[0];
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region UnityFunctions
|
||||||
|
|
||||||
|
void OnDrawGizmos () {
|
||||||
|
Gizmos.color = drawColor;
|
||||||
|
|
||||||
|
if(points.Length > 1){
|
||||||
|
for(int i = 0; i < points.Length - 1; i++){
|
||||||
|
DrawCurve(points[i], points[i+1], resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close) DrawCurve(points[points.Length - 1], points[0], resolution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Awake(){
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PublicFunctions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Adds the given point to the end of the curve ("points" array)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='point'>
|
||||||
|
/// - The point to add.
|
||||||
|
/// </param>
|
||||||
|
public void AddPoint(BezierPoint point)
|
||||||
|
{
|
||||||
|
List<BezierPoint> tempArray = new List<BezierPoint>(points);
|
||||||
|
tempArray.Add(point);
|
||||||
|
points = tempArray.ToArray();
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Adds a point at position
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point object
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='position'>
|
||||||
|
/// - Where to add the point
|
||||||
|
/// </param>
|
||||||
|
public BezierPoint AddPointAt(Vector3 position)
|
||||||
|
{
|
||||||
|
GameObject pointObject = new GameObject("Point "+pointCount);
|
||||||
|
|
||||||
|
pointObject.transform.parent = transform;
|
||||||
|
pointObject.transform.position = position;
|
||||||
|
|
||||||
|
BezierPoint newPoint = pointObject.AddComponent<BezierPoint>();
|
||||||
|
newPoint.curve = this;
|
||||||
|
|
||||||
|
return newPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Removes the given point from the curve ("points" array)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='point'>
|
||||||
|
/// - The point to remove
|
||||||
|
/// </param>
|
||||||
|
public void RemovePoint(BezierPoint point)
|
||||||
|
{
|
||||||
|
List<BezierPoint> tempArray = new List<BezierPoint>(points);
|
||||||
|
tempArray.Remove(point);
|
||||||
|
points = tempArray.ToArray();
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets a copy of the bezier point array used to define this curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The cloned array of points
|
||||||
|
/// </returns>
|
||||||
|
public BezierPoint[] GetAnchorPoints()
|
||||||
|
{
|
||||||
|
return (BezierPoint[])points.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets the point at 't' percent along this curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - Returns the point at 't' percent
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the curve (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
public Vector3 GetPointAt(float t)
|
||||||
|
{
|
||||||
|
if(t <= 0) return points[0].position;
|
||||||
|
else if (t >= 1) return points[points.Length - 1].position;
|
||||||
|
|
||||||
|
float totalPercent = 0;
|
||||||
|
float curvePercent = 0;
|
||||||
|
|
||||||
|
BezierPoint p1 = null;
|
||||||
|
BezierPoint p2 = null;
|
||||||
|
|
||||||
|
for(int i = 0; i < points.Length - 1; i++)
|
||||||
|
{
|
||||||
|
curvePercent = ApproximateLength(points[i], points[i + 1], 10) / length;
|
||||||
|
if(totalPercent + curvePercent > t)
|
||||||
|
{
|
||||||
|
p1 = points[i];
|
||||||
|
p2 = points[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else totalPercent += curvePercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(close && p1 == null)
|
||||||
|
{
|
||||||
|
p1 = points[points.Length - 1];
|
||||||
|
p2 = points[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
t -= totalPercent;
|
||||||
|
|
||||||
|
return GetPoint(p1, p2, t / curvePercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Get the index of the given point in this curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The index, or -1 if the point is not found
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='point'>
|
||||||
|
/// - Point to search for
|
||||||
|
/// </param>
|
||||||
|
public int GetPointIndex(BezierPoint point)
|
||||||
|
{
|
||||||
|
int result = -1;
|
||||||
|
for(int i = 0; i < points.Length; i++)
|
||||||
|
{
|
||||||
|
if(points[i] == point)
|
||||||
|
{
|
||||||
|
result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Sets this curve to 'dirty'
|
||||||
|
/// - Forces the curve to recalculate its length
|
||||||
|
/// </summary>
|
||||||
|
public void SetDirty()
|
||||||
|
{
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PublicStaticFunctions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Draws the curve in the Editor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The bezier point at the beginning of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The bezier point at the end of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='resolution'>
|
||||||
|
/// - The number of segments along the curve to draw
|
||||||
|
/// </param>
|
||||||
|
public static void DrawCurve(BezierPoint p1, BezierPoint p2, int resolution)
|
||||||
|
{
|
||||||
|
int limit = resolution+1;
|
||||||
|
float _res = resolution;
|
||||||
|
Vector3 lastPoint = p1.position;
|
||||||
|
Vector3 currentPoint = Vector3.zero;
|
||||||
|
|
||||||
|
for(int i = 1; i < limit; i++){
|
||||||
|
currentPoint = GetPoint(p1, p2, i/_res);
|
||||||
|
Gizmos.DrawLine(lastPoint, currentPoint);
|
||||||
|
lastPoint = currentPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets the point 't' percent along a curve
|
||||||
|
/// - Automatically calculates for the number of relevant points
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point 't' percent along the curve
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The bezier point at the beginning of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The bezier point at the end of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the curve (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
public static Vector3 GetPoint(BezierPoint p1, BezierPoint p2, float t)
|
||||||
|
{
|
||||||
|
if(p1.handle2 != Vector3.zero)
|
||||||
|
{
|
||||||
|
if(p2.handle1 != Vector3.zero) return GetCubicCurvePoint(p1.position, p1.globalHandle2, p2.globalHandle1, p2.position, t);
|
||||||
|
else return GetQuadraticCurvePoint(p1.position, p1.globalHandle2, p2.position, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(p2.handle1 != Vector3.zero) return GetQuadraticCurvePoint(p1.position, p2.globalHandle1, p2.position, t);
|
||||||
|
else return GetLinearPoint(p1.position, p2.position, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets the point 't' percent along a third-order curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point 't' percent along the curve
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The point at the beginning of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The second point along the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p3'>
|
||||||
|
/// - The third point along the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p4'>
|
||||||
|
/// - The point at the end of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the curve (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
public static Vector3 GetCubicCurvePoint(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, float t)
|
||||||
|
{
|
||||||
|
t = Mathf.Clamp01(t);
|
||||||
|
|
||||||
|
Vector3 part1 = Mathf.Pow(1 - t, 3) * p1;
|
||||||
|
Vector3 part2 = 3 * Mathf.Pow(1 - t, 2) * t * p2;
|
||||||
|
Vector3 part3 = 3 * (1 - t) * Mathf.Pow(t, 2) * p3;
|
||||||
|
Vector3 part4 = Mathf.Pow(t, 3) * p4;
|
||||||
|
|
||||||
|
return part1 + part2 + part3 + part4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets the point 't' percent along a second-order curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point 't' percent along the curve
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The point at the beginning of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The second point along the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p3'>
|
||||||
|
/// - The point at the end of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the curve (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
public static Vector3 GetQuadraticCurvePoint(Vector3 p1, Vector3 p2, Vector3 p3, float t)
|
||||||
|
{
|
||||||
|
t = Mathf.Clamp01(t);
|
||||||
|
|
||||||
|
Vector3 part1 = Mathf.Pow(1 - t, 2) * p1;
|
||||||
|
Vector3 part2 = 2 * (1 - t) * t * p2;
|
||||||
|
Vector3 part3 = Mathf.Pow(t, 2) * p3;
|
||||||
|
|
||||||
|
return part1 + part2 + part3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets point 't' percent along a linear "curve" (line)
|
||||||
|
/// - This is exactly equivalent to Vector3.Lerp
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point 't' percent along the curve
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The point at the beginning of the line
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The point at the end of the line
|
||||||
|
/// </param>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the line (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
public static Vector3 GetLinearPoint(Vector3 p1, Vector3 p2, float t)
|
||||||
|
{
|
||||||
|
return p1 + ((p2 - p1) * t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Gets point 't' percent along n-order curve
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The point 't' percent along the curve
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='t'>
|
||||||
|
/// - Value between 0 and 1 representing the percent along the curve (0 = 0%, 1 = 100%)
|
||||||
|
/// </param>
|
||||||
|
/// <param name='points'>
|
||||||
|
/// - The points used to define the curve
|
||||||
|
/// </param>
|
||||||
|
public static Vector3 GetPoint(float t, params Vector3[] points){
|
||||||
|
t = Mathf.Clamp01(t);
|
||||||
|
|
||||||
|
int order = points.Length-1;
|
||||||
|
Vector3 point = Vector3.zero;
|
||||||
|
Vector3 vectorToAdd;
|
||||||
|
|
||||||
|
for(int i = 0; i < points.Length; i++){
|
||||||
|
vectorToAdd = points[points.Length-i-1] * (BinomialCoefficient(i, order) * Mathf.Pow(t, order-i) * Mathf.Pow((1-t), i));
|
||||||
|
point += vectorToAdd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Approximates the length
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// - The approximate length
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='p1'>
|
||||||
|
/// - The bezier point at the start of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='p2'>
|
||||||
|
/// - The bezier point at the end of the curve
|
||||||
|
/// </param>
|
||||||
|
/// <param name='resolution'>
|
||||||
|
/// - The number of points along the curve used to create measurable segments
|
||||||
|
/// </param>
|
||||||
|
public static float ApproximateLength(BezierPoint p1, BezierPoint p2, int resolution = 10)
|
||||||
|
{
|
||||||
|
float _res = resolution;
|
||||||
|
float total = 0;
|
||||||
|
Vector3 lastPosition = p1.position;
|
||||||
|
Vector3 currentPosition;
|
||||||
|
|
||||||
|
for(int i = 0; i < resolution + 1; i++)
|
||||||
|
{
|
||||||
|
currentPosition = GetPoint(p1, p2, i / _res);
|
||||||
|
total += (currentPosition - lastPosition).magnitude;
|
||||||
|
lastPosition = currentPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region UtilityFunctions
|
||||||
|
|
||||||
|
private static int BinomialCoefficient(int i, int n){
|
||||||
|
return Factoral(n)/(Factoral(i)*Factoral(n-i));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Factoral(int i){
|
||||||
|
if(i == 0) return 1;
|
||||||
|
|
||||||
|
int total = 1;
|
||||||
|
|
||||||
|
while(i-1 >= 0){
|
||||||
|
total *= i;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public Vector3 GetPointAtDistance(float distance)
|
||||||
|
{
|
||||||
|
if(close)
|
||||||
|
{
|
||||||
|
if(distance < 0) while(distance < 0) { distance += length; }
|
||||||
|
else if(distance > length) while(distance > length) { distance -= length; }
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(distance <= 0) return points[0].position;
|
||||||
|
else if(distance >= length) return points[points.Length - 1].position;
|
||||||
|
}
|
||||||
|
|
||||||
|
float totalLength = 0;
|
||||||
|
float curveLength = 0;
|
||||||
|
|
||||||
|
BezierPoint firstPoint = null;
|
||||||
|
BezierPoint secondPoint = null;
|
||||||
|
|
||||||
|
for(int i = 0; i < points.Length - 1; i++)
|
||||||
|
{
|
||||||
|
curveLength = ApproximateLength(points[i], points[i + 1], resolution);
|
||||||
|
if(totalLength + curveLength >= distance)
|
||||||
|
{
|
||||||
|
firstPoint = points[i];
|
||||||
|
secondPoint = points[i+1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else totalLength += curveLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(firstPoint == null)
|
||||||
|
{
|
||||||
|
firstPoint = points[points.Length - 1];
|
||||||
|
secondPoint = points[0];
|
||||||
|
curveLength = ApproximateLength(firstPoint, secondPoint, resolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
distance -= totalLength;
|
||||||
|
return GetPoint(firstPoint, secondPoint, distance / curveLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4234cd2c43978e041bbe9323c195c4bd
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+170
@@ -0,0 +1,170 @@
|
|||||||
|
#region UsingStatements
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Helper class for storing and manipulating Bezier Point data
|
||||||
|
/// - Ensures that handles are in correct relation to one another
|
||||||
|
/// - Handles adding/removing self from curve point lists
|
||||||
|
/// - Calls SetDirty() on curve when edited
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class BezierPoint : MonoBehaviour{
|
||||||
|
|
||||||
|
#region PublicEnumerations
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Enumeration describing the relationship between a point's handles
|
||||||
|
/// - Connected : The point's handles are mirrored across the point
|
||||||
|
/// - Broken : Each handle moves independently of the other
|
||||||
|
/// - None : This point has no handles (both handles are located ON the point)
|
||||||
|
/// </summary>
|
||||||
|
public enum HandleStyle
|
||||||
|
{
|
||||||
|
Connected,
|
||||||
|
Broken,
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PublicProperties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Curve this point belongs to
|
||||||
|
/// - Changing this value will automatically remove this point from the current curve and add it to the new one
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField]
|
||||||
|
private BezierCurve _curve;
|
||||||
|
public BezierCurve curve
|
||||||
|
{
|
||||||
|
get{return _curve;}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(_curve) _curve.RemovePoint(this);
|
||||||
|
_curve = value;
|
||||||
|
_curve.AddPoint(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Value describing the relationship between this point's handles
|
||||||
|
/// </summary>
|
||||||
|
public HandleStyle handleStyle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Shortcut to transform.position
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// - The point's world position
|
||||||
|
/// </value>
|
||||||
|
public Vector3 position
|
||||||
|
{
|
||||||
|
get { return transform.position; }
|
||||||
|
set { transform.position = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Shortcut to transform.localPosition
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// - The point's local position.
|
||||||
|
/// </value>
|
||||||
|
public Vector3 localPosition
|
||||||
|
{
|
||||||
|
get { return transform.localPosition; }
|
||||||
|
set { transform.localPosition = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Local position of the first handle
|
||||||
|
/// - Setting this value will cause the curve to become dirty
|
||||||
|
/// - This handle effects the curve generated from this point and the point proceeding it in curve.points
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField]
|
||||||
|
private Vector3 _handle1;
|
||||||
|
public Vector3 handle1
|
||||||
|
{
|
||||||
|
get { return _handle1; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(_handle1 == value) return;
|
||||||
|
_handle1 = value;
|
||||||
|
if(handleStyle == HandleStyle.None) handleStyle = HandleStyle.Broken;
|
||||||
|
else if(handleStyle == HandleStyle.Connected) _handle2 = -value;
|
||||||
|
_curve.SetDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Global position of the first handle
|
||||||
|
/// - Ultimately stored in the 'handle1' variable
|
||||||
|
/// - Setting this value will cause the curve to become dirty
|
||||||
|
/// - This handle effects the curve generated from this point and the point proceeding it in curve.points
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 globalHandle1
|
||||||
|
{
|
||||||
|
get{return transform.TransformPoint(handle1);}
|
||||||
|
set{handle1 = transform.InverseTransformPoint(value);}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Local position of the second handle
|
||||||
|
/// - Setting this value will cause the curve to become dirty
|
||||||
|
/// - This handle effects the curve generated from this point and the point coming after it in curve.points
|
||||||
|
/// </summary>
|
||||||
|
[SerializeField]
|
||||||
|
private Vector3 _handle2;
|
||||||
|
public Vector3 handle2
|
||||||
|
{
|
||||||
|
get { return _handle2; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if(_handle2 == value) return;
|
||||||
|
_handle2 = value;
|
||||||
|
if(handleStyle == HandleStyle.None) handleStyle = HandleStyle.Broken;
|
||||||
|
else if(handleStyle == HandleStyle.Connected) _handle1 = -value;
|
||||||
|
_curve.SetDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Global position of the second handle
|
||||||
|
/// - Ultimately stored in the 'handle2' variable
|
||||||
|
/// - Setting this value will cause the curve to become dirty
|
||||||
|
/// - This handle effects the curve generated from this point and the point coming after it in curve.points
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 globalHandle2
|
||||||
|
{
|
||||||
|
get{return transform.TransformPoint(handle2);}
|
||||||
|
set{handle2 = transform.InverseTransformPoint(value);}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PrivateVariables
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// - Used to determine if this point has moved since the last frame
|
||||||
|
/// </summary>
|
||||||
|
private Vector3 lastPosition;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region MonoBehaviourFunctions
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if(!_curve.dirty && transform.position != lastPosition)
|
||||||
|
{
|
||||||
|
_curve.SetDirty();
|
||||||
|
lastPosition = transform.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1dff893e341592e438963ea8cbceb377
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
Product : Bezier Curve Editor Package
|
||||||
|
Studio : Arkham Interactive
|
||||||
|
Date : September 9th, 2013
|
||||||
|
Version : 1.0
|
||||||
|
Email : support@arkhaminteractive.com
|
||||||
|
|
||||||
|
How to use:
|
||||||
|
1) Add BezierCurve package to your Unity project
|
||||||
|
2a) Add BezierCurve.cs script from Assets/BezierCurves/Scripts to any object
|
||||||
|
2b) Alternatively, select GameObject/Create Other/Bezier Curve
|
||||||
|
3) Use "Add Point" button to add bezier points to the curve
|
||||||
|
4) Use "X" button to remove bezier points from the curve
|
||||||
|
5) Use "/\" or "\/" to move points up or down in the curve order
|
||||||
|
|
||||||
|
- The BezierCurve class also contains static functions used for getting points on first, second, and third order bezier curves.
|
||||||
|
- These functions take the positions of the anchor points as arguments.
|
||||||
|
- Instances of the BezierCurve object use these same functions to calculate positions.
|
||||||
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1c019e87c4c680d4ba6e2fb138a2e1ee
|
||||||
|
TextScriptImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -11,6 +11,10 @@ public class CameraFade : MonoBehaviour {
|
|||||||
|
|
||||||
static Material blitMaterial;
|
static Material blitMaterial;
|
||||||
|
|
||||||
|
public void SetFade(float alpha) {
|
||||||
|
this.alpha = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
if (!blitMaterial) {
|
if (!blitMaterial) {
|
||||||
@@ -20,8 +24,8 @@ public class CameraFade : MonoBehaviour {
|
|||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
int deviceIndex = 4;
|
//int deviceIndex = 3;
|
||||||
alpha = SteamVR_Controller.Input(deviceIndex).GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
|
//alpha = SteamVR_Controller.Input(deviceIndex).GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnRenderImage(RenderTexture src, RenderTexture dest) {
|
void OnRenderImage(RenderTexture src, RenderTexture dest) {
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f36a6f9524b5e3e4aa56aa8b1e8aba72
|
||||||
|
timeCreated: 1463676857
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+121
@@ -0,0 +1,121 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: baf816cb3aa55494abd732a0d093c95a
|
||||||
|
timeCreated: 1463668249
|
||||||
|
licenseType: Free
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 19
|
||||||
|
fileIDToRecycleName:
|
||||||
|
100000: Armature
|
||||||
|
100002: Bone1
|
||||||
|
100004: Bone2
|
||||||
|
100006: Bone3
|
||||||
|
100008: Bone4
|
||||||
|
100010: Bone5
|
||||||
|
100012: Bone5_end
|
||||||
|
100014: Circle
|
||||||
|
100016: Circle_MeshPart0
|
||||||
|
100018: Circle_MeshPart1
|
||||||
|
100020: Circle_MeshPart2
|
||||||
|
100022: Circle_MeshPart3
|
||||||
|
100024: Circle_MeshPart4
|
||||||
|
100026: Circle_MeshPart5
|
||||||
|
100028: Circle_MeshPart6
|
||||||
|
100030: //RootNode
|
||||||
|
100032: Root
|
||||||
|
400000: Armature
|
||||||
|
400002: Bone1
|
||||||
|
400004: Bone2
|
||||||
|
400006: Bone3
|
||||||
|
400008: Bone4
|
||||||
|
400010: Bone5
|
||||||
|
400012: Bone5_end
|
||||||
|
400014: Circle
|
||||||
|
400016: Circle_MeshPart0
|
||||||
|
400018: Circle_MeshPart1
|
||||||
|
400020: Circle_MeshPart2
|
||||||
|
400022: Circle_MeshPart3
|
||||||
|
400024: Circle_MeshPart4
|
||||||
|
400026: Circle_MeshPart5
|
||||||
|
400028: Circle_MeshPart6
|
||||||
|
400030: //RootNode
|
||||||
|
400032: Root
|
||||||
|
4300000: Circle_MeshPart0
|
||||||
|
4300002: Circle_MeshPart1
|
||||||
|
4300004: Circle_MeshPart2
|
||||||
|
4300006: Circle_MeshPart3
|
||||||
|
4300008: Circle_MeshPart4
|
||||||
|
4300010: Circle_MeshPart5
|
||||||
|
4300012: Circle_MeshPart6
|
||||||
|
7400000: Armature|ArmatureAction
|
||||||
|
9500000: //RootNode
|
||||||
|
13700000: Circle_MeshPart0
|
||||||
|
13700002: Circle_MeshPart1
|
||||||
|
13700004: Circle_MeshPart2
|
||||||
|
13700006: Circle_MeshPart3
|
||||||
|
13700008: Circle_MeshPart4
|
||||||
|
13700010: Circle_MeshPart5
|
||||||
|
13700012: Circle_MeshPart6
|
||||||
|
materials:
|
||||||
|
importMaterials: 1
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleRotations: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
motionNodeName:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 1
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
importBlendShapes: 1
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
optimizeMeshForGPU: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
importAnimation: 1
|
||||||
|
copyAvatar: 0
|
||||||
|
humanDescription:
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
animationType: 2
|
||||||
|
humanoidOversampling: 1
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c496a453085c5a4d97fc65212ab3afb
|
||||||
|
timeCreated: 1463670446
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a012f334991a2f343817365493d55ea1
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1463689726
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 20f750e5957fb9f439c9216bbf14c569
|
||||||
|
timeCreated: 1463689741
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d050741419ef7064cbbf53934a7f7353
|
||||||
|
timeCreated: 1463689745
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -3,26 +3,63 @@ using System.Collections;
|
|||||||
|
|
||||||
public class LeftController : MonoBehaviour {
|
public class LeftController : MonoBehaviour {
|
||||||
|
|
||||||
|
public bool AlwaysCenter = false;
|
||||||
|
|
||||||
|
|
||||||
|
private Transform controllerRig;
|
||||||
|
private SteamVR_TrackedController trackedController;
|
||||||
|
|
||||||
|
private GameObject mainCamera;
|
||||||
|
private GameObject warehouseCamera;
|
||||||
|
|
||||||
|
private CameraFade cameraFade;
|
||||||
|
private SteamVR_Camera mainSteamVRCamera;
|
||||||
|
|
||||||
|
private bool inWarehouse = false;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
var trackedController = GetComponent<SteamVR_TrackedController>();
|
controllerRig = this.transform.parent;
|
||||||
|
|
||||||
|
trackedController = GetComponent<SteamVR_TrackedController>();
|
||||||
trackedController.TriggerClicked += TriggerClicked;
|
trackedController.TriggerClicked += TriggerClicked;
|
||||||
trackedController.Gripped += Gripped;
|
trackedController.Gripped += Gripped;
|
||||||
}
|
|
||||||
|
mainCamera = GameObject.Find("Main Camera (origin)");
|
||||||
|
warehouseCamera = GameObject.Find("Warehouse Camera (origin)");
|
||||||
|
|
||||||
|
cameraFade = mainCamera.GetComponentInChildren<CameraFade>();
|
||||||
|
mainSteamVRCamera = mainCamera.GetComponentInChildren<SteamVR_Camera>();
|
||||||
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
|
float alpha = SteamVR_Controller.Input((int)trackedController.controllerIndex).GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
|
||||||
|
if (alpha > 0.05) {
|
||||||
|
cameraFade.SetFade(alpha);
|
||||||
|
if (!inWarehouse) {
|
||||||
|
controllerRig.SetParent(warehouseCamera.transform, false);
|
||||||
|
if (AlwaysCenter) {
|
||||||
|
warehouseCamera.transform.localPosition = new Vector3(-mainSteamVRCamera.head.localPosition.x, warehouseCamera.transform.localPosition.y, -mainSteamVRCamera.head.localPosition.z);
|
||||||
|
}
|
||||||
|
inWarehouse = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cameraFade.SetFade(0.0f);
|
||||||
|
if (inWarehouse) {
|
||||||
|
controllerRig.SetParent(mainCamera.transform, false);
|
||||||
|
inWarehouse = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerClicked(object sender, ClickedEventArgs e) {
|
void TriggerClicked(object sender, ClickedEventArgs e) {
|
||||||
SteamVR_Fade.Start(Color.black, 2);
|
|
||||||
//var warehouseCamera = GameObject.FindWithTag("WarehouseCamera").GetComponent<SteamVR_Camera>();
|
//var warehouseCamera = GameObject.FindWithTag("WarehouseCamera").GetComponent<SteamVR_Camera>();
|
||||||
//warehouseCamera.enabled = true;
|
//warehouseCamera.enabled = true;
|
||||||
|
Debug.Log("awd");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gripped(object sender, ClickedEventArgs e) {
|
void Gripped(object sender, ClickedEventArgs e) {
|
||||||
var warehouseCamera = GameObject.FindWithTag("WarehouseCamera").GetComponent<SteamVR_Camera>();
|
|
||||||
warehouseCamera.enabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cdbdaac5b008da54694cee489bc57287
|
||||||
|
timeCreated: 1463668249
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 785d00a1d77d51142bdbd18431b592c7
|
||||||
|
timeCreated: 1463666876
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f8746632966a9d489e51277b6a89fd3
|
||||||
|
timeCreated: 1463666875
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+78
@@ -0,0 +1,78 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 930e0304420db7d4ea1c3e6b73721682
|
||||||
|
timeCreated: 1463666876
|
||||||
|
licenseType: Free
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 19
|
||||||
|
fileIDToRecycleName:
|
||||||
|
100000: default
|
||||||
|
100002: //RootNode
|
||||||
|
400000: default
|
||||||
|
400002: //RootNode
|
||||||
|
2300000: default
|
||||||
|
3300000: default
|
||||||
|
4300000: default
|
||||||
|
materials:
|
||||||
|
importMaterials: 1
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleRotations: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
motionNodeName:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 1
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
importBlendShapes: 1
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
optimizeMeshForGPU: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
importAnimation: 1
|
||||||
|
copyAvatar: 0
|
||||||
|
humanDescription:
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
animationType: 0
|
||||||
|
humanoidOversampling: 1
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c7fff8a80b497e245857fbcc47a9134c
|
||||||
|
timeCreated: 1463666875
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 0
|
||||||
|
cubemapConvolution: 0
|
||||||
|
cubemapConvolutionSteps: 7
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: -1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
textureType: -1
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -422,6 +422,22 @@ public class SteamVR_Camera : MonoBehaviour
|
|||||||
SteamVR_Utils.QueueEventOnRenderThread(eventID);
|
SteamVR_Utils.QueueEventOnRenderThread(eventID);
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
Graphics.SetRenderTarget(dest);
|
||||||
|
SteamVR_Camera.blitMaterial.mainTexture = src;
|
||||||
|
|
||||||
|
GL.PushMatrix();
|
||||||
|
GL.LoadOrtho();
|
||||||
|
SteamVR_Camera.blitMaterial.SetPass(0);
|
||||||
|
GL.Begin(GL.QUADS);
|
||||||
|
GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0);
|
||||||
|
GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0);
|
||||||
|
GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0);
|
||||||
|
GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0);
|
||||||
|
GL.End();
|
||||||
|
GL.PopMatrix();
|
||||||
|
|
||||||
|
Graphics.SetRenderTarget(null);
|
||||||
} else {
|
} else {
|
||||||
if (SteamVR_Render.eye == EVREye.Eye_Right) {
|
if (SteamVR_Render.eye == EVREye.Eye_Right) {
|
||||||
Graphics.Blit(src, RightEyeRenderTexture);
|
Graphics.Blit(src, RightEyeRenderTexture);
|
||||||
@@ -431,21 +447,7 @@ public class SteamVR_Camera : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Graphics.SetRenderTarget(dest);
|
|
||||||
//SteamVR_Camera.blitMaterial.mainTexture = src;
|
|
||||||
|
|
||||||
//GL.PushMatrix();
|
|
||||||
//GL.LoadOrtho();
|
|
||||||
//SteamVR_Camera.blitMaterial.SetPass(0);
|
|
||||||
//GL.Begin(GL.QUADS);
|
|
||||||
//GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0);
|
|
||||||
//GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0);
|
|
||||||
//GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0);
|
|
||||||
//GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0);
|
|
||||||
//GL.End();
|
|
||||||
//GL.PopMatrix();
|
|
||||||
|
|
||||||
//Graphics.SetRenderTarget(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Binary file not shown.
Executable
+87
@@ -0,0 +1,87 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class WarehouseRow : MonoBehaviour {
|
||||||
|
public GameObject[] Prefabs;
|
||||||
|
public bool ShowInEditor = false;
|
||||||
|
|
||||||
|
BezierCurve curve;
|
||||||
|
|
||||||
|
List<GameObject> furnitures;
|
||||||
|
|
||||||
|
float offset = 0;
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start() {
|
||||||
|
curve = GetComponent<BezierCurve>();
|
||||||
|
furnitures = new List<GameObject>();
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
EditorApplication.playmodeStateChanged += StateChange;
|
||||||
|
#endif
|
||||||
|
spawnPrefabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnEnable() {
|
||||||
|
spawnPrefabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable() {
|
||||||
|
foreach (var item in furnitures) {
|
||||||
|
GameObject.DestroyImmediate(item);
|
||||||
|
}
|
||||||
|
furnitures.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy() {
|
||||||
|
foreach (var item in furnitures) {
|
||||||
|
GameObject.DestroyImmediate(item);
|
||||||
|
}
|
||||||
|
furnitures.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateChange() {
|
||||||
|
if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) {
|
||||||
|
OnDisable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnValidate() {
|
||||||
|
foreach (var item in furnitures) {
|
||||||
|
GameObject.DestroyImmediate(item);
|
||||||
|
}
|
||||||
|
furnitures.Clear();
|
||||||
|
spawnPrefabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void spawnPrefabs() {
|
||||||
|
if (furnitures.Count == 0) {
|
||||||
|
for (int i = 0; i < Prefabs.Length; i++) {
|
||||||
|
var prefab = Prefabs[i];
|
||||||
|
|
||||||
|
GameObject furniture = Instantiate(prefab);
|
||||||
|
furniture.transform.SetParent(transform);
|
||||||
|
furnitures.Add(furniture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update() {
|
||||||
|
if (Application.isPlaying) {
|
||||||
|
offset += Time.deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < furnitures.Count; i++) {
|
||||||
|
var furniture = furnitures[i];
|
||||||
|
|
||||||
|
var distance = (float)i / (furnitures.Count - 1) * curve.length + offset;
|
||||||
|
distance = Mathf.Repeat(distance, curve.length);
|
||||||
|
var pos = curve.GetPointAtDistance(distance);
|
||||||
|
furniture.transform.position = pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d2bd389e77eda6e4b9d010637a29833a
|
||||||
|
timeCreated: 1463689433
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
Reference in New Issue
Block a user