summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/XWeaponTrail/Scripts
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-03-10 14:07:40 +0800
committerchai <chaifix@163.com>2022-03-10 14:07:40 +0800
commit22891bf59032ba88262824255a706d652031384b (patch)
tree7595439ba9966c9402d37e37cee5e8cf098757d5 /Assets/ThirdParty/XWeaponTrail/Scripts
parent8b04ea73e540067f83870b61d89db4868fea5e8a (diff)
* move folder
Diffstat (limited to 'Assets/ThirdParty/XWeaponTrail/Scripts')
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs250
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs.meta10
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs123
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs.meta10
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs282
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs.meta10
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs419
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs.meta10
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs80
-rw-r--r--Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs.meta10
10 files changed, 0 insertions, 1204 deletions
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs
deleted file mode 100644
index 33b32555..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-using UnityEngine;
-using System.Collections;
-using System.Collections.Generic;
-namespace XftWeapon {
- public class Spline
- {
-
- List<SplineControlPoint> mControlPoints = new List<SplineControlPoint>();
- List<SplineControlPoint> mSegments = new List<SplineControlPoint>();
-
-
- public int Granularity = 20;
-
-
- public SplineControlPoint this[int index]
- {
- get
- {
- if (index > -1 && index < mSegments.Count)
- return mSegments[index];
- else
- return null;
-
- }
- }
-
- public List<SplineControlPoint> Segments
- {
- get
- {
- return mSegments;
- }
- }
-
- public List<SplineControlPoint> ControlPoints
- {
- get
- {
- return mControlPoints;
- }
- }
-
-
- public SplineControlPoint NextControlPoint(SplineControlPoint controlpoint)
- {
- if (mControlPoints.Count == 0) return null;
-
- int i = controlpoint.ControlPointIndex + 1;
- if (i >= mControlPoints.Count)
- return null;
- else
- return mControlPoints[i];
- }
-
-
- public SplineControlPoint PreviousControlPoint(SplineControlPoint controlpoint)
- {
- if (mControlPoints.Count == 0) return null;
-
- int i = controlpoint.ControlPointIndex - 1;
- if (i < 0)
- return null;
- else
- return mControlPoints[i];
- }
-
- public Vector3 NextPosition(SplineControlPoint controlpoint)
- {
- SplineControlPoint seg = NextControlPoint(controlpoint);
- if (seg != null)
- return seg.Position;
- else
- return controlpoint.Position;
- }
-
-
- public Vector3 PreviousPosition(SplineControlPoint controlpoint)
- {
- SplineControlPoint seg = PreviousControlPoint(controlpoint);
- if (seg != null)
- return seg.Position;
- else
- return controlpoint.Position;
- }
-
-
- public Vector3 PreviousNormal(SplineControlPoint controlpoint)
- {
- SplineControlPoint seg = PreviousControlPoint(controlpoint);
- if (seg != null)
- return seg.Normal;
- else
- return controlpoint.Normal;
- }
-
- public Vector3 NextNormal(SplineControlPoint controlpoint)
- {
- SplineControlPoint seg = NextControlPoint(controlpoint);
- if (seg != null)
- return seg.Normal;
- else
- return controlpoint.Normal;
- }
-
- public SplineControlPoint LenToSegment(float t, out float localF)
- {
- SplineControlPoint seg = null;
-
- t = Mathf.Clamp01(t);
-
- float len = t * mSegments[mSegments.Count - 1].Dist;
-
-
- int index = 0;
- for (index = 0; index < mSegments.Count; index++)
- {
- if (mSegments[index].Dist >= len)
- {
- seg = mSegments[index];
- break;
- }
- }
-
- if (index == 0)
- {
- //skip the first frame.
- localF = 0f;
- return seg;
- }
-
- float PrevLen = 0f;
- int prevIdx = seg.SegmentIndex - 1;
- SplineControlPoint prevSeg = mSegments[prevIdx];
- PrevLen = seg.Dist - prevSeg.Dist;
- localF = (len - prevSeg.Dist) / PrevLen;
- return prevSeg;
-
- }
-
-
- public static Vector3 CatmulRom(Vector3 T0, Vector3 P0, Vector3 P1, Vector3 T1, float f)
- {
- double DT1 = -0.5;
- double DT2 = 1.5;
- double DT3 = -1.5;
- double DT4 = 0.5;
-
- double DE2 = -2.5;
- double DE3 = 2;
- double DE4 = -0.5;
-
- double DV1 = -0.5;
- double DV3 = 0.5;
-
- double FAX = DT1 * T0.x + DT2 * P0.x + DT3 * P1.x + DT4 * T1.x;
- double FBX = T0.x + DE2 * P0.x + DE3 * P1.x + DE4 * T1.x;
- double FCX = DV1 * T0.x + DV3 * P1.x;
- double FDX = P0.x;
-
- double FAY = DT1 * T0.y + DT2 * P0.y + DT3 * P1.y + DT4 * T1.y;
- double FBY = T0.y + DE2 * P0.y + DE3 * P1.y + DE4 * T1.y;
- double FCY = DV1 * T0.y + DV3 * P1.y;
- double FDY = P0.y;
-
- double FAZ = DT1 * T0.z + DT2 * P0.z + DT3 * P1.z + DT4 * T1.z;
- double FBZ = T0.z + DE2 * P0.z + DE3 * P1.z + DE4 * T1.z;
- double FCZ = DV1 * T0.z + DV3 * P1.z;
- double FDZ = P0.z;
-
- float FX = (float)(((FAX * f + FBX) * f + FCX) * f + FDX);
- float FY = (float)(((FAY * f + FBY) * f + FCY) * f + FDY);
- float FZ = (float)(((FAZ * f + FBZ) * f + FCZ) * f + FDZ);
-
- return new Vector3(FX, FY, FZ);
- }
-
-
- public Vector3 InterpolateByLen(float tl)
- {
- float localF;
- SplineControlPoint seg = LenToSegment(tl, out localF);
- return seg.Interpolate(localF);
- }
-
- public Vector3 InterpolateNormalByLen(float tl)
- {
- float localF;
- SplineControlPoint seg = LenToSegment(tl, out localF);
- return seg.InterpolateNormal(localF);
- }
-
- public SplineControlPoint AddControlPoint(Vector3 pos, Vector3 up)
- {
- SplineControlPoint cp = new SplineControlPoint();
-
- cp.Init(this);
-
- cp.Position = pos;
-
- cp.Normal = up;
-
- mControlPoints.Add(cp);
-
- cp.ControlPointIndex = mControlPoints.Count - 1;
-
-
- return cp;
- }
-
- public void Clear()
- {
- mControlPoints.Clear();
- }
-
-
- void RefreshDistance()
- {
- if (mSegments.Count < 1)
- return;
-
- mSegments[0].Dist = 0f;
-
- for (int i = 1; i < mSegments.Count; i++)
- {
-
- float prevLen = (mSegments[i].Position - mSegments[i - 1].Position).magnitude;
-
- mSegments[i].Dist = mSegments[i - 1].Dist + prevLen;
- }
- }
-
- public void RefreshSpline()
- {
- mSegments.Clear();
-
- for (int i = 0; i < mControlPoints.Count; i++)
- {
- if (mControlPoints[i].IsValid)
- {
- mSegments.Add(mControlPoints[i]);
- mControlPoints[i].SegmentIndex = mSegments.Count - 1;
- }
- }
-
- RefreshDistance();
- }
- }
-}
-
-
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs.meta b/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs.meta
deleted file mode 100644
index c2f6aea7..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/Spline.cs.meta
+++ /dev/null
@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: b3d86990734e5c247a39502c62e7d9a8
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs
deleted file mode 100644
index 9f8602c6..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-
-namespace XftWeapon {
- public class SplineControlPoint
- {
- public Vector3 Position;
- public Vector3 Normal;
-
- public int ControlPointIndex = -1;
- public int SegmentIndex = -1;
-
- public float Dist;
-
- protected Spline mSpline;
-
-
- public SplineControlPoint NextControlPoint
- {
- get
- {
- return mSpline.NextControlPoint(this);
- }
- }
-
- public SplineControlPoint PreviousControlPoint
- {
- get
- {
- return mSpline.PreviousControlPoint(this);
- }
- }
-
- public Vector3 NextPosition
- {
- get
- {
- return mSpline.NextPosition(this);
- }
- }
-
-
- public Vector3 PreviousPosition
- {
- get
- {
- return mSpline.PreviousPosition(this);
-
- }
- }
-
-
- public Vector3 NextNormal
- {
- get
- {
- return mSpline.NextNormal(this);
- }
- }
-
-
- public Vector3 PreviousNormal
- {
- get { return mSpline.PreviousNormal(this); }
- }
-
- public bool IsValid
- {
- get
- {
- return (NextControlPoint != null);
- }
- }
-
-
- Vector3 GetNext2Position()
- {
- SplineControlPoint cp = NextControlPoint;
- if (cp != null)
- return cp.NextPosition;
- return NextPosition;
- }
-
-
- Vector3 GetNext2Normal()
- {
- SplineControlPoint cp = NextControlPoint;
- if (cp != null)
- return cp.NextNormal;
-
-
- return Normal;
- }
-
-
- public Vector3 Interpolate(float localF)
- {
- localF = Mathf.Clamp01(localF);
-
- return Spline.CatmulRom(PreviousPosition, Position, NextPosition, GetNext2Position(), localF);
-
- }
-
-
- public Vector3 InterpolateNormal(float localF)
- {
- localF = Mathf.Clamp01(localF);
-
- return Spline.CatmulRom(PreviousNormal, Normal, NextNormal, GetNext2Normal(), localF);
- }
-
-
- public void Init(Spline owner)
- {
- mSpline = owner;
- SegmentIndex = -1;
- }
-
- }
-}
-
-
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs.meta b/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs.meta
deleted file mode 100644
index 68db10c1..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/SplineControlPoint.cs.meta
+++ /dev/null
@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: f49d3fcc41e813e4781a8c4ce717f813
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs
deleted file mode 100644
index 31d98d08..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs
+++ /dev/null
@@ -1,282 +0,0 @@
-//----------------------------------------------
-// Xffect Editor
-// Copyright © 2012- Shallway Studio
-// http://shallway.net
-//----------------------------------------------
-using UnityEngine;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace XftWeapon {
-
- public class VertexPool
- {
- public class VertexSegment
- {
- public int VertStart;
- public int IndexStart;
- public int VertCount;
- public int IndexCount;
- public VertexPool Pool;
-
- public VertexSegment(int start, int count, int istart, int icount, VertexPool pool)
- {
- VertStart = start;
- VertCount = count;
- IndexCount = icount;
- IndexStart = istart;
- Pool = pool;
- }
-
-
- public void ClearIndices()
- {
- for (int i = IndexStart; i < IndexStart + IndexCount; i++)
- {
- Pool.Indices[i] = 0;
- }
-
- Pool.IndiceChanged = true;
- }
-
- }
-
- public Vector3[] Vertices;
- public int[] Indices;
- public Vector2[] UVs;
- public Color[] Colors;
-
- public bool IndiceChanged;
- public bool ColorChanged;
- public bool UVChanged;
- public bool VertChanged;
- public bool UV2Changed;
-
-
-
-
-
- protected int VertexTotal;
- protected int VertexUsed;
- protected int IndexTotal = 0;
- protected int IndexUsed = 0;
- public bool FirstUpdate = true;
-
- protected bool VertCountChanged;
-
-
- public const int BlockSize = 108;
-
- public float BoundsScheduleTime = 1f;
- public float ElapsedTime = 0f;
-
- protected XWeaponTrail _owner;
-
- protected MeshFilter _meshFilter;
-
- protected Mesh _mesh2d;
- protected Material _material;
-
- public Mesh MyMesh {
- get {
-
- if (!_owner.UseWith2D) {
- return _mesh2d;
- }
- else {
- if (_meshFilter == null || _meshFilter.gameObject == null) {
- return null;
- }
- return _meshFilter.sharedMesh;
- }
- }
- }
-
- public void RecalculateBounds()
- {
- MyMesh.RecalculateBounds();
- }
-
-
- public void SetMeshObjectActive(bool flag) {
- if (_meshFilter == null) {
- return;
- }
-
- _meshFilter.gameObject.SetActive(flag);
- }
-
- void CreateMeshObj(XWeaponTrail owner, Material material) {
- GameObject obj = new GameObject("_XWeaponTrailMesh:" + "|material:" + material.name);
- obj.layer = owner.gameObject.layer;
- obj.AddComponent<MeshFilter>();
- obj.AddComponent<MeshRenderer>();
-
- obj.transform.position = Vector3.zero;
- obj.transform.rotation = Quaternion.identity;
-
-
- MeshRenderer Meshrenderer;
- _meshFilter = (MeshFilter)obj.GetComponent(typeof(MeshFilter));
- Meshrenderer = (MeshRenderer)obj.GetComponent(typeof(MeshRenderer));
-#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8
- Meshrenderer.castShadows = false;
-#else
- Meshrenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
-#endif
- Meshrenderer.receiveShadows = false;
- Meshrenderer.GetComponent<Renderer>().sharedMaterial = material;
- Meshrenderer.sortingLayerName = _owner.SortingLayerName;
- Meshrenderer.sortingOrder = _owner.SortingOrder;
- _meshFilter.sharedMesh = new Mesh();
- }
-
- public void Destroy() {
-
- if (!_owner.UseWith2D) {
- Mesh.DestroyImmediate(_mesh2d);
- }
- else {
- if (_meshFilter != null) {
- GameObject.Destroy(_meshFilter.gameObject);
- }
- }
- }
-
- public VertexPool(Material material, XWeaponTrail owner)
- {
- VertexTotal = VertexUsed = 0;
- VertCountChanged = false;
- _owner = owner;
- if (owner.UseWith2D) {
- CreateMeshObj(owner, material);
- }
- else {
- _mesh2d = new Mesh();
- }
- _material = material;
- InitArrays();
- IndiceChanged = ColorChanged = UVChanged = UV2Changed = VertChanged = true;
- }
-
-
- public VertexSegment GetVertices(int vcount, int icount)
- {
- int vertNeed = 0;
- int indexNeed = 0;
- if (VertexUsed + vcount >= VertexTotal)
- {
- vertNeed = (vcount / BlockSize + 1) * BlockSize;
- }
- if (IndexUsed + icount >= IndexTotal)
- {
- indexNeed = (icount / BlockSize + 1) * BlockSize;
- }
- VertexUsed += vcount;
- IndexUsed += icount;
- if (vertNeed != 0 || indexNeed != 0)
- {
- EnlargeArrays(vertNeed, indexNeed);
- VertexTotal += vertNeed;
- IndexTotal += indexNeed;
- }
-
- VertexSegment ret = new VertexSegment(VertexUsed - vcount, vcount, IndexUsed - icount, icount, this);
-
- return ret;
- }
-
-
- protected void InitArrays()
- {
- Vertices = new Vector3[4];
- UVs = new Vector2[4];
- Colors = new Color[4];
- Indices = new int[6];
- VertexTotal = 4;
- IndexTotal = 6;
- }
-
-
-
- public void EnlargeArrays(int count, int icount)
- {
- Vector3[] tempVerts = Vertices;
- Vertices = new Vector3[Vertices.Length + count];
- tempVerts.CopyTo(Vertices, 0);
-
- Vector2[] tempUVs = UVs;
- UVs = new Vector2[UVs.Length + count];
- tempUVs.CopyTo(UVs, 0);
-
- Color[] tempColors = Colors;
- Colors = new Color[Colors.Length + count];
- tempColors.CopyTo(Colors, 0);
-
- int[] tempTris = Indices;
- Indices = new int[Indices.Length + icount];
- tempTris.CopyTo(Indices, 0);
-
- VertCountChanged = true;
- IndiceChanged = true;
- ColorChanged = true;
- UVChanged = true;
- VertChanged = true;
- UV2Changed = true;
- }
-
-
-
-
- public void LateUpdate()
- {
- if (VertCountChanged)
- {
- MyMesh.Clear();
- }
-
- // we assume the vertices are always changed.
- MyMesh.vertices = Vertices;
- if (UVChanged)
- {
- MyMesh.uv = UVs;
- }
-
- if (ColorChanged)
- {
- MyMesh.colors = Colors;
- }
-
- if (IndiceChanged)
- {
- MyMesh.triangles = Indices;
- }
-
- ElapsedTime += Time.deltaTime;
- if (ElapsedTime > BoundsScheduleTime || FirstUpdate)
- {
- RecalculateBounds();
- ElapsedTime = 0f;
- }
-
- if (ElapsedTime > BoundsScheduleTime)
- FirstUpdate = false;
-
- VertCountChanged = false;
- IndiceChanged = false;
- ColorChanged = false;
- UVChanged = false;
- UV2Changed = false;
- VertChanged = false;
-
-
- if (_owner.UseWith2D) {
-
- }
- else {
- //Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one);
- Graphics.DrawMesh(MyMesh, Matrix4x4.identity, _material, _owner.gameObject.layer, null, 0, null, false, false);
- }
- }
- }
-} \ No newline at end of file
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs.meta b/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs.meta
deleted file mode 100644
index 474b340b..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/VertexPool.cs.meta
+++ /dev/null
@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: 339f2e9408de8004b81c1de4cc130d45
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs
deleted file mode 100644
index 5a2de663..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs
+++ /dev/null
@@ -1,419 +0,0 @@
-using UnityEngine;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace XftWeapon {
- public class XWeaponTrail : MonoBehaviour {
- public class Element {
- public Vector3 PointStart;
-
- public Vector3 PointEnd;
-
- public Vector3 Pos {
- get {
- return (PointStart + PointEnd) / 2f;
- }
- }
-
-
- public Element(Vector3 start, Vector3 end) {
- PointStart = start;
- PointEnd = end;
- }
-
- public Element() {
-
- }
- }
- public class ElementPool {
- private readonly Stack<Element> _stack = new Stack<Element>();
-
- public int CountAll { get; private set; }
- public int CountActive { get { return CountAll - CountInactive; } }
- public int CountInactive { get { return _stack.Count; } }
-
- public ElementPool(int preCount) {
- for (int i = 0; i < preCount; i++) {
- Element element = new Element();
- _stack.Push(element);
- CountAll++;
- }
- }
-
- public Element Get() {
- Element element;
- if (_stack.Count == 0) {
- element = new Element();
- CountAll++;
- }
- else {
- element = _stack.Pop();
- }
-
- return element;
- }
-
- public void Release(Element element) {
- if (_stack.Count > 0 && ReferenceEquals(_stack.Peek(), element)) {
- Debug.LogError("Internal error. Trying to destroy object that is already released to pool.");
- }
- _stack.Push(element);
- }
- }
-
- #region public members
-
- public static string Version = "1.2.0";
-
-
- public bool UseWith2D = false;
- public string SortingLayerName;
- public int SortingOrder;
- public Transform PointStart;
- public Transform PointEnd;
-
- public int MaxFrame = 14;
- public int Granularity = 60;
- //public float Fps = 60f;
-
- public Color MyColor = Color.white;
- public Material MyMaterial;
- #endregion
-
-
-
- #region protected members
- protected float mTrailWidth = 0f;
- protected Element mHeadElem = new Element();
- protected List<Element> mSnapshotList = new List<Element>();
- protected ElementPool mElemPool;
- protected Spline mSpline = new Spline();
- protected float mFadeT = 1f;
- protected bool mIsFading = false;
- protected float mFadeTime = 1f;
- protected float mElapsedTime = 0f;
- protected float mFadeElapsedime = 0f;
- protected GameObject mMeshObj;
- protected VertexPool mVertexPool;
- protected VertexPool.VertexSegment mVertexSegment;
- protected bool mInited = false;
-
- #endregion
-
- #region property
- //public float UpdateInterval {
- // get {
- // return 1f / Fps;
- // }
- //}
- public Vector3 CurHeadPos {
- get { return (PointStart.position + PointEnd.position) / 2f; }
- }
- public float TrailWidth {
- get {
- return mTrailWidth;
- }
- }
- #endregion
-
- #region API
- //you may pre-init the trail to save some performance.
- public void Init() {
- if (mInited)
- return;
-
- mElemPool = new ElementPool(MaxFrame);
-
- mTrailWidth = (PointStart.position - PointEnd.position).magnitude;
-
- InitMeshObj();
-
- InitOriginalElements();
-
- InitSpline();
-
- mInited = true;
- }
-
- public void Activate() {
-
- Init();
-
- gameObject.SetActive(true);
- mVertexPool.SetMeshObjectActive(true);
-
- mFadeT = 1f;
- mIsFading = false;
- mFadeTime = 1f;
- mFadeElapsedime = 0f;
- mElapsedTime = 0f;
-
- //reset all elemts to head pos.
- for (int i = 0; i < mSnapshotList.Count; i++) {
- mSnapshotList[i].PointStart = PointStart.position;
- mSnapshotList[i].PointEnd = PointEnd.position;
-
- mSpline.ControlPoints[i].Position = mSnapshotList[i].Pos;
- mSpline.ControlPoints[i].Normal = mSnapshotList[i].PointEnd - mSnapshotList[i].PointStart;
- }
-
- //reset vertex too.
- RefreshSpline();
- UpdateVertex();
- }
-
- public void Deactivate() {
- gameObject.SetActive(false);
- mVertexPool.SetMeshObjectActive(false);
- }
-
- public void StopSmoothly(float fadeTime) {
- mIsFading = true;
- mFadeTime = fadeTime;
- }
-
- #endregion
-
- #region unity methods
- void Update() {
-
- if (!mInited)
- return;
-
-
- UpdateHeadElem();
-
-
- //mElapsedTime += Time.deltaTime;
- //if (mElapsedTime < UpdateInterval) {
- // return;
- //}
- //mElapsedTime -= UpdateInterval;
-
-
-
- RecordCurElem();
-
- RefreshSpline();
-
- UpdateFade();
-
- UpdateVertex();
-
- }
-
-
- void LateUpdate() {
- if (!mInited)
- return;
-
-
- mVertexPool.LateUpdate();
- }
-
- void OnDestroy() {
- if (!mInited || mVertexPool == null) {
- return;
- }
- mVertexPool.Destroy();
- }
-
-
- void Start() {
- mInited = false;
- Init();
- }
-
- void OnDrawGizmos() {
- if (PointEnd == null || PointStart == null) {
- return;
- }
-
-
- float dist = (PointStart.position - PointEnd.position).magnitude;
-
- if (dist < Mathf.Epsilon)
- return;
-
-
- Gizmos.color = Color.red;
-
- Gizmos.DrawSphere(PointStart.position, dist * 0.04f);
-
-
- Gizmos.color = Color.blue;
- Gizmos.DrawSphere(PointEnd.position, dist * 0.04f);
-
- }
-
- #endregion
-
- #region local methods
-
- void InitSpline() {
- mSpline.Granularity = Granularity;
-
- mSpline.Clear();
-
- for (int i = 0; i < MaxFrame; i++) {
- mSpline.AddControlPoint(CurHeadPos, PointStart.position - PointEnd.position);
- }
- }
-
- void RefreshSpline() {
- for (int i = 0; i < mSnapshotList.Count; i++) {
- mSpline.ControlPoints[i].Position = mSnapshotList[i].Pos;
- mSpline.ControlPoints[i].Normal = mSnapshotList[i].PointEnd - mSnapshotList[i].PointStart;
- }
-
- mSpline.RefreshSpline();
- }
-
- void UpdateVertex() {
-
- VertexPool pool = mVertexSegment.Pool;
-
-
- for (int i = 0; i < Granularity; i++) {
- int baseIdx = mVertexSegment.VertStart + i * 3;
-
- float uvSegment = (float)i / Granularity;
-
-
- float fadeT = uvSegment * mFadeT;
-
- Vector2 uvCoord = Vector2.zero;
-
- Vector3 pos = mSpline.InterpolateByLen(fadeT);
-
- //Debug.DrawRay(pos, Vector3.up, Color.red);
-
- Vector3 up = mSpline.InterpolateNormalByLen(fadeT);
- Vector3 pos0 = pos + (up.normalized * mTrailWidth * 0.5f);
- Vector3 pos1 = pos - (up.normalized * mTrailWidth * 0.5f);
-
-
- // pos0
- pool.Vertices[baseIdx] = pos0;
- pool.Colors[baseIdx] = MyColor;
- uvCoord.x = 0f;
- uvCoord.y = uvSegment;
- pool.UVs[baseIdx] = uvCoord;
-
- //pos
- pool.Vertices[baseIdx + 1] = pos;
- pool.Colors[baseIdx + 1] = MyColor;
- uvCoord.x = 0.5f;
- uvCoord.y = uvSegment;
- pool.UVs[baseIdx + 1] = uvCoord;
-
- //pos1
- pool.Vertices[baseIdx + 2] = pos1;
- pool.Colors[baseIdx + 2] = MyColor;
- uvCoord.x = 1f;
- uvCoord.y = uvSegment;
- pool.UVs[baseIdx + 2] = uvCoord;
- }
-
- mVertexSegment.Pool.UVChanged = true;
- mVertexSegment.Pool.VertChanged = true;
- mVertexSegment.Pool.ColorChanged = true;
-
- }
-
- void UpdateIndices() {
-
- VertexPool pool = mVertexSegment.Pool;
-
- for (int i = 0; i < Granularity - 1; i++) {
- int baseIdx = mVertexSegment.VertStart + i * 3;
- int nextBaseIdx = mVertexSegment.VertStart + (i + 1) * 3;
-
- int iidx = mVertexSegment.IndexStart + i * 12;
-
- //triangle left
- pool.Indices[iidx + 0] = nextBaseIdx;
- pool.Indices[iidx + 1] = nextBaseIdx + 1;
- pool.Indices[iidx + 2] = baseIdx;
- pool.Indices[iidx + 3] = nextBaseIdx + 1;
- pool.Indices[iidx + 4] = baseIdx + 1;
- pool.Indices[iidx + 5] = baseIdx;
-
-
- //triangle right
- pool.Indices[iidx + 6] = nextBaseIdx + 1;
- pool.Indices[iidx + 7] = nextBaseIdx + 2;
- pool.Indices[iidx + 8] = baseIdx + 1;
- pool.Indices[iidx + 9] = nextBaseIdx + 2;
- pool.Indices[iidx + 10] = baseIdx + 2;
- pool.Indices[iidx + 11] = baseIdx + 1;
-
- }
-
- pool.IndiceChanged = true;
- }
-
- void UpdateHeadElem() {
- mSnapshotList[0].PointStart = PointStart.position;
- mSnapshotList[0].PointEnd = PointEnd.position;
- }
-
-
- void UpdateFade() {
- if (!mIsFading)
- return;
-
- mFadeElapsedime += Time.deltaTime;
-
- float t = mFadeElapsedime / mFadeTime;
-
- mFadeT = 1f - t;
-
- if (mFadeT < 0f) {
- Deactivate();
- }
- }
-
- void RecordCurElem() {
- //TODO: use element pool to avoid gc alloc.
- //Element elem = new Element(PointStart.position, PointEnd.position);
-
- Element elem = mElemPool.Get();
- elem.PointStart = PointStart.position;
- elem.PointEnd = PointEnd.position;
-
- if (mSnapshotList.Count < MaxFrame) {
- mSnapshotList.Insert(1, elem);
- }
- else {
- mElemPool.Release(mSnapshotList[mSnapshotList.Count - 1]);
- mSnapshotList.RemoveAt(mSnapshotList.Count - 1);
- mSnapshotList.Insert(1, elem);
- }
-
- }
-
- void InitOriginalElements() {
- mSnapshotList.Clear();
- //at least add 2 original elements
- mSnapshotList.Add(new Element(PointStart.position, PointEnd.position));
- mSnapshotList.Add(new Element(PointStart.position, PointEnd.position));
- }
-
-
-
- void InitMeshObj() {
- //init vertexpool
- mVertexPool = new VertexPool(MyMaterial, this);
- mVertexSegment = mVertexPool.GetVertices(Granularity * 3, (Granularity - 1) * 12);
- UpdateIndices();
- }
-
- #endregion
-
-
- }
-
-}
-
-
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs.meta b/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs.meta
deleted file mode 100644
index 9cf46f13..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrail.cs.meta
+++ /dev/null
@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: f6c2c9828fec98747a1b0680f47bed80
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs b/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs
deleted file mode 100644
index 9061995c..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using UnityEngine;
-using System.Collections;
-using XftWeapon;
-
-public class XWeaponTrailDemo : MonoBehaviour
-{
- public Animation SwordAnimation;
-
-
-
- public XWeaponTrail ProTrailDistort;
- public XWeaponTrail ProTrailShort;
- public XWeaponTrail ProTraillong;
-
-
- public XWeaponTrail SimpleTrail;
-
-
-
- //pre-init to save some performance.
- public void Start()
- {
- ProTrailDistort.Init();
- ProTrailShort.Init();
- ProTraillong.Init();
- SimpleTrail.Init();
- }
-
-
-
- void OnGUI()
- {
-
- //GUI.Label(new Rect(60, 0, 500, 30), "Pro example requires unity Pro.");
-
- if (GUI.Button(new Rect(0, 0, 150, 30), "Activate Trail1"))
- {
-
- ProTrailDistort.Deactivate();
- ProTrailShort.Deactivate();
- ProTraillong.Deactivate();
-
- SwordAnimation.Play();
- SimpleTrail.Activate();
- }
- if (GUI.Button(new Rect(0, 30, 150, 30), "Stop Trail1"))
- {
-
- SimpleTrail.Deactivate();
- }
- if (GUI.Button(new Rect(0, 60, 150, 30), "Stop Trail1 Smoothly"))
- {
- SimpleTrail.StopSmoothly(0.3f);
- }
-
-
- if (GUI.Button(new Rect(0, 120, 150, 30), "Activate Trail2"))
- {
- SimpleTrail.Deactivate();
-
- SwordAnimation.Play();
- ProTrailDistort.Activate();
- ProTrailShort.Activate();
- ProTraillong.Activate();
- }
- if (GUI.Button(new Rect(0, 150, 150, 30), "Stop Trail2"))
- {
- ProTrailDistort.Deactivate();
- ProTrailShort.Deactivate();
- ProTraillong.Deactivate();
- }
- if (GUI.Button(new Rect(0, 180, 150, 30), "Stop Trail2 Smoothly"))
- {
- ProTrailDistort.StopSmoothly(0.3f);
- ProTrailShort.StopSmoothly(0.3f);
- ProTraillong.StopSmoothly(0.3f);
- }
- }
-
-}
diff --git a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs.meta b/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs.meta
deleted file mode 100644
index 0ad531e3..00000000
--- a/Assets/ThirdParty/XWeaponTrail/Scripts/XWeaponTrailDemo.cs.meta
+++ /dev/null
@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: d55fb505d1775e94c851f7bd430a8458
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant: