public static void DrawSplineSceneGUI(Camera sceneviewCamera, NodeConnection connection) { var startColor = connection.Configuration != null ? connection.Configuration.PreviewColor : Color.gray; /* * float h, s, v; * Color.RGBToHSV(startColor, out h, out s, out v); * var endColor = Color.HSVToRGB(h + .5f, s, v);*/ if (RoadNetworkWindow.IsSelected(connection) || RoadNetworkWindow.IsSelected(connection.NextNode)) { var spline = connection.GetSpline(true); var pointCount = Mathf.Min(spline.Points.Count, 30); int lastIndex = 0; for (int i = 1; i < pointCount; i++) { var percentageThrough = i / (float)pointCount; var index = Mathf.FloorToInt(percentageThrough * spline.Points.Count); //Handles.color = Color.Lerp(startColor, endColor, percentageThrough); Handles.color = startColor; Handles.DrawLine(spline.Points[lastIndex].Position, spline.Points[index].Position); lastIndex = index; } Handles.color = startColor; if (pointCount > 0) { Handles.DrawLine(spline.Points[lastIndex].Position, spline.Points[spline.Points.Count - 1].Position); } } else { Handles.color = startColor; Handles.DrawLine(connection.ThisNode.NodePosition, connection.NextNode.NodePosition); } }
public override void ProcessObjects(TerrainWrapper wrapper, LayerBase baseLayer, int stencilKey) { var layer = baseLayer as MMTerrainLayer; if (layer == null) { Debug.LogWarning(string.Format("Attempted to write {0} to incorrect layer type! Expected Layer {1} to be {2}, but it was {3}", name, baseLayer.name, GetLayerType(), baseLayer.GetType()), this); return; } if (!Network) { return; } if (Configuration == null) { return; } var config = Configuration.GetConfig <Config>(); if (config == null) { Debug.LogError("Invalid configuration! Expected ConnectionTerrainHeightConfiguration"); return; } var spline = NodeConnection.GetSpline(); var bounds = spline.GetApproximateXZObjectBounds(); bounds.Expand(new Vector3(config.ObjectRemoveDistance, 1000, config.ObjectRemoveDistance)); var tPos = wrapper.transform.position; var tSize = wrapper.Terrain.terrainData.size; var regex = new Regex(config.RegexMatch ?? string.Empty); var objects = wrapper.GetCompoundObjects(layer, true); foreach (var data in objects) { if (data.Prefab == null || !regex.IsMatch(data.Prefab.name)) { continue; } var wPos = tPos + new Vector3(data.Position.x * tSize.x, data.Position.y, data.Position.z * tSize.z); if (!bounds.Contains(wPos)) { //Debug.DrawLine(wPos, wPos + Vector3.up * 10, Color.cyan, 20); continue; } var ut = spline.GetClosestUniformTimeOnSplineXZ(wPos.xz()); var pointOnSpline = spline.GetUniformPointOnSpline(ut); var dist = (pointOnSpline.xz() - wPos.xz()).magnitude; if (dist < config.ObjectRemoveDistance) { if (!layer.ObjectRemovals.Contains(data.Guid)) { layer.ObjectRemovals.Add(data.Guid); } if (ShowDebug) { Debug.DrawLine(pointOnSpline, wPos, Color.red, 20); } } else { if (ShowDebug) { Debug.DrawLine(pointOnSpline, wPos, Color.green, 20); } } } }
public virtual void SetData(NodeConnection nodeConnection, ComponentConfigurationRef config) { Configuration = config; NodeConnection = nodeConnection; }