mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
Add Popcron.Gizmos license.
Made sure to add the MIT license to their folder.
This commit is contained in:
parent
29060f71c1
commit
7aaec9c512
10 changed files with 21 additions and 0 deletions
96
CVRGizmos/Popcron.Gizmos/Drawers/CubeDrawer.cs
Normal file
96
CVRGizmos/Popcron.Gizmos/Drawers/CubeDrawer.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
public class CubeDrawer : Drawer
|
||||
{
|
||||
public CubeDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int Draw(ref Vector3[] buffer, params object[] values)
|
||||
{
|
||||
Vector3 position = (Vector3)values[0];
|
||||
Quaternion rotation = (Quaternion)values[1];
|
||||
Vector3 size = (Vector3)values[2];
|
||||
|
||||
size *= 0.5f;
|
||||
|
||||
Vector3 point1 = new Vector3(position.x - size.x, position.y - size.y, position.z - size.z);
|
||||
Vector3 point2 = new Vector3(position.x + size.x, position.y - size.y, position.z - size.z);
|
||||
Vector3 point3 = new Vector3(position.x + size.x, position.y + size.y, position.z - size.z);
|
||||
Vector3 point4 = new Vector3(position.x - size.x, position.y + size.y, position.z - size.z);
|
||||
|
||||
Vector3 point5 = new Vector3(position.x - size.x, position.y - size.y, position.z + size.z);
|
||||
Vector3 point6 = new Vector3(position.x + size.x, position.y - size.y, position.z + size.z);
|
||||
Vector3 point7 = new Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||
Vector3 point8 = new Vector3(position.x - size.x, position.y + size.y, position.z + size.z);
|
||||
|
||||
point1 = rotation * (point1 - position);
|
||||
point1 += position;
|
||||
|
||||
point2 = rotation * (point2 - position);
|
||||
point2 += position;
|
||||
|
||||
point3 = rotation * (point3 - position);
|
||||
point3 += position;
|
||||
|
||||
point4 = rotation * (point4 - position);
|
||||
point4 += position;
|
||||
|
||||
point5 = rotation * (point5 - position);
|
||||
point5 += position;
|
||||
|
||||
point6 = rotation * (point6 - position);
|
||||
point6 += position;
|
||||
|
||||
point7 = rotation * (point7 - position);
|
||||
point7 += position;
|
||||
|
||||
point8 = rotation * (point8 - position);
|
||||
point8 += position;
|
||||
|
||||
//square
|
||||
buffer[0] = point1;
|
||||
buffer[1] = point2;
|
||||
|
||||
buffer[2] = point2;
|
||||
buffer[3] = point3;
|
||||
|
||||
buffer[4] = point3;
|
||||
buffer[5] = point4;
|
||||
|
||||
buffer[6] = point4;
|
||||
buffer[7] = point1;
|
||||
|
||||
//other square
|
||||
buffer[8] = point5;
|
||||
buffer[9] = point6;
|
||||
|
||||
buffer[10] = point6;
|
||||
buffer[11] = point7;
|
||||
|
||||
buffer[12] = point7;
|
||||
buffer[13] = point8;
|
||||
|
||||
buffer[14] = point8;
|
||||
buffer[15] = point5;
|
||||
|
||||
//connectors
|
||||
buffer[16] = point1;
|
||||
buffer[17] = point5;
|
||||
|
||||
buffer[18] = point2;
|
||||
buffer[19] = point6;
|
||||
|
||||
buffer[20] = point3;
|
||||
buffer[21] = point7;
|
||||
|
||||
buffer[22] = point4;
|
||||
buffer[23] = point8;
|
||||
|
||||
return 24;
|
||||
}
|
||||
}
|
||||
}
|
19
CVRGizmos/Popcron.Gizmos/Drawers/LineDrawer.cs
Normal file
19
CVRGizmos/Popcron.Gizmos/Drawers/LineDrawer.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
public class LineDrawer : Drawer
|
||||
{
|
||||
public LineDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int Draw(ref Vector3[] buffer, params object[] args)
|
||||
{
|
||||
buffer[0] = (Vector3)args[0];
|
||||
buffer[1] = (Vector3)args[1];
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
40
CVRGizmos/Popcron.Gizmos/Drawers/PolygonDrawer.cs
Normal file
40
CVRGizmos/Popcron.Gizmos/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;
|
||||
}
|
||||
}
|
||||
}
|
72
CVRGizmos/Popcron.Gizmos/Drawers/SquareDrawer.cs
Normal file
72
CVRGizmos/Popcron.Gizmos/Drawers/SquareDrawer.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Popcron
|
||||
{
|
||||
public class SquareDrawer : Drawer
|
||||
{
|
||||
public SquareDrawer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override int Draw(ref Vector3[] buffer, params object[] values)
|
||||
{
|
||||
Vector2 position = default;
|
||||
if (values[0] is Vector2 p2)
|
||||
{
|
||||
position = p2;
|
||||
}
|
||||
else if (values[0] is Vector3 p3)
|
||||
{
|
||||
position = p3;
|
||||
}
|
||||
|
||||
Quaternion rotation = (Quaternion)values[1];
|
||||
|
||||
Vector2 size = default;
|
||||
if (values[2] is Vector2 s2)
|
||||
{
|
||||
size = s2;
|
||||
}
|
||||
else if (values[2] is Vector3 s3)
|
||||
{
|
||||
size = s3;
|
||||
}
|
||||
|
||||
size *= 0.5f;
|
||||
|
||||
Vector2 point1 = new Vector3(position.x - size.x, position.y - size.y);
|
||||
Vector2 point2 = new Vector3(position.x + size.x, position.y - size.y);
|
||||
Vector2 point3 = new Vector3(position.x + size.x, position.y + size.y);
|
||||
Vector2 point4 = new Vector3(position.x - size.x, position.y + size.y);
|
||||
|
||||
point1 = rotation * (point1 - position);
|
||||
point1 += position;
|
||||
|
||||
point2 = rotation * (point2 - position);
|
||||
point2 += position;
|
||||
|
||||
point3 = rotation * (point3 - position);
|
||||
point3 += position;
|
||||
|
||||
point4 = rotation * (point4 - position);
|
||||
point4 += position;
|
||||
|
||||
//square
|
||||
buffer[0] = point1;
|
||||
buffer[1] = point2;
|
||||
|
||||
buffer[2] = point2;
|
||||
buffer[3] = point3;
|
||||
|
||||
buffer[4] = point3;
|
||||
buffer[5] = point4;
|
||||
|
||||
//loop back to start
|
||||
buffer[6] = point4;
|
||||
buffer[7] = point1;
|
||||
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue