This commit is contained in:
CortexCore
2023-06-05 16:25:06 +08:00
parent 9027120bb8
commit 4565ff2e35
2947 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
{
"name": "UnitySpline",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:21d1eb854b91ade49bc69a263d12bee2",
"GUID:a209c53514018594f9f482516f2a6781",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:66d2ae14764cc7d49aad4b16930747c0",
"GUID:d8b63aba1907145bea998dd612889d6b"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"UnitySplines"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Splines;
namespace BITKit.Spline
{
public interface ISplineContainer
{
Transform Position { get; }
Transform TangentIn { get; }
Transform TangentOut { get; }
}
[System.Serializable]
public class BasicSplineContainer : ISplineContainer
{
public Transform m_transform;
public Transform m_tangentIn;
public Transform m_tangentOut;
public Transform Position => m_transform;
public Transform TangentIn => m_tangentIn;
public Transform TangentOut => m_tangentOut;
}
[ExecuteAlways]
public class UnitySplineCreator : MonoBehaviour
{
[SerializeReference, SubclassSelector] public List<ISplineContainer> splines = new();
public SplineContainer container;
public SplineExtrude extrude;
[Header(Constant.Header.Settings)]
public int updateTimes;
void Update()
{
UnityEngine.Splines.Spline spline = new();
foreach (var x in splines)
{
spline.Add(new BezierKnot()
{
Position = x.Position.position,
Rotation = x.Position.rotation,
TangentIn = x.TangentIn ? x.TangentIn.position : Vector3.zero,
TangentOut = x.TangentOut ? x.TangentOut.position : Vector3.zero,
});
}
container.Spline = spline;
extrude.Rebuild();
updateTimes++;
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Splines;
namespace BITKit
{
[ExecuteAlways]
public class UnitySplineRebuilder : MonoBehaviour
{
[Header(Constant.Header.Settings)]
[Range(0, 1)]
public float elapsedTime;
public bool allowAnimate;
[Header(Constant.Header.Debug)]
public float m_elapsedTime;
[Header(Constant.Header.Components)]
public SplineContainer container;
public SplineExtrude extrude;
public SplineAnimate animate;
void Update()
{
extrude?.Rebuild();
if (allowAnimate && animate)
{
animate.ElapsedTime = elapsedTime;
}
m_elapsedTime = elapsedTime;
}
}
}

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Splines;
namespace BITKit
{
public class UnityWireSplineCreator : MonoBehaviour,IAction
{
public Mesh mesh;
public SplineContainer container;
public SplineExtrude extrude;
// ReSharper disable Unity.PerformanceAnalysis
[ContextMenu(nameof(Excute))]
public void Excute()
{
UnityEngine.Splines.Spline spline = new();
var count = 0;
// foreach (var vertexes in MathE.Combinations(mesh.vertices))
// {
// foreach (var vertex in vertexes)
// {
// spline.Add(new BezierKnot()
// {
// Position = vertex
// });
// count++;
// }
// }
foreach (var vertex in mesh.vertices)
{
spline.Add(new (vertex));
count++;
}
container.Spline = spline;
extrude.Rebuild();
Debug.Log($"已创建{count}个顶点");
}
}
}