예제 #1
0
        // Copy from
        void CopyFrom(RayfireShatter shatter)
        {
            type = shatter.type;

            voronoi   = new RFVoronoi(shatter.voronoi);
            splinters = new RFSplinters(shatter.splinters);
            slabs     = new RFSplinters(shatter.slabs);
            radial    = new RFRadial(shatter.radial);
            custom    = new RFCustom(shatter.custom);
            slice     = new RFSlice(shatter.slice);
            tets      = new RFTets(shatter.tets);

            mode = shatter.mode;
            material.CopyFrom(shatter.material);
            clusters = new RFShatterCluster(shatter.clusters);
            advanced = new RFShatterAdvanced(shatter.advanced);
        }
예제 #2
0
 // Constructor
 public RFTets(RFTets src)
 {
     lattice = src.lattice;
     density = src.density;
     noise   = src.noise;
 }
예제 #3
0
        // Set Custom Voronoi properties
        static void SetTet(RFShatter shatter, Bounds bounds, RFTets tets)
        {
            // Main
            shatter.SetFragmentParameter(RFShatter.FragmentParams.type, (int)RFShatter.FragmentType.tetra);
            shatter.SetFragmentParameter(RFShatter.FragmentParams.tetra_type, (int)tets.lattice);

            // Get max
            float max = bounds.size.x;

            if (bounds.size.y > max)
            {
                max = bounds.size.y;
            }
            if (bounds.size.z > max)
            {
                max = bounds.size.z;
            }
            if (max == 0)
            {
                max = 0.01f;
            }

            // Get density
            Vector3Int density = new Vector3Int(
                (int)Mathf.Ceil(bounds.size.x / max * tets.density),
                (int)Mathf.Ceil(bounds.size.y / max * tets.density),
                (int)Mathf.Ceil(bounds.size.z / max * tets.density));

            // Limit
            if (density.x > 30)
            {
                density.x = 30;
            }
            else if (density.x < 1)
            {
                density.x = 1;
            }
            if (density.y > 30)
            {
                density.y = 30;
            }
            else if (density.y < 1)
            {
                density.y = 1;
            }
            if (density.z > 30)
            {
                density.z = 30;
            }
            else if (density.z < 1)
            {
                density.z = 1;
            }

            // Set density
            shatter.SetPoint3Parameter((int)RFShatter.FragmentParams.tetra2_density, density);
            shatter.SetPoint3Parameter((int)RFShatter.FragmentParams.tetra1_density, density);

            // Noise
            shatter.SetFragmentParameter(RFShatter.FragmentParams.tetra_noise, tets.noise);
        }