public Vector3 GetPoint(float t, int curveIndex) { curveIndex *= 3; return(transform.TransformPoint(CurveUtils.GetPoint(m_points[curveIndex], m_points[curveIndex + 1], m_points[curveIndex + 2], m_points[curveIndex + 3], t))); }
public Vector3 GetPointLocal(float t, int curveIndex) { curveIndex *= 3; return(CurveUtils.GetPoint(m_points[curveIndex], m_points[curveIndex + 1], m_points[curveIndex + 2], m_points[curveIndex + 3], t)); }
public void Draw() { if (m_points.Length < 2) { return; } SplineRuntimeEditor runtimeEditor = SplineRuntimeEditor.Instance; if (runtimeEditor == null) { return; } runtimeEditor.SplineMaterial.SetPass(0); GL.PushMatrix(); GL.MultMatrix(transform.localToWorldMatrix); GL.Begin(GL.LINES); Vector3 p0 = m_points[0]; for (int i = 1; i < m_points.Length; i += 3) { Vector3 p1 = m_points[i]; Vector3 p2 = m_points[i + 1]; Vector3 p3 = m_points[i + 2]; GL.Color(SplineRuntimeEditor.ControlPointLineColor); GL.Vertex(p0); GL.Vertex(p1); GL.Color(SplineRuntimeEditor.ControlPointLineColor); GL.Vertex(p2); GL.Vertex(p3); p0 = p3; } GL.End(); GL.Begin(GL.LINES); GL.Color(SplineRuntimeEditor.SplineColor); p0 = m_points[0]; for (int i = 1; i < m_points.Length; i += 3) { Vector3 p1 = m_points[i]; Vector3 p2 = m_points[i + 1]; Vector3 p3 = m_points[i + 2]; float len = (p0 - p1).magnitude + (p1 - p2).magnitude + (p2 - p3).magnitude; int count = Mathf.CeilToInt(runtimeEditor.Smoothness * len); if (count <= 0) { count = 1; } for (int j = 0; j < count; ++j) { float t = ((float)j) / count; Vector3 point = CurveUtils.GetPoint(p0, p1, p2, p3, t); GL.Vertex(point); t = ((float)j + 1) / count; point = CurveUtils.GetPoint(p0, p1, p2, p3, t); GL.Vertex(point); } p0 = p3; } GL.End(); GL.PopMatrix(); }