添加插件
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiColorDataChannel : ObiPathDataChannelIdentity<Color>
|
||||
{
|
||||
public ObiColorDataChannel() : base(new ObiColorInterpolator3D()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4078c779a63154dddac14f5a1e65a692
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiPhaseDataChannel : ObiPathDataChannelIdentity<int>
|
||||
{
|
||||
public ObiPhaseDataChannel() : base(new ObiConstantInterpolator()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cfdcf019ed7249799993815bfc3c0bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiMassDataChannel : ObiPathDataChannelIdentity<float>
|
||||
{
|
||||
public ObiMassDataChannel() : base(new ObiCatmullRomInterpolator()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e55025008fa8f4bccae82dbaded0f019
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiNormalDataChannel : ObiPathDataChannelIdentity<Vector3>
|
||||
{
|
||||
public ObiNormalDataChannel() : base(new ObiCatmullRomInterpolator3D()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4721087e73d0d422ab48ad62a2fd3d3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
public interface IObiPathDataChannel
|
||||
{
|
||||
int Count { get; }
|
||||
bool Dirty { get; }
|
||||
void Clean();
|
||||
void RemoveAt(int index);
|
||||
}
|
||||
|
||||
public abstract class ObiPathDataChannel<T,U> : IObiPathDataChannel
|
||||
{
|
||||
protected ObiInterpolator<U> interpolator;
|
||||
protected bool dirty = false;
|
||||
public List<T> data = new List<T>();
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return data.Count; }
|
||||
}
|
||||
|
||||
public bool Dirty
|
||||
{
|
||||
get { return dirty; }
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
public ObiPathDataChannel(ObiInterpolator<U> interpolator)
|
||||
{
|
||||
this.interpolator = interpolator;
|
||||
}
|
||||
|
||||
public T this[int i]
|
||||
{
|
||||
get { return data[i]; }
|
||||
set { data[i] = value; dirty = true; }
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
data.RemoveAt(index);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public U Evaluate(U v0, U v1, U v2, U v3, float mu)
|
||||
{
|
||||
return interpolator.Evaluate(v0, v1, v2, v3, mu);
|
||||
}
|
||||
public U EvaluateFirstDerivative(U v0, U v1, U v2, U v3, float mu)
|
||||
{
|
||||
return interpolator.EvaluateFirstDerivative(v0, v1, v2, v3, mu);
|
||||
}
|
||||
public U EvaluateSecondDerivative(U v0, U v1, U v2, U v3, float mu)
|
||||
{
|
||||
return interpolator.EvaluateSecondDerivative(v0, v1, v2, v3, mu);
|
||||
}
|
||||
|
||||
public int GetSpanCount(bool closed)
|
||||
{
|
||||
int cps = Count;
|
||||
if (cps < 2)
|
||||
return 0;
|
||||
|
||||
return closed ? cps : cps - 1;
|
||||
}
|
||||
|
||||
public int GetSpanControlPointAtMu(bool closed, float mu, out float spanMu)
|
||||
{
|
||||
|
||||
int spanCount = GetSpanCount(closed);
|
||||
spanMu = mu * spanCount;
|
||||
int i = (mu >= 1f) ? (spanCount - 1) : (int)spanMu;
|
||||
spanMu -= i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43ab47ea5c62b45248edce6a9d099626
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
public abstract class ObiPathDataChannelIdentity<T> : ObiPathDataChannel<T,T>
|
||||
{
|
||||
public ObiPathDataChannelIdentity(ObiInterpolator<T> interpolator) : base(interpolator)
|
||||
{
|
||||
}
|
||||
|
||||
public T GetFirstDerivative(int index)
|
||||
{
|
||||
int nextCP = (index + 1) % Count;
|
||||
|
||||
return EvaluateFirstDerivative(this[index],
|
||||
this[index],
|
||||
this[nextCP],
|
||||
this[nextCP], 0);
|
||||
}
|
||||
|
||||
public T GetSecondDerivative(int index)
|
||||
{
|
||||
int nextCP = (index + 1) % Count;
|
||||
|
||||
return EvaluateSecondDerivative(this[index],
|
||||
this[index],
|
||||
this[nextCP],
|
||||
this[nextCP], 0);
|
||||
}
|
||||
|
||||
public T GetAtMu(bool closed, float mu)
|
||||
{
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
return Evaluate(this[i],
|
||||
this[i],
|
||||
this[nextCP],
|
||||
this[nextCP], p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get property in path because it has less than 2 control points.");
|
||||
}
|
||||
}
|
||||
|
||||
public T GetFirstDerivativeAtMu(bool closed, float mu)
|
||||
{
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
return EvaluateFirstDerivative(this[i],
|
||||
this[i],
|
||||
this[nextCP],
|
||||
this[nextCP], p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get derivative in path because it has less than 2 control points.");
|
||||
}
|
||||
}
|
||||
|
||||
public T GetSecondDerivativeAtMu(bool closed, float mu)
|
||||
{
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
return EvaluateSecondDerivative(this[i],
|
||||
this[i],
|
||||
this[nextCP],
|
||||
this[nextCP], p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get second derivative in path because it has less than 2 control points.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61b5c82c04eb14f1999e94baa1f073bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,124 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiPointsDataChannel : ObiPathDataChannel<ObiWingedPoint, Vector3>
|
||||
{
|
||||
|
||||
public ObiPointsDataChannel() : base(new ObiCatmullRomInterpolator3D()) { }
|
||||
|
||||
public Vector3 GetTangent(int index)
|
||||
{
|
||||
int nextCP = (index + 1) % Count;
|
||||
|
||||
var wp1 = this[index];
|
||||
var wp2 = this[nextCP];
|
||||
|
||||
return EvaluateFirstDerivative(wp1.position,
|
||||
wp1.outTangentEndpoint,
|
||||
wp2.inTangentEndpoint,
|
||||
wp2.position, 0);
|
||||
}
|
||||
|
||||
public Vector3 GetAcceleration(int index)
|
||||
{
|
||||
int nextCP = (index + 1) % Count;
|
||||
|
||||
var wp1 = this[index];
|
||||
var wp2 = this[nextCP];
|
||||
|
||||
return EvaluateSecondDerivative(wp1.position,
|
||||
wp1.outTangentEndpoint,
|
||||
wp2.inTangentEndpoint,
|
||||
wp2.position, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns spline position at time mu, with 0<=mu<=1 where 0 is the start of the spline
|
||||
* and 1 is the end.
|
||||
*/
|
||||
public Vector3 GetPositionAtMu(bool closed,float mu)
|
||||
{
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
var wp1 = this[i];
|
||||
var wp2 = this[nextCP];
|
||||
|
||||
return Evaluate(wp1.position,
|
||||
wp1.outTangentEndpoint,
|
||||
wp2.inTangentEndpoint,
|
||||
wp2.position, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get position in path because it has zero control points.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns normal tangent vector at time mu, with 0<=mu<=1 where 0 is the start of the spline
|
||||
* and 1 is the end.
|
||||
*/
|
||||
public Vector3 GetTangentAtMu(bool closed, float mu)
|
||||
{
|
||||
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
var wp1 = this[i];
|
||||
var wp2 = this[nextCP];
|
||||
|
||||
return EvaluateFirstDerivative(wp1.position,
|
||||
wp1.outTangentEndpoint,
|
||||
wp2.inTangentEndpoint,
|
||||
wp2.position, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get derivative in path because it has less than 2 control points.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns acceleration at time mu, with 0<=mu<=1 where 0 is the start of the spline
|
||||
* and 1 is the end.
|
||||
*/
|
||||
public Vector3 GetAccelerationAtMu(bool closed, float mu)
|
||||
{
|
||||
|
||||
int cps = Count;
|
||||
if (cps >= 2)
|
||||
{
|
||||
float p;
|
||||
int i = GetSpanControlPointAtMu(closed, mu, out p);
|
||||
int nextCP = (i + 1) % cps;
|
||||
|
||||
var wp1 = this[i];
|
||||
var wp2 = this[nextCP];
|
||||
|
||||
return EvaluateSecondDerivative(wp1.position,
|
||||
wp1.outTangentEndpoint,
|
||||
wp2.inTangentEndpoint,
|
||||
wp2.position, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Cannot get second derivative in path because it has less than 2 control points.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d710ff448ae4e4a6f9351a678af9a8ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiRotationalMassDataChannel : ObiPathDataChannelIdentity<float>
|
||||
{
|
||||
public ObiRotationalMassDataChannel() : base(new ObiCatmullRomInterpolator()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c38822e5a79441a8177689f83644e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Obi
|
||||
{
|
||||
[Serializable]
|
||||
public class ObiThicknessDataChannel : ObiPathDataChannelIdentity<float>
|
||||
{
|
||||
public ObiThicknessDataChannel() : base(new ObiCatmullRomInterpolator()) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b414fbc6ce2db42299dc01619ed4fc97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user