public static void DrawAsterisms() { if (m_leftCamera == null || m_rightCamera == null) { Debug.LogError("No Draw Camera Defined."); return; } if (AsterismParser.AsterismData == null) { return; } VectorLine.SetCamera3D(m_leftCamera); foreach (Asterism asterism in AsterismParser.AsterismData) { if (asterism.lineArt == null) { continue; } asterism.lineArt.Draw3D(); } /* * VectorLine.SetCamera3D(m_rightCamera); * foreach(Asterism asterism in AsterismParser.AsterismData) { * if ( asterism.lineArt == null ) { continue; } * asterism.lineArt.Draw3D(); * }*/ }
void SetSelectionLine() { if (currentSelectionLine != null) { VectorLine.Destroy(ref currentSelectionLine); } VectorLine.SetCamera3D(Camera.main); currentCapName = "cap" + solved; VectorLine.SetEndCap(currentCapName, EndCap.Mirror, lineTex, capTex); endCaps.Add(currentCapName); LineType lineType = LineType.Discrete; Joins joins = Joins.None; float lineWidth = Screen.width * 0.07f; if (currentSelectionLine == null) { lineColors = new List <Color32>(); // currentSelectionLine = new VectorLine("Line", new List<Vector3>(), lineMaterial, lineWidth, lineType, joins); currentSelectionLine = new VectorLine("Line", new List <Vector3>(), lineWidth, lineType, joins); currentSelectionLine.material = lineMaterial; if (currentSelectionLine.endCap == null) { currentSelectionLine.endCap = currentCapName; } } }
void Start() { deformedLineList = new List <VectorLine>(); pointLists = new List <List <Vector3> >(); VectorLine.SetCamera3D(myCamera); //Wireframe of cube VectorLine line = new VectorLine("Wireframe", new List <Vector3>(), 1.0f, LineType.Discrete); Mesh cubeMesh = ((MeshFilter)gameObject.GetComponent("MeshFilter")).mesh; line.MakeWireframe(cubeMesh); line.drawTransform = gameObject.transform; line.Draw3DAuto(); mainLine = new VectorLine("MainLine", new List <Vector3>(), 10.0f); mainLine.Draw3DAuto(); deformedLine = new VectorLine("deformedLine", new List <Vector3>(), 10.0f); deformedLine.Draw3DAuto(); lineTransformList = new List <Transform>(); deformedLineTransformList = new List <Transform>(); //Force Line forceVectorList = new List <Vector3>(); //forceLine = new VectorLine("ForceLine", new List<Vector3>(), 30.0f); //VectorLine.SetEndCap("Arrow", EndCap.Both, -1.0F, lineTex, frontTex, backTex); //forceLine.endCap = "Arrow"; //forceLine.Draw3DAuto(); }
protected void onEnterMapView() { Utils.Log("[SystemHeatOverlay]: Entered map view, clearing panels", LogType.Overlay); VectorLine.SetCamera3D(PlanetariumCamera.Camera); ClearPanels(); }
// Use this for initialization void Start() { //We have to start turtle analysis at the same place each time we stir initialPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z); VectorLine.SetCamera3D(FindObjectOfType <Camera>()); }
public void Init() { if (listLine == null) { listLine = new List <object>(); VectorLine.SetCamera3D(mainCam); isHasDraw = false; } }
protected void onExitMapView() { if (SystemHeatSettings.DebugOverlay) { Utils.Log("[SystemHeatOverlay]: Entered map view, clearing panels"); } VectorLine.SetCamera3D(FlightCamera.fetch.mainCamera); }
protected void onEnterMapView() { if (SystemHeatSettings.DebugOverlay) { Utils.Log("[SystemHeatOverlay]: Entered map view, clearing panels"); } VectorLine.SetCamera3D(PlanetariumCamera.Camera); ClearPanels(); }
void Start() { preview.SetActive(false); //disable until we need it gridGranularity = (float)(1m / 20m); originSet = false; isColliding = false; allowPlacing = false; delLine = new VectorLine("Delete", new List <Vector3>(), 6.0f, LineType.Discrete); VectorLine.SetCamera3D(myCamera); delLine.Draw3DAuto(); }
// Use this for initialization void Start() { //board = GetComponent<Board> (); //player = GetComponent<Player> (); NotificationCenter.DefaultCenter().AddObserver(this, "MenuEnter"); NotificationCenter.DefaultCenter().AddObserver(this, "MenuExit"); NotificationCenter.DefaultCenter().AddObserver(this, "TimerTrigger"); NotificationCenter.DefaultCenter().AddObserver(this, "PlayerDeath"); NotificationCenter.DefaultCenter().AddObserver(this, "Pause"); NotificationCenter.DefaultCenter().AddObserver(this, "Unpause"); VectorLine.SetCamera3D(); }
// Use this for initialization void Start() { for (int i = 0; i < MAX_MESHES; i++) { points[i] = new List <Vector3>(); points[i].Capacity = MAX_VERTEX; meshBack[i] = new Mesh(); } totalTimeSeconds = 1700; timeStepsPerSecond = 10; polarSteps = 100; // handle line VectorLine.SetCamera3D(lineCam); linePoints = new List <Vector3>(); line = new VectorLine("line", linePoints, 7.0f, LineType.Continuous, Joins.Fill); line.drawTransform = displayCube.transform; line2d = new VectorLine("line2d", linePoints, 2.0f, LineType.Continuous, Joins.Fill); GameObject.Find("line").layer = 9; GameObject.Find("line2d").layer = 8; // Initialize the object color palette text fields redValueTextObj.text = redSliderObj.value.ToString(); greenValueTextObj.text = greenSliderObj.value.ToString(); blueValueTextObj.text = blueSliderObj.value.ToString(); currentObjectColor = new Color(0, 0.5f, 0.5f, 1); //RGBa colors. setObjectColor(currentObjectColor); // Initialize the background color palette text fields redValueTextBG.text = redSliderBG.value.ToString(); greenValueTextBG.text = greenSliderBG.value.ToString(); blueValueTextBG.text = blueSliderBG.value.ToString(); currentBGColor = new Color(1, 1, 1, 1); //RGBa colors. setBGColor(currentBGColor); // Initialize the line color palette text fields redValueTextLine.text = redSliderLine.value.ToString(); greenValueTextLine.text = greenSliderLine.value.ToString(); blueValueTextLine.text = blueSliderLine.value.ToString(); currentLineColor = new Color(1, 0, 0, 1); //RGBa colors. setLineColor(currentLineColor); setAxesColor(blackAxesToggle.isOn); }
void Start() { VectorLine.SetCamera3D(Camera.main); if (!GetComponent <File>().IsBacklink) { var from = From.transform.position; var to = To.transform.position; from.y = -0.05f / 2; to.y = -0.05f / 2; Vector3 extentDirection = Vector3.zero; var diff = to - from; if (Math.Abs(diff.x) > Math.Abs(diff.z)) { extentDirection = Math.Sign(diff.x) * Vector3.right; } else { extentDirection = Math.Sign(diff.z) * Vector3.forward; } if (ForcedExtentDirection != Vector3.zero) { extentDirection = ForcedExtentDirection; } var invExtent = -extentDirection; if (ForcedInvExtentDirection != Vector3.zero) { invExtent = ForcedInvExtentDirection; } inStraight = new VectorLine("In", new[] { from, from + extentDirection }, LineMaterial, 1.5f); inter = new VectorLine("Inter", new[] { from + extentDirection, to + invExtent }, LineMaterial, 1.5f); outStraight = new VectorLine("Out", new[] { to + invExtent, to }, LineMaterial, 1.5f); } if (To.Type != File.FileTypes.Shortcut) { To.Type = File.FileTypes.Shortcut; To.IsBacklink = true; To.Refresh(); To.UpdateIcon(); To.GetComponent <Link>().To = GetComponent <File>(); } }
void Start() { VectorLine.SetCamera3D(myCamera); demoLine = new VectorLine("demoLine", new List <Vector3>(), 20.0f, LineType.Discrete); Hemisphere.CreateHemisphereMesh(); demoLine.points3.Add(target1.transform.position); demoLine.points3.Add(pos.transform.position); demoLine.points3.Add(target2.transform.position); demoLine.points3.Add(pos.transform.position); demoLine.Draw3DAuto(); origin = GameObject.CreatePrimitive(PrimitiveType.Sphere); origin.transform.position = pos.transform.position; Destroy(origin.GetComponent <MeshRenderer>()); freedomPos = GameObject.CreatePrimitive(PrimitiveType.Sphere); freedomPos.transform.localScale = new Vector3(0.01F, 0.01F, 0.01F); Destroy(freedomPos.GetComponent <MeshRenderer>()); }
// Start is called before the first frame update void Start() { CommonData.Lenght = Lenght; CommonData.numberOfLines = numberOfLines; distanceBetweenLines = Lenght / (2 * numberOfLines); CommonData.distanceBetweenLines = distanceBetweenLines; CommonData.X_position = gameObject.transform.localPosition.x; CommonData.Z_position = gameObject.transform.localPosition.z; Debug.Log("x=" + gameObject.transform.localPosition.x + " z=" + gameObject.transform.localPosition.z); CommonData.Scale = gameObject.transform.localScale.x; CommonData.Y_Rotate = gameObject.transform.localEulerAngles.y; gridPoints = new List <Vector3>(); XOY_Points = new List <Vector3>(); spline_Current_Points = new List <Vector3>(); spline_Base_Points = new List <Vector3>(); colorGrid = Color.white; colorSpline_Current = Color.red; colorSpline_Base = Color.blue; colorXOY = Color.white; VectorLine.SetCamera3D(CameraMain); VectorLine.SetEndCap("arrow", EndCap.Both, 0, -3, -3, 3, lineTex, frontTex, frontTex); Grid = new VectorLine("Grid", gridPoints, lineWidth * CommonData.distanceBetweenLines); XOY_Line = new VectorLine("XOY_Line", XOY_Points, 8 * lineWidth * CommonData.distanceBetweenLines); Spline_Base = new VectorLine("Spline_Base", spline_Base_Points, 10 * lineWidth * CommonData.distanceBetweenLines, LineType.Continuous); Spline_Current = new VectorLine("Spline_Current", spline_Current_Points, 10 * lineWidth * CommonData.distanceBetweenLines, LineType.Continuous); // var graph_current = GameObject.Find("Spline_Current"); // var graph_base = GameObject.Find("Spline_Base"); // // var controller = GameObject.Find("Controller"); // // // graph_current.transform.parent = controller.transform; // graph_base.transform.parent = controller.transform; // // // graph_current.transform.localPosition = new Vector3(0, 0, -0.015f); // graph_base.transform.localPosition = new Vector3(0, 0, -0.015f); }
public OverlayLine(Transform parent, int id) { Utils.Log($"[OverlayLine]: building line for loop ID {id}"); if (HighLogic.LoadedSceneIsEditor) { VectorLine.SetCamera3D(EditorLogic.fetch.editorCamera); } if (HighLogic.LoadedSceneIsFlight) { VectorLine.SetCamera3D(FlightCamera.fetch.mainCamera); } line = new VectorLine($"SystemHeat_Loop{id}_VectorLine", new List <Vector3>(), SystemHeatSettings.OverlayBaseLineWidth, LineType.Continuous, Joins.Weld); line.layer = 0; line.material = new Material(Shader.Find("GUI/Text Shader")); line.material.renderQueue = 3000; lineColor = SystemHeatSettings.GetLoopColor(id); }
private void DrawArrow(Vector3 direction_camera) { Vector3 ray_direction_world_space = Camera.main.cameraToWorldMatrix.MultiplyVector(direction_camera); float arrowHeadAngle = 45; float arrow_length = 0.005f; Vector3 right = Quaternion.LookRotation(ray_direction_world_space) * Quaternion.Euler(0, 180 + arrowHeadAngle, 0) * new Vector3(0, 0, arrow_length); Vector3 left = Quaternion.LookRotation(ray_direction_world_space) * Quaternion.Euler(0, 180 - arrowHeadAngle, 0) * new Vector3(0, 0, arrow_length); VectorLine.SetCamera3D(Camera.main); float line_width = 2f; float time = Time.deltaTime * 2; VectorLine line = VectorLine.SetLine3D(Color.red, time, new Vector3[] { ray_begin.position, ray_end.position, left, right, ray_end.position }); line.SetWidth(line_width); line.Draw(); }
IEnumerator CreatePath() { Pathway.transform.position = Pathway_init; MoveSpeed_actual = MoveSpeed; Safeway_Threshold_actual = Safeway_Threshold; int checks = 0; while (TargetGrand == null || TargetGrand.Data.Fitness.Ratio > 0.6F) { int r = Random.Range(0, GameManager.instance.Grands.Length); TargetGrand = GameManager.instance.Grands[r].GrandObj; checks++; if (checks > 10) { break; } } if (TargetGrand == null) { TargetGrand = GameManager.Generator.Generate(0); } TargetGrand_Face = GameManager.Generator.GenerateNewFace(TargetGrand.Data); MOB[1].T.rotation = Quaternion.Euler(face_rotation_x, 0, 0); MOB[1].T.localPosition = Vector3.zero; MOB[1].AddChild(TargetGrand_Face); TargetGrand_Face.transform.localPosition = Vector3.up * 4; BalancePoint = Vector3.zero; EndPoint.position = StartPoint.position - StartPoint.up * TotalDistance; MOB[0][0].transform.localScale = new Vector3(19.5F, TotalDistance / 3, 1.0F); MiddlePoints = new Transform[PathPoints]; Velocity = EndPoint.position - StartPoint.position; Velocity.Normalize(); CrossVelocity = Vector3.Cross(Velocity, -Vector3.forward).normalized; float pathrate = 0.9F / PathPoints; for (int i = 0; i < PathPoints; i++) { GameObject g = new GameObject("Path Point " + i); MiddlePoints[i] = g.transform; MiddlePoints[i].position = Vector3.Lerp(StartPoint.position, EndPoint.position, Mathf.Clamp(pathrate + (pathrate * i), 0.0F, 1.0F)); MiddlePoints[i].position += CrossVelocity * ((Random.value - Random.value) * 10); MiddlePoints[i].SetParent(MOB[0].transform); } List <float> splinewidths = new List <float>(); List <Vector3> splinepoints = new List <Vector3>(); splinepoints.Add(StartPoint.localPosition); splinewidths.Add(Safeway_Threshold); for (int i = 0; i < MiddlePoints.Length; i++) { splinepoints.Add(MiddlePoints[i].localPosition); splinewidths.Add(Safeway_Threshold / i + 1); } splinepoints.Add(EndPoint.localPosition); splinewidths.Add(0.0F); VectorLine.Destroy(ref Safeway); int mvmt_segments = 10 + MiddlePoints.Length * 10; Safeway = new VectorLine("Safeway Path", new List <Vector3>(mvmt_segments + 1), Safeway_Threshold_actual * 1.2F, LineType.Continuous); Safeway.MakeSpline(splinepoints.ToArray(), mvmt_segments, 0, false); Safeway.drawTransform = MOB[0].transform; Safeway.SetColor(PathColor); Safeway.joins = Joins.Fill; int objnum = 20 + MiddlePoints.Length * 5; PathInstances = new FOBJ[objnum]; float point = 0.0F; float objratio = 0.9F / objnum; for (int i = 0; i < objnum; i++) { PathInstances[i] = (FOBJ)Instantiate(PathPrefabs[Random.Range(0, PathPrefabs.Length)]); MOB[0].AddChild(PathInstances[i]); point += Random.Range(objratio / 1.5F, objratio * 1.5F); Vector3 pos = Safeway.GetPoint3D01(point); Vector3 nextpos = Safeway.GetPoint3D01(point + 0.1F); Vector3 vel = (nextpos - pos).normalized; Vector3 cross = Vector3.Cross(vel, -Vector3.forward).normalized; float xd = cross.x * Safeway_Threshold_actual / 10; pos.x += Random.value > 0.5F ? xd : -xd; PathInstances[i].T.position = pos; PathInstances[i].T.LookAt(pos + vel); PathInstances[i].T.rotation *= Quaternion.Euler(0, 90, 90); } Safeway.Draw3D(); VectorLine.SetCamera3D(Camera.main); VectorManager.useDraw3D = true; yield return(null); }
private void plotDeformedCoords(string str) { VectorLine.SetCamera3D(myCamera); string[] strArr = str.Split('|'); string[] coords = strArr[0].Split(';'); string[] meshCoords = strArr[1].Split(';'); string[] indices = strArr[2].Split(' '); string[] meshIndexStrings = strArr[3].Split(';'); List <Vector3> vectorList = new List <Vector3>(); int numPoints = coords.Length - 1; int numMesh = meshCoords.Length - 1; print("Number of Points received: " + numPoints); print("Number of Mesh Points received: " + numMesh); for (int i = 0; i < numPoints; i++) //stop one before because the last one is empty { Vector3 newCoords = getLocalCoords(coords[i]); //Vector3 worldPosNewCoords = domain.transform.TransformPoint(newCoords); vectorList.Add(newCoords); GameObject newObj = GameObject.Instantiate(allTransformList[i].gameObject, domain.transform); List <GameObject> children = new List <GameObject>(); foreach (Transform child in newObj.transform) { children.Add(child.gameObject); } children.ForEach(child => Destroy(child)); newObj.transform.localScale = allTransformList[i].localScale; Color color = ((Renderer)newObj.GetComponent <Renderer>()).material.color; color.a = 1F; ((Renderer)newObj.GetComponent <Renderer>()).material.color = color; newObj.transform.localPosition = newCoords; deformedTransformList.Add(newObj.transform); } //add the mesh coordinates too for (int i = 0; i < numMesh; i++) { //Vector3 worldPosNewCoords = domain.transform.TransformPoint(getLocalCoords(meshCoords[i])); vectorList.Add(getLocalCoords(meshCoords[i])); } //--------------------------------------TODO---------------------------------------------- //Modify lineTransformList //Need to construct a new spline between each node //instead of updating every intermediate mesh coord, maybe just make these spline gameObjects children of the main gameObject // See if there is too much deviation when scaling / rotating to use this hack //for(int i = 0; i < indices.Length - 1; i++) //{ // domain.GetComponent<InitLines>().deformedLineTransformList.Insert(i, deformedTransformList[int.Parse(indices[i]) - 1]); // domain.GetComponent<InitLines>().deformedLine.points3.Add(deformedTransformList[int.Parse(indices[i]) - 1].position); //} for (int i = 0; i < meshIndexStrings.Length - 1; i++) { VectorLine line = null; GameObject vectorLineObj = null; List <Vector3> splinePointList = null; string[] currMeshIndices = meshIndexStrings[i].Split(' '); splinePointList = new List <Vector3>(); for (int j = 0; j < currMeshIndices.Length; j++) { int index = int.Parse(currMeshIndices[j]) - 1; splinePointList.Add(vectorList[index]); } line = new VectorLine("Spline", splinePointList, 10.0f, LineType.Continuous, Joins.Fill); line.Draw3DAuto(); line.SetColor(Color.red); vectorLineObj = GameObject.Find("Spline"); vectorLineObj.name = "Complete Spline"; domain.GetComponent <InitLines>().addDeformedLine(line, splinePointList); } }
protected void onExitMapView() { Utils.Log("[SystemHeatOverlay]: Entered map view, clearing panels", LogType.Overlay); VectorLine.SetCamera3D(FlightCamera.fetch.mainCamera); }
// Start is called before the first frame update void Start() { VectorLine.SetCamera3D(CameraMain); VectorLine.SetEndCap("arrow", EndCap.Both, 0, -3, -3, 3, lineTex, frontTex, frontTex); var points = new List <Vector3>(); // Lines down X axis for (int i = -numberOfLines; i <= numberOfLines; i++) { if (i != 0) { points.Add(new Vector3(i * distanceBetweenLines, -((numberOfLines) * distanceBetweenLines), 0)); points.Add(new Vector3(i * distanceBetweenLines, (numberOfLines) * distanceBetweenLines, 0)); } } // Lines down Z axis for (int i = -numberOfLines; i <= numberOfLines; i++) { if (i != 0) { points.Add(new Vector3(-((numberOfLines) * distanceBetweenLines), i * distanceBetweenLines, 0)); points.Add(new Vector3((numberOfLines) * distanceBetweenLines, i * distanceBetweenLines, 0)); } } var line = new VectorLine("Grid", points, lineWidth * distanceBetweenLines); line.SetColor(Color.white); line.Draw3D(); splinePoints = new List <Vector3>(); //spline = new VectorLine("Grid", new List<Vector3>(7000), 4); for (float i = -20; i <= 20; i += 0.05f) { //Debug.Log(index); // spline.points3[index] = new Vector3(i, i * i, 0); //index++; if ((i * i) <= numberOfLines && (i * i) >= -numberOfLines) { splinePoints.Add(new Vector3(i * distanceBetweenLines, i * i * distanceBetweenLines, 0)); } } Debug.Log(splinePoints.Count); //spline = new VectorLine("Spline", new List<Vector3>(segments + 1), 6.0f, LineType.Continuous); var XOY_points = new List <Vector3>(); // XOY_points.Add(new Vector3(0, (numberOfLines * distanceBetweenLines), 0)); // XOY_points.Add(new Vector3(0, -(numberOfLines * distanceBetweenLines), 0)); var XO_line = new VectorLine("XO", new List <Vector3>(), 6 * lineWidth * distanceBetweenLines); XO_line.points3.Add(new Vector3(-(numberOfLines * distanceBetweenLines), 0, 0)); XO_line.points3.Add(new Vector3((numberOfLines * distanceBetweenLines), 0, 0)); XO_line.endCap = "arrow"; XO_line.SetColor(Color.black); XO_line.Draw3D(); var YO_line = new VectorLine("YO", new List <Vector3>(), 6 * lineWidth * distanceBetweenLines); YO_line.points3.Add(new Vector3(0, (numberOfLines * distanceBetweenLines), 0)); YO_line.points3.Add(new Vector3(0, -(numberOfLines * distanceBetweenLines), 0)); YO_line.endCap = "arrow"; YO_line.SetColor(Color.black); YO_line.Draw3D(); spline = new VectorLine("Spline", splinePoints, 10 * lineWidth * distanceBetweenLines, LineType.Continuous); //spline.texture = lineTex; // spline.continuousTexture = true; spline.joins = Joins.Fill; spline.SetColor(Color.red); spline.endCap = "arrow"; //spline.MakeSpline(splinePoints.ToArray()); Debug.Log(spline.points3.Count); spline.Draw3D(); var grid = GameObject.Find("Grid"); var graph = GameObject.Find("Spline"); var xo = GameObject.Find("XO"); var yo = GameObject.Find("YO"); var controller = GameObject.Find("Controller"); grid.transform.parent = controller.transform; graph.transform.parent = controller.transform; graph.transform.localPosition = new Vector3(0, 0, -0.1f); xo.transform.parent = controller.transform; yo.transform.parent = controller.transform; xo.transform.localPosition = new Vector3(0, 0, -0.1f); yo.transform.localPosition = new Vector3(0, 0, -0.1f); grid.transform.localPosition = new Vector3(0, 0, 0); }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { lineWidth = 2f; VectorLine.SetCamera3D(mainCam); }