BITFALL/Assets/Plugins/FImpossible Creations/Plugins - Level Design/Mesh Operations CSG/Classes/Polygon.cs

38 lines
862 B
C#
Raw Normal View History

2023-11-30 00:23:23 +08:00
using UnityEngine;
using System.Collections.Generic;
namespace Parabox.CSG
{
/// <summary>
/// Represents a polygon face with an arbitrary number of vertices.
/// </summary>
sealed class Polygon
{
public List<Vertex> vertices;
public Plane plane;
public Material material;
public Polygon(List<Vertex> list, Material mat)
{
vertices = list;
plane = new Plane(list[0].position, list[1].position, list[2].position);
material = mat;
}
public void Flip()
{
vertices.Reverse();
for (int i = 0; i < vertices.Count; i++)
vertices[i].Flip();
plane.Flip();
}
public override string ToString()
{
return $"[{vertices.Count}] {plane.normal}";
}
}
}