mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
Initial Upload
it working and not nuking fps... wow
This commit is contained in:
parent
cb280bdf00
commit
29060f71c1
23 changed files with 1905 additions and 0 deletions
40
CVRGizmos/Gizmo/Drawers/PolygonDrawer.cs
Normal file
40
CVRGizmos/Gizmo/Drawers/PolygonDrawer.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
public class PolygonDrawer : Drawer
|
||||
{
|
||||
public PolygonDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int Draw(ref Vector3[] buffer, params object[] values)
|
||||
{
|
||||
Vector3 position = (Vector3)values[0];
|
||||
int points = (int)values[1];
|
||||
float radius = (float)values[2];
|
||||
float offset = (float)values[3];
|
||||
Quaternion rotation = (Quaternion)values[4];
|
||||
|
||||
float step = 360f / points;
|
||||
offset *= Mathf.Deg2Rad;
|
||||
|
||||
for (int i = 0; i < points; i++)
|
||||
{
|
||||
float cx = Mathf.Cos(Mathf.Deg2Rad * step * i + offset) * radius;
|
||||
float cy = Mathf.Sin(Mathf.Deg2Rad * step * i + offset) * radius;
|
||||
Vector3 current = new Vector3(cx, cy);
|
||||
|
||||
float nx = Mathf.Cos(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
|
||||
float ny = Mathf.Sin(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
|
||||
Vector3 next = new Vector3(nx, ny);
|
||||
|
||||
buffer[i * 2] = position + (rotation * current);
|
||||
buffer[(i * 2) + 1] = position + (rotation * next);
|
||||
}
|
||||
|
||||
return points * 2;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue