예제 #1
0
        /// /////////////////////////////////////////////////////////
        /// Methods
        /// /////////////////////////////////////////////////////////

        // Fragment this object by shatter properties
        public void Fragment()
        {
            // Cache variables
            if (DefineComponents() == false)
            {
                return;
            }

            // Cache default vars
            SetVariables();

            // Check if object is too small
            ScaleCheck();

            // Cache
            RFFragment.CacheMeshes(ref meshes, ref pivots, ref origSubMeshIdsRF, this);

            // Stop
            if (meshes == null)
            {
                return;
            }

            // Create fragments
            fragmentsLast = CreateFragments();

            // Collect to all fragments
            fragmentsAll.AddRange(fragmentsLast);

            // Reset original object back if it was scaled
            transForm.localScale = originalScale;
        }
예제 #2
0
        /// /////////////////////////////////////////////////////////
        /// Methods
        /// /////////////////////////////////////////////////////////

        // Fragment this object by shatter properties
        public void Fragment(int fragmentMode = 0)
        {
            // Cache variables
            if (DefineComponents() == false)
            {
                return;
            }

            // Cache default vars
            SetVariables();

            // Check if object is too small
            ScaleCheck();

            // Cache
            RFFragment.CacheMeshes(ref meshes, ref pivots, ref origSubMeshIdsRF, this);

            // Stop
            if (meshes == null)
            {
                return;
            }

            // Create fragments
            if (fragmentMode == 1)
            {
                if (rootChildList[rootChildList.Count - 1] != null)
                {
                    fragmentsLast = CreateFragments(rootChildList[rootChildList.Count - 1].gameObject);
                }
                else
                {
                    fragmentMode = 0;
                }
            }
            if (fragmentMode == 0)
            {
                fragmentsLast = CreateFragments();
            }

            // Vertex limitation
            VertexLimitation();

            // Collect to all fragments
            fragmentsAll.AddRange(fragmentsLast);

            // Reset original object back if it was scaled
            transForm.localScale = originalScale;
        }
예제 #3
0
        /// /////////////////////////////////////////////////////////
        /// Methods
        /// /////////////////////////////////////////////////////////

        // Fragment this object by shatter properties
        public void Fragment(int fragmentMode = 0)
        {
            // Cache variables
            if (DefineComponents() == false)
            {
                return;
            }

            // Cache default vars
            SetVariables();

            // Check if object is too small
            ScaleCheck();

            // Cache
            RFFragment.CacheMeshes(ref meshes, ref pivots, ref origSubMeshIdsRF, this);

            // Stop
            if (meshes == null)
            {
                return;
            }

            // Create fragments
            if (fragmentMode == 1)
            {
                if (rootChildList[rootChildList.Count - 1] != null)
                {
                    fragmentsLast = CreateFragments(rootChildList[rootChildList.Count - 1].gameObject);
                }
                else
                {
                    fragmentMode = 0;
                }
            }
            if (fragmentMode == 0)
            {
                fragmentsLast = CreateFragments();
            }

            // Vertex limitation
            if (advanced.vertexLimitation == true)
            {
                for (int i = fragmentsLast.Count - 1; i >= 0; i--)
                {
                    MeshFilter mf = fragmentsLast[i].GetComponent <MeshFilter>();
                    if (mf.sharedMesh.vertexCount > advanced.vertexAmount)
                    {
                        RayfireShatter shat = fragmentsLast[i].AddComponent <RayfireShatter>();
                        shat.voronoi.amount = 4;

                        shat.Fragment();
                        Debug.Log(shat.name);

                        if (shat.fragmentsLast.Count > 0)
                        {
                            fragmentsLast.AddRange(shat.fragmentsLast);
                            DestroyImmediate(shat.gameObject);
                            fragmentsLast.RemoveAt(i);
                        }
                    }
                }
            }

            // Collect to all fragments
            fragmentsAll.AddRange(fragmentsLast);

            // Reset original object back if it was scaled
            transForm.localScale = originalScale;
        }