// Set Shatter Runtime Mode properties static void SetShatterRuntimeMode(RFShatter shatter) { shatter.EditorMode(false); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_shatter, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_cap, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_weld, true); }
// Set Shatter Runtime Mode properties static void SetShatterRuntimeMode(RFShatter shatter) { shatter.EditorMode(false); //shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_shatter, true); //shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_cap, true); //shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_weld, true); // TODO tests vals shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_shatter, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_cap, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_weld, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.minFacesFilter, 3); }
// Set Shatter Editor Mode properties static void SetShatterEditorMode(RFShatter shatter, float sizeFilter, bool preCap, bool remCap, bool remDbl, bool exInside) { shatter.EditorMode(true); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_pre_cap, preCap); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_remove_cap_faces, remCap); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_separate_only, false); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_elliminateCollinears_maxIterFuse, 150); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_min_bbox_diag_size_filter, sizeFilter); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_exclude_inside, exInside); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_remove_double_faces, remDbl); shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_remove_inversed_double_faces, remDbl); shatter.SetGeneralParameter(RFShatter.GeneralParams.minFacesFilter, 0); }
/// ///////////////////////////////////////////////////////// /// Properties setup /// ///////////////////////////////////////////////////////// // Set common fragmentation properties static RFShatter SetShatter(int shatterMode, Mesh mesh, Transform transform, RFSurface interior, bool decompose, bool deleteCol, int seed = 1, FragmentMode mode = FragmentMode.Runtime, bool preCap = true, bool remCap = false, bool remDbl = true, bool exInside = false, int percSize = 3) { // Creating shatter RFShatter shatter = new RFShatter((RFShatter.RFShatterMode)shatterMode, true); // Safe/unsafe properties if (mode == FragmentMode.Editor) { float sizeFilter = mesh.bounds.size.magnitude * percSize / 100f; // TODO check render bound size SetShatterEditorMode(shatter, sizeFilter, preCap, remCap, remDbl, exInside); } else { SetShatterRuntimeMode(shatter); } // Detach by elements shatter.DecomposeResultMesh(decompose); // Set properties shatter.SetFragmentParameter(RFShatter.FragmentParams.seed, seed); shatter.SetGeneralParameter(RFShatter.GeneralParams.pre_weld_threshold, 0.001f); shatter.SetGeneralParameter(RFShatter.GeneralParams.delete_collinear, deleteCol); // Other shatter.SetGeneralParameter(RFShatter.GeneralParams.maping_scale, interior.mappingScale); shatter.SetGeneralParameter(RFShatter.GeneralParams.restore_normals, true); // Setting shatter params bool inputState = shatter.SetInputMesh(transform, mesh); // Failed input if (inputState == false) { Debug.Log("Bad input mesh: " + transform.name, transform.gameObject); return(null); } return(shatter); }
/// ///////////////////////////////////////////////////////// /// Clusters /// ///////////////////////////////////////////////////////// // Set clusters static void SetClusters(RFShatter shatter, RFShatterCluster gluing) { shatter.InitClustering(true); shatter.SetClusterParameter(RFShatter.ClusterParams.enabled, true); shatter.SetClusterParameter(RFShatter.ClusterParams.by_pcloud_count, gluing.count); shatter.SetClusterParameter(RFShatter.ClusterParams.options_seed, gluing.seed); shatter.SetClusterParameter(RFShatter.ClusterParams.preview_scale, 100f); // Debris shatter.SetClusterParameter(RFShatter.ClusterParams.debris_layers_count, gluing.layers); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_count, gluing.amount); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_scale, gluing.scale); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_min, gluing.min); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_max, gluing.max); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_tessellate, false); shatter.SetClusterParameter(RFShatter.ClusterParams.debris_remove, false); // Glue shatter.SetGeneralParameter(RFShatter.GeneralParams.glue, true); shatter.SetGeneralParameter(RFShatter.GeneralParams.glue_weld_threshold, 0.001f); shatter.SetGeneralParameter(RFShatter.GeneralParams.relax, gluing.relax); }
// Decompose to elements static void SetDecompose(RFShatter shatter) { shatter.SetGeneralParameter(RFShatter.GeneralParams.editor_mode_separate_only, true); }