Exemplo n.º 1
0
        public IEnumerator CoroutinePunchOutAndInitialize(MonoBehaviour caller, XZPolygon polygon, bool bKeepInterior, GameObject zeObject, string strName, string strLayer, CustomMesh customMesh, Material material, bool bCollider)
        {
            float T = Time.time;

            yield return null;

            yield return caller.StartCoroutine(PunchOutStep1(polygon));

            Debug.Log("(1)");

            yield return null;

            Debug.Log("(2) Dt=" + (Time.time - T));
            T = Time.time;

            yield return caller.StartCoroutine(PunchOutStep2(polygon));

            yield return null;

            Debug.Log("(3) Dt=" + (Time.time - T));
            T = Time.time;

            yield return caller.StartCoroutine(PunchOutStep3(polygon, bKeepInterior));

            yield return null;

            Debug.Log("(4) Dt=" + (Time.time - T));
            T = Time.time;

            if (zeObject == null)
            {
                zeObject = new GameObject(strName);
                zeObject.transform.parent = caller.transform;
                zeObject.transform.localPosition = Vector3.zero;
                zeObject.transform.localScale = Vector3.one;
                zeObject.layer = LayerMask.NameToLayer(strLayer);
            }
            customMesh.AttachMeshTo(zeObject, material);
            if (bCollider)
            {
                customMesh.AddMeshCollider(zeObject);
            }

            yield return null;

            Debug.Log("(5) Dt=" + (Time.time - T));
            T = Time.time;

            caller.gameObject.SendMessage("OnPunchOutDone", zeObject);
        }
Exemplo n.º 2
0
        // Constructor to clone existing custom mesh
        public CustomMesh(CustomMesh customMeshOriginal)
        {
            // Copy vertices
            mlVertices = new List<Vertex>();
            for (int i = 0; i < customMeshOriginal.mlVertices.Count; i++)
            {
                Vertex vertex = new Vertex(mlVertices.Count);
                vertex.mvPos = customMeshOriginal.mlVertices[i].mvPos;
                vertex.mvUV = customMeshOriginal.mlVertices[i].mvUV;
                mlVertices.Add(vertex);
            }

            // Copy triangles
            mlTriangles = new List<Triangle>();
            for (int i = 0; i < customMeshOriginal.mlTriangles.Count; i += 3)
            {
                Triangle originalTriangle = customMeshOriginal.mlTriangles[i];
                Vertex A = AddVertex(originalTriangle.mA);
                Vertex B = AddVertex(originalTriangle.mB);
                Vertex C = AddVertex(originalTriangle.mC);
                AddTriangle(A, B, C);
            }
        }
Exemplo n.º 3
0
        // Constructor to clone existing custom mesh
        public CustomMesh(CustomMesh customMeshOriginal)
        {
            // Copy vertices
            mlVertices = new List <Vertex>();
            for (int i = 0; i < customMeshOriginal.mlVertices.Count; i++)
            {
                Vertex vertex = new Vertex(mlVertices.Count);
                vertex.mvPos = customMeshOriginal.mlVertices[i].mvPos;
                vertex.mvUV  = customMeshOriginal.mlVertices[i].mvUV;
                mlVertices.Add(vertex);
            }

            // Copy triangles
            mlTriangles = new List <Triangle>();
            for (int i = 0; i < customMeshOriginal.mlTriangles.Count; i += 3)
            {
                Triangle originalTriangle = customMeshOriginal.mlTriangles[i];
                Vertex   A = AddVertex(originalTriangle.mA);
                Vertex   B = AddVertex(originalTriangle.mB);
                Vertex   C = AddVertex(originalTriangle.mC);
                AddTriangle(A, B, C);
            }
        }
Exemplo n.º 4
0
 public CustomMeshInterlinked(CustomMesh customMeshOriginal)
     : base(customMeshOriginal)
 {
 }
Exemplo n.º 5
0
 public void PunchOutAndInitialize(MonoBehaviour caller, XZPolygon polygon, bool bKeepInterior, GameObject zeObject, string strName, string strLayer, CustomMesh customMesh, Material material, bool bCollider)
 {
     caller.StartCoroutine(CoroutinePunchOutAndInitialize(caller, polygon, bKeepInterior, zeObject, strName, strLayer, customMesh, material, bCollider));
 }
Exemplo n.º 6
0
        public IEnumerator CoroutinePunchOutAndInitialize(MonoBehaviour caller, XZPolygon polygon, bool bKeepInterior, GameObject zeObject, string strName, string strLayer, CustomMesh customMesh, Material material, bool bCollider)
        {
            float T = Time.time;


            yield return(null);

            yield return(caller.StartCoroutine(PunchOutStep1(polygon)));

            Debug.Log("(1)");

            yield return(null);

            Debug.Log("(2) Dt=" + (Time.time - T));
            T = Time.time;

            yield return(caller.StartCoroutine(PunchOutStep2(polygon)));

            yield return(null);

            Debug.Log("(3) Dt=" + (Time.time - T));
            T = Time.time;

            yield return(caller.StartCoroutine(PunchOutStep3(polygon, bKeepInterior)));

            yield return(null);

            Debug.Log("(4) Dt=" + (Time.time - T));
            T = Time.time;

            if (zeObject == null)
            {
                zeObject = new GameObject(strName);
                zeObject.transform.parent        = caller.transform;
                zeObject.transform.localPosition = Vector3.zero;
                zeObject.transform.localScale    = Vector3.one;
                zeObject.layer = LayerMask.NameToLayer(strLayer);
            }
            customMesh.AttachMeshTo(zeObject, material);
            if (bCollider)
            {
                customMesh.AddMeshCollider(zeObject);
            }

            yield return(null);

            Debug.Log("(5) Dt=" + (Time.time - T));
            T = Time.time;

            caller.gameObject.SendMessage("OnPunchOutDone", zeObject);
        }
Exemplo n.º 7
0
 public void PunchOutAndInitialize(MonoBehaviour caller, XZPolygon polygon, bool bKeepInterior, GameObject zeObject, string strName, string strLayer, CustomMesh customMesh, Material material, bool bCollider)
 {
     caller.StartCoroutine(CoroutinePunchOutAndInitialize(caller, polygon, bKeepInterior, zeObject, strName, strLayer, customMesh, material, bCollider));
 }
Exemplo n.º 8
0
 public CustomMeshInterlinked(CustomMesh customMeshOriginal)
     : base(customMeshOriginal)
 {
 }