public void Restore() { //print("Restore node_backup is\n " + node_backup.Replace(Environment.NewLine, Environment.NewLine + "ModelMultiParticlePersistFX ")); string[] text = node_backup.Split(new[] { "\n" }, StringSplitOptions.None); ConfigNode node = SmokeScreenUtil.RecurseFormat(SmokeScreenUtil.PreFormatConfig(text)); OnLoad(node); }
//[MethodImpl(MethodImplOptions.AggressiveInlining)] private Vector3 ParticleCollision(Vector3d pPos, Vector3d pVel, int mask) { RaycastHit hit; if (Physics.Raycast( pPos, pVel, out hit, (float)pVel.magnitude * Time.deltaTime * physicsPass * TimeWarp.CurrentRate, mask)) { //// collidersName[hit.collider.name] = true; if (hit.collider.name != SmokeScreenUtil.LaunchPadGrateColliderName) { Vector3 unitTangent = (hit.normal.x == 0 && hit.normal.y == 0) ? new Vector3(1, 0, 0) : Vector3.ProjectOnPlane(new Vector3(0, 0, 1), hit.normal).normalized; Vector3 hVel = Vector3.ProjectOnPlane(pVel, hit.normal); Vector3 reflectedNormalVelocity = hVel - pVel; float residualFlow = reflectedNormalVelocity.magnitude * (1 - collideRatio); // An attempt at a better velocity change; the blob collides with some // restitution coefficient collideRatio << 1 and we add a random tangential term // for outflowing particles---randomness handwaved in through fluid dynamics: float randomAngle = Random.value * 360.0f; Vector3d outflow = Quaternion.AngleAxis(randomAngle, hit.normal) * unitTangent * residualFlow; pVel = hVel + collideRatio * reflectedNormalVelocity + outflow * (1 - stickiness); } else { // Don't collide with the launch pad grid and add colliders under it if (!addedLaunchPadCollider) { addedLaunchPadCollider = SmokeScreenUtil.AddLaunchPadColliders(hit); } } } return(pVel); }
private void windowGUI(int ID) { GUILayout.BeginVertical(); activated = GUILayout.Toggle(activated, "Active"); GUILayout.Space(10); overRideInputs = GUILayout.Toggle(overRideInputs, "Manual Inputs"); GUIInput((int)MultiInputCurve.Inputs.power, "Power"); GUIInput((int)MultiInputCurve.Inputs.density, "Atmo Density"); GUIInput((int)MultiInputCurve.Inputs.mach, "Mach Speed"); GUIInput((int)MultiInputCurve.Inputs.parttemp, "Part Temperature"); GUIInput((int)MultiInputCurve.Inputs.externaltemp, "External Temperature"); if (persistentEmitters.Count > 0) { GUILayout.Label("Shader: " + persistentEmitters[0].pe.pr.material.shader.name); } GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("Single Emit Timer")) { OnEvent(); } if (GUILayout.Button("Clear Particles")) { for (int i = 0; i < persistentEmitters.Count; i++) { persistentEmitters[i].pe.pe.ClearParticles(); } } GUILayout.EndHorizontal(); GUILayout.Space(10); nodeEdit = GUILayout.Toggle(nodeEdit, "Open Config Editor"); if (nodeEdit) { GUILayout.BeginHorizontal(); // Set the node with what was in the .cfg if (GUILayout.Button("Import")) { nodeText = string.Copy(node_backup); //print("Displaying node \n " + nodeText.Replace("\n", "\n" + "ModelMultiParticlePersistFX ")); } // Rebuild the text from the active config if (GUILayout.Button("Rebuild")) { ConfigNode node = new ConfigNode(); OnSave(node); nodeText = SmokeScreenUtil.WriteRootNode(node); } // Apply the text if (GUILayout.Button("Apply")) { string[] text = nodeText.Split(new[] { "\n" }, StringSplitOptions.None); ConfigNode node = SmokeScreenUtil.RecurseFormat(SmokeScreenUtil.PreFormatConfig(text)); OnLoad(node); } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.MinHeight(300)); nodeText = GUILayout.TextArea(nodeText, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); } GUILayout.EndVertical(); GUI.DragWindow(); }
public void Backup(ConfigNode node) { node_backup = SmokeScreenUtil.WriteRootNode(node); //print("Backup node_backup is\n " + node_backup.Replace(Environment.NewLine, Environment.NewLine + "ModelMultiParticlePersistFX ")); }