Ejemplo n.º 1
0
        public static void ConvertSkeletonMeshToBuildRMesh(OffsetPolyCore skeleton, ref BuildRMesh mesh, float baseHeight, float height, int submesh)
        {
//            //hipped shape
//            SkeletonTri[] tris = skeleton.data.mesh.GetTriangles();
//            foreach (SkeletonTri tri in tris)
//            {
//                Vector3 p0 = new Vector3(tri[0].position.x, tri[0].height * height + baseHeight, tri[0].position.y);
//                Vector3 p1 = new Vector3(tri[1].position.x, tri[1].height * height + baseHeight, tri[1].position.y);
//                Vector3 p2 = new Vector3(tri[2].position.x, tri[2].height * height + baseHeight, tri[2].position.y);
//                Vector3[] verts = { p0, p1, p2 };
//                Vector3[] norms = { tri.normal, tri.normal, tri.normal };
//                Vector4[] tangents = { tri.tangent, tri.tangent, tri.tangent };
//                mesh.AddData(verts, tri.uvs, new[] { 0, 2, 1 }, norms, tangents, submesh);
//            }
//
//            //top shape
//            Vector2[] topShape = skeleton.data.mesh.topShape().ToArray();
//            int shapeSize = topShape.Length;
//            int[] topTris = EarClipper.Triangulate(topShape);
//            Vector3[] topVerts = new Vector3[shapeSize];
//            Vector2[] topUVs = new Vector2[shapeSize];
//            Vector3[] topNormals = new Vector3[shapeSize];
//            Vector4[] topTangents = new Vector4[shapeSize];
//            Vector4 tangent = DynamicMesh.CalculateTangent(Vector3.right);
//            for (int t = 0; t < shapeSize; t++)
//            {
//                topVerts[t] = new Vector3(topShape[t].x, height, topShape[t].y);
//                topUVs[t] = topShape[t];
//                topNormals[t] = Vector3.up;
//                topTangents[t] = tangent;
//            }
//            mesh.AddData(topVerts, topUVs, topTris, topNormals, topTangents, submesh);
        }
Ejemplo n.º 2
0
 public OffsetPoly(Vector2[] poly, float distance = 0, bool debug = false)
 {
     _debug     = debug;
     _direction = distance > 0 ? _direction = 1 : _direction = -1;
     _core      = new OffsetPolyCore();
     _core.LiveDebug(debug);
     _core.maxOffset             = distance;
     _core.calculateInteractions = false;
     _core.Init(poly);
     _core.OnFlipEvent     += OnFlip;
     _core.OnSplitEvent    += OnSplit;
     _core.OnMergedEvent   += OnMerged;
     _core.OnCompleteEvent += OnComplete;
     _core.OnErrorEvent    += OnError;
 }
Ejemplo n.º 3
0
 public OffsetSkeleton(Vector2[] poly, bool[] gables = null, float distance = 0, bool debug = false)
 {
     nodeTris.Clear();
     _debug = debug;
     if (direction == 0)
     {
         direction = -1;
     }
     _core = new OffsetPolyCore();
     _core.LiveDebug(debug);
     _core.maxOffset             = distance;
     _core.percentAccuracy       = percentAccuracy;
     _core.calculateInteractions = true;
     _core.Init(poly, gables);
     _core.OnFlipEvent     += OnFlip;
     _core.OnSplitEvent    += OnSplit;
     _core.OnMergedEvent   += OnMerged;
     _core.OnCompleteEvent += OnComplete;
     _core.OnErrorEvent    += OnError;
 }