public void SetColorTemperature(int newColorTemperature, int id) { switch (id) { case 0: StartColor.Color = ColorAssistant.ConvertColorTemperatureToColor(newColorTemperature); StartColorButton.Content = newColorTemperature.ToString(); break; case 1: CenterColor.Color = ColorAssistant.ConvertColorTemperatureToColor(newColorTemperature); CenterColorButton.Content = newColorTemperature.ToString(); break; case 2: StopColor.Color = ColorAssistant.ConvertColorTemperatureToColor(newColorTemperature); StopColorButton.Content = newColorTemperature.ToString(); break; } if (rgbMode == false) { onColorClass.ColorTemperatureGradientThreeChanged(Convert.ToInt32(StartColorButton.Content), Convert.ToInt32(CenterColorButton.Content), Convert.ToInt32(StopColorButton.Content)); } }
/// <summary> /// Sets the output display to the given values. /// </summary> /// <param name="brightness">The new brightness, can also be null if it shouldn't change</param> /// <param name="rgbColor">The new color, can also be null if it shouldn't change</param> /// <param name="rgbColor">The new colorTemperature, can also be null if it shouldn't change</param> public static async void UpdateOutputDisplay(int?brightness, RGBColor?rgbColor, int?colorTemperature) { //Runs the code in the UI thread. await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (partyControlAdvanced != null) { if (rgbColor == null && colorTemperature == null) { partyControlAdvanced.UpdateOutputDisplay(brightness, null); } if (rgbColor != null && colorTemperature == null) { partyControlAdvanced.UpdateOutputDisplay(brightness, ColorAssistant.ConvertRGBColorToColor((RGBColor)rgbColor)); } if (rgbColor == null && colorTemperature != null) { partyControlAdvanced.UpdateOutputDisplay(brightness, ColorAssistant.ConvertColorTemperatureToColor((int)colorTemperature)); } } }); }
//Temperture Color Picker private void SetTemperatureColorPicker() { int colorTemperature = 250; foreach (Light light in BridgeInformation.lights) { if (BridgeInformation.usedLights.Contains(light.Id)) { if (LightInformation.IsTemperatureType(light)) { colorTemperature = Convert.ToInt32(light.State.ColorTemperature); } else { Color color = ColorAssistant.ConvertRGBColorToColor(light.State.ToRGBColor()); int temp = ColorAssistant.TryToConvertColorToColorTemperatur(color); if (temp != -1) { colorTemperature = temp; } } } } ((TemperatureColorPicker)ColorPickerFrame.Content).SetColorTemperatureSliderPosition(colorTemperature); }
private void visualizeCenterLine() { LineRenderer lr = initLine(ColorAssistant.getQualitativeColor(2), 0.1f, "BSpline"); for (int i = 0; i < interpolation.Length; i++) { extendLine(new Vector3(interpolation[i].x, interpolation[i].y, interpolation[i].z), lr, i); } }
//RGB Color Picker private void SetRGBColorPicker() { Color color = Color.FromArgb(255, 255, 255, 255); if (!LightInformation.IsTemperatureType(BridgeInformation.mainLightTarget)) { color = ColorAssistant.ConvertRGBColorToColor(BridgeInformation.mainLightTarget.State.ToRGBColor()); } ((RGBColorPicker)ColorPickerFrame.Content).SetRGBColorPickerColor(color); }
/** * Shows a cube in which all samples should be contained **/ private void visualizeBoundingVolume() { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.localScale = base._size; cube.transform.position = base._center; cube.name = "BoundingVolume"; Color col = ColorAssistant.getQualitativeColor(1); col.a = 100.0f / 255.0f; setColor(cube, col); }
/// <summary> /// Gets the color of a light. /// </summary> /// <param name="light">The light with which the method works</param> /// <returns>The color of a light.</returns> public static Color GetLightColor(Light light) { if (!IsTemperatureType(light)) { Color color = ColorAssistant.ConvertRGBColorToColor(light.State.ToRGBColor()); return(color); } else { Color color = ColorAssistant.ConvertColorTemperatureToColor((int)light.State.ColorTemperature); return(color); } }
private void visualizeKeypoints(Vector4[] points) { foreach (Vector4 ball in points) { GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = new Vector3(ball.w * 2, ball.w * 2, ball.w * 2); // radius to diameter sphere.transform.position = new Vector3(ball.x, ball.y, ball.z); sphere.name = "Keypoint"; Color col = ColorAssistant.getQualitativeColor(0); setColor(sphere, col); sphere.transform.parent = gameObject.transform; } }
public override void visualize() { foreach (Vector3 sample in _data.samples) { // draw a sphere at the sample location GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); sphere.transform.position = sample; sphere.name = "sample"; Color col = ColorAssistant.getDivergingColor(0); setColor(sphere, col); } _data.visualize(); }
public void visualizeVertices(ITriangulation <Vector3Vertex, DefaultTriangulationCell <Vector3Vertex> > triangulation) { // visualize foreach (var cell in triangulation.Cells) { foreach (var vertex in cell.Vertices) { GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = vertex.toVector3(); sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); sphere.transform.SetParent(_delaunay.transform); setColor(sphere, ColorAssistant.getQualitativeColor(0)); } } }
public void visualizeVertices(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation) { // visualize foreach (var cell in triangulation.Vertices) { foreach (var vertex in cell.Vertices) { GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = vertex.toVector3(); sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); sphere.transform.SetParent(_voronoi.transform); setColor(sphere, ColorAssistant.getQualitativeColor(1)); } } }
public void visualizeCells(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation) { Tetrahedron cell = triangulation.Vertices.First <Tetrahedron>(); //foreach (var cell in triangulation.Vertices) //{ Mesh faces = cell.CreateModel(ColorAssistant.getDivergingColor(0), 1.0f); faces.RecalculateNormals(); faces.RecalculateBounds(); GameObject o = new GameObject("cell"); o.AddComponent <MeshFilter>(); o.GetComponent <MeshFilter>().mesh = faces; o.AddComponent <MeshRenderer>(); //} }
private GradientStopCollection GenerateGradientStopCollection(Color colorInput) { Color firstColor = ColorAssistant.GetStepBetweenTwoColors(Color.FromArgb(255, 255, 255, 255), colorInput, 0.5f); GradientStopCollection gradientStops = new GradientStopCollection(); gradientStops.Add(new GradientStop() { Color = firstColor, Offset = 0 }); gradientStops.Add(new GradientStop() { Color = colorInput, Offset = 1 }); return(gradientStops); }
public void visualizeEdges(VoronoiMesh <Vector3Vertex, Tetrahedron, VoronoiEdge <Vector3Vertex, Tetrahedron> > triangulation) { // visualize foreach (var edge in triangulation.Edges) { Vector3 from = edge.Source.calculateCircumsphere(); Vector3 to = edge.Target.calculateCircumsphere(); drawLine(from, to, ColorAssistant.getDivergingColor(0)); } /* * int cellIdx = 0; * foreach(var cell in triangulation.Vertices) * { * foreach(var neighbor in cell.Adjacency) * { * if (neighbor == null) continue; * Vector3 from = cell.calculateCircumsphere(); * Vector3 to = neighbor.calculateCircumsphere(); * * drawLine(from, to, ColorAssistant.getQualitativeColor(cellIdx)); * } * cellIdx++; * } */ /* * foreach (var cell in triangulation.Vertices) * { * for (int i = 0; i < 4; i++) * { * if (cell.Adjacency[i] == null) * { * Vector3 from = cell.calculateCircumsphere(); * var t = cell.Vertices.Where((_, j) => j != i).ToArray(); * float factor = 100.0f ; * Vector3 dir = new Vector3((float)(0.5f * (t[0].Position[0] + t[1].Position[0])), (float)(0.5f * (t[0].Position[1] + t[1].Position[1])), (float)(0.5f * (t[0].Position[2] + t[1].Position[2]))) - from; * Vector3 to = from + factor * dir; * drawLine(from, to, ColorAssistant.getDivergingColor(1)); * } * } * } */ }
private void visualizeHull() { for (int i = 0; i < interpolation.Length; i++) { Vector4 c = interpolation[i]; Vector4 dc = dinterpolation[i]; Vector3 lastBasis = Vector3.right; Vector3[] segments = calculateCircle(new Vector3(c.x, c.y, c.z), new Vector3(dc.x, dc.y, dc.z), c.w, ref lastBasis, nCirclePolypoints); LineRenderer lr = initLine(ColorAssistant.getQualitativeColor(1), 0.03f, "SurfaceRing"); for (int j = 0; j < segments.Length; j++) { extendLine(segments[j], lr, j); } extendLine(segments[0], lr, segments.Length); // close the circle } }
private void visualizeSamples() { for (int i = 0; i < _grid.nSamples; i++) { Vector3 sample = _grid.samples[i]; // draw a sphere at the sample location GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); sphere.transform.position = sample; sphere.name = "sample"; Color col = ColorAssistant.getQualitativeColor(0); setColor(sphere, col); sphere.transform.SetParent(_visualization.transform); } // throwing dart around this one GameObject sphere3 = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere3.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); sphere3.transform.position = consideredSample; sphere3.name = "Considered Sample"; Color col3 = ColorAssistant.getQualitativeColor(2); setColor(sphere3, col3); sphere3.transform.SetParent(_visualization.transform); // generated this one GameObject sphere2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere2.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); sphere2.transform.position = newSample; sphere2.name = "New Sample"; Color col2 = ColorAssistant.getQualitativeColor(1); setColor(sphere2, col2); sphere2.transform.SetParent(_visualization.transform); }
private void visualizeSamples() { foreach (Vector3 sample in _data.samples) { // draw a sphere at the sample location GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); sphere.transform.position = sample; sphere.name = "sample"; Color col = ColorAssistant.getDivergingColor(0); setColor(sphere, col); // draw Neighborhood hull // 186,228,179 GameObject sphere2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); float hullSize = _minDist; // diameter of the sphere = 2 * radius. Therefore, no two such hull spheres should intersect sphere2.transform.localScale = new Vector3(hullSize, hullSize, hullSize); sphere2.transform.position = sample; sphere2.name = "hull"; Color col2 = ColorAssistant.getDivergingColor(1); col2.a = 70.0f / 255.0f; setColor(sphere2, col2); } }
private Vector3[] calculateSphereCap(Vector3 center, Vector3 normal, float spin, float radius, Vector3 basis) { Vector3[] points = new Vector3[getSphericalCapSize()]; // the full sphere consists of two caps for (int j = 0; j < points.Length; j++) { points[j] = new Vector3(0, 0, 0); } normal.Normalize(); Vector3 basis2 = Vector3.Cross(normal, basis); Vector3 basis1 = Vector3.Cross(normal, basis2); bool tipPlaced = false; // the very tip of the spherical cap is just one point, not a whole circle. int i = 0; for (int angle1 = nCirclePolypoints / 2; angle1 >= 0; angle1--) { for (int angle2 = 0; angle2 < nCirclePolypoints; angle2++) { float theta = Mathf.PI + 2 * Mathf.PI / nCirclePolypoints * angle2; // runs [0 2Pi] float omega = 2 * Mathf.PI / nCirclePolypoints * angle1; // runs [0 Pi] if (Mathf.Cos(omega) <= 0) { continue; } int thetaDegree = (int)((theta * 180 / Mathf.PI) % 360); int omegaDegree = (int)((omega * 180 / Mathf.PI) % 360); //Debug.Log("T:" + theta * 180 / Mathf.PI + ", O:" + omega * 180 / Mathf.PI); // Place the tip point if (!tipPlaced && (angle1 == nCirclePolypoints / 2 || angle1 == 0)) { tipPlaced = true; points[i] = calculatePointOnSphere(center, normal, spin, radius, theta, omega, basis1, basis2); addMarker(points[i], i + "(" + thetaDegree + "," + omegaDegree + ")", ColorAssistant.getQualitativeColor(angle1)); i++; } // all other sphere points if (angle1 != nCirclePolypoints / 2 && angle1 != 0) { // generate the new point points[i] = calculatePointOnSphere(center, normal, spin, radius, theta, omega, basis1, basis2); addMarker(points[i], i + "(" + thetaDegree + "," + omegaDegree + ")", ColorAssistant.getQualitativeColor(angle1)); tipPlaced = false; i++; } } } Debug.Log("Constructed " + i + "/" + getSphericalCapSize() + " points."); return(points); }