private void UpdateHighLightScale(Vector3 clampScale) { float max = Math.Max(clampScale) * highlightSphereScale; highlightObj.transform.localScale = new Vector3((1 / clampScale.x) * max, (1 / clampScale.y) * max, (1 / clampScale.z) * max); // If tbe clamp is too small, match a minimum global size if (highlightObj.transform.lossyScale.x < minHighlightGlobalSize) { Vector3 globalSize = new Vector3(minHighlightGlobalSize, minHighlightGlobalSize, minHighlightGlobalSize); Transform curParent = transform.parent; // Convert global size to local space do { globalSize = new Vector3(globalSize.x / curParent.localScale.x, globalSize.y / curParent.localScale.y, globalSize.z / curParent.localScale.z); curParent = curParent.parent; } while (curParent.parent != null); globalSize = new Vector3(globalSize.x / curParent.localScale.x, globalSize.y / curParent.localScale.y, globalSize.z / curParent.localScale.z); highlightObj.transform.localScale = globalSize; } }
/// <summary> /// Sets the radius and height of the clamp /// </summary> private void SetScale(Neuron.NodeData cellNodeData) { currentVisualizationScale = (float)simulation.VisualInflation; float radiusScalingValue = radiusRatio * (float)cellNodeData.NodeRadius; float heightScalingValue = heightRatio * simulation.AverageDendriteRadius; //Ensures clamp is always at least as wide as tall when Visual Inflation is 1 float radiusLength = Math.Max(radiusScalingValue, heightScalingValue) * currentVisualizationScale; //if (somaClamp) transform.parent.localScale = new Vector3(radiusLength, radiusLength, radiusLength); transform.parent.localScale = new Vector3(radiusLength, radiusLength, heightScalingValue); UpdateHighLightScale(transform.parent.localScale); }
/// <summary> /// If the user holds a raycast down for X seconds on a clamp, it should destroy the clamp /// </summary> public void MonitorInput() { if (ClampManager.PressedCancel) { ResetInput(); } if (ClampManager.PressedToggleDestroy) { holdCount++; // If we've held the button long enough to destory, color caps red until user releases button if (holdCount > ClampManager.destroyCount && !powerClick) { SwitchCaps(false); } else if (powerClick) { SwitchCaps(true); } } else { CheckInput(); } float power = ClampManager.PowerModifier; // If clamp power is modified while the user holds a click, don't let the click also toggle/destroy the clamp if (power != 0 && !powerClick) { powerClick = true; } ClampPower += power; Math.Clamp(ClampPower, MinPower, MaxPower); }
public void SwitchVisualMesh(double inflation) { inflation = Math.Clamp(inflation, 1, 5); VisualInflation = inflation; }