本文整理汇总了C#中System.Utils.GetPlaneMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.GetPlaneMatrix方法的具体用法?C# Utils.GetPlaneMatrix怎么用?C# Utils.GetPlaneMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Utils
的用法示例。
在下文中一共展示了Utils.GetPlaneMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Triangulate
void Triangulate(List<Dictionary<int, int>> contours, Utils.Plane plane, List<Vector3>[] vertices, List<Vector3>[] normals, List<Vector2>[] uvs, List<int>[] triangles, bool uvCutMesh)
{
if (contours.Count == 0 || contours[0].Count < 3)
{
return;
}
// prepare plane matrix
var m = plane.GetPlaneMatrix();
var mInv = m.inverse;
var zShit = 0.0f;
var polygons = new List<Polygon>(contours.Count);
// construct polygons from contours
Polygon highAreaPoly = null;
foreach (var ctr in contours)
{
var polygonPoints = new Vector2[ctr.Count];
var j = 0;
foreach (var i in ctr.Values)
{
var p = mInv*vertices[0][i];
polygonPoints[j++] = p;
// save z-coordinate
zShit = p.z;
}
var polygon = new Polygon(polygonPoints);
polygons.Add(polygon);
if (highAreaPoly == null || highAreaPoly.Area < polygon.Area)
{
highAreaPoly = polygon;
}
}
MeshUtils.Assert(polygons.Count > 0, "Zero polygons!");
// test for holes
if (polygons.Count > 0)
{
var polyToRemove = new List<Polygon>();
foreach (var polygon in polygons)
{
if (polygon != highAreaPoly)
{
if (highAreaPoly.IsPointInside(polygon.Points[0]))
{
highAreaPoly.AddHole(polygon);
polyToRemove.Add(polygon);
}
}
}
foreach (var polygon in polyToRemove)
{
polygons.Remove(polygon);
}
}
var vertCounter0 = vertices[0].Count;
var vertCounter1 = vertices[1].Count;
foreach (var polygon in polygons)
{
var indices = polygon.Triangulate();
// get polygon bounding square size
var min = Mathf.Min(polygon.Min.x, polygon.Min.y);
var max = Mathf.Max(polygon.Max.x, polygon.Max.y);
var polygonSize = min - max;
// MeshUtils.Log("PolygonSize: " + polygonSize + " " + polygon.Min + " " + polygon.Max);
foreach (var polyPoint in polygon.Points)
{
var p = m * new Vector3(polyPoint.x, polyPoint.y, zShit);
vertices[0].Add(p);
vertices[1].Add(p);
normals[0].Add(-plane.Normal);
normals[1].Add(plane.Normal);
if (uvCutMesh)
{
uvs[0].Add(new Vector2((polyPoint.x - min) / polygonSize,
(polyPoint.y - min) / polygonSize));
uvs[1].Add(new Vector2((polyPoint.x - min) / polygonSize,
(polyPoint.y - min) / polygonSize));
}
else
{
uvs[0].Add(Vector2.zero);
uvs[1].Add(Vector2.zero);
}
//.........这里部分代码省略.........