rabidus-test/Assets/Dreamteck/Splines/Core/Primitives/Ngon.cs

30 lines
812 B
C#
Raw Permalink Normal View History

2023-07-24 16:38:13 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Dreamteck.Splines.Primitives
{
public class Ngon : SplinePrimitive
{
public float radius = 1f;
public int sides = 3;
public override Spline.Type GetSplineType()
{
return Spline.Type.Linear;
}
protected override void Generate()
{
base.Generate();
closed = true;
CreatePoints(sides, SplinePoint.Type.SmoothMirrored);
for (int i = 0; i < sides; i++)
{
float percent = (float)i / sides;
Vector3 pos = Quaternion.AngleAxis(360f * percent, Vector3.forward) * Vector3.up * radius;
points[i].SetPosition(pos);
}
}
}
}