// Use this for initialization void Start() { segments = new List <CatmullRomSegment>(); spheres = new List <DraggablePoint>(); if (points.Count < 4) { createSpheres(); return; } if (randomize) { for (int i = 0; i < points.Count; i++) { points[i] = 2f * Random.insideUnitSphere; points[i] += 2.5f * Vector3.up; } } SetMaterial(DesignerController.instance.defaultLineMaterial); lineRender.SetColors(Color.white, Color.red); makeSegments(); createSpheres(); MoveEndpoints(); updateRenderPoints(); if (!containingCanvas) { containingCanvas = FindObjectOfType <SplineCanvas>(); containingCanvas.AddExistingSpline(this); } }
// Use this for initialization void Start() { currentMode = DesignerMode.Shell; modeText.text = "Shell mode"; kMeansPoints.text = "0"; impulsePoints.text = numImpulses.ToString(); splineCanvas = FindObjectOfType <SplineCanvas>(); NumKMeansPoints = 10; }
void GetCanvas() { if (!outputCanvas) { outputCanvas = FindObjectOfType <SplineCanvas>(); if (!outputCanvas) { GameObject canvasObj = new GameObject(); canvasObj.name = name + "-canvas"; outputCanvas = canvasObj.AddComponent <SplineCanvas>(); } } }
void AddLine(List <int> pointIndices) { if (!outputCanvas) { outputCanvas = FindObjectOfType <SplineCanvas>(); if (!outputCanvas) { GameObject canvasObj = new GameObject(); canvasObj.name = name + "-canvas"; outputCanvas = canvasObj.AddComponent <SplineCanvas>(); } } Vector3[] points = new Vector3[pointIndices.Count]; for (int i = 0; i < points.Length; i++) { Vector3 pos = mesh.vertices[pointIndices[i]]; points[i] = pos; } GameObject lineObj = new GameObject(); lineObj.transform.parent = transform; lineObj.transform.localPosition = Vector3.zero; lineObj.transform.localRotation = Quaternion.identity; lineObj.name = "skeleton-spline"; // Create spline from points // Transform to world space for (int i = 0; i < points.Length; i++) { points[i] = transform.rotation * points[i] + transform.position; } CatmullRomSpline crs = lineObj.AddComponent <CatmullRomSpline>(); crs.points = new List <Vector3>(); Vector3 firstDiff = points[1] - points[0]; Vector3 first = points[0] - 0.01f * firstDiff.normalized; Vector3 lastDiff = points[points.Length - 2] - points[points.Length - 1]; Vector3 last = points[points.Length - 1] - 0.01f * lastDiff.normalized; crs.points.Add(first); crs.points.AddRange(points); crs.points.Add(last); outputCanvas.AddExistingSpline(crs); /* * LineRenderer line = lineObj.AddComponent<LineRenderer>(); * line.useWorldSpace = false; * * line.SetVertexCount(points.Length); * line.SetPositions(points); * line.SetWidth(0.1f, 0.1f); * line.material = DesignerController.instance.defaultLineMaterial; * Color c = Color.HSVToRGB(hue, 1, 1); * line.SetColors(c, c); * hue = Mathf.Repeat(hue + 0.3f, 1); */ }
// Use this for initialization void Start() { canvas = GetComponent <SplineCanvas>(); }