Aetheria/Assets/Plugins/GPUTrail/Scripts/GPUTrailSpline.cs
Reinier Vens bb297bf84c Lightning
Created Lightning Gun effect (Uses LineRenderer, very slow)
Created GPU Lightning renderer (very fast, still needs integration)
2021-02-04 04:37:47 +00:00

26 lines
712 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using System.Collections;
public class GPUTrailSpline : MonoBehaviour
{
/// <summary>
/// start~end をつなぐ曲線上の点をtに応じて求める
/// http://t-pot.com/program/2_3rdcurve/index.html
/// </summary>
/// <param name="t">0f~1f</param>
/// <param name="prev"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <returns></returns>
public static Vector3 CatmullRom(float t, Vector3 prev, Vector3 start, Vector3 end)
{
var t2 = t * t;
return
0.5f * (
t2 * (prev - 2f * start + end)
+ t * (-prev + end)
)
+ start;
}
}