void OnMouseDown() { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); if (pc.drawLine) { RaycastHit hit; Ray ray = GameObject.Find("Flycam").camera.ScreenPointToRay(Input.mousePosition); if (collider.Raycast(ray, out hit, Mathf.Infinity)) { if (!point1active) { point1 = hit.point; point1active = true; } else if (!point2active) { point2 = hit.point; VectorLine.SetCamera(GameObject.Find("Flycam").camera); myLine = VectorLine.SetLine3D(Color.red, new Vector3[] { point1, point2 }); myLine.lineWidth = 3.0f; point2active = true; lineCrossed = 0; pc.lineDrawn(); } else { removeLine(); } } } }
// Update is called once per frame void Update() { if (point1active && !point2active) { RaycastHit hit; Ray ray = GameObject.Find("Flycam").GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { VectorLine.Destroy(ref myLine_tmp); VectorLine.SetCamera(GameObject.Find("Flycam").GetComponent <Camera>()); myLine_tmp = VectorLine.SetLine3D(Color.red, new Vector3[] { point1, hit.point }); myLine_tmp.lineWidth = 3.0f; } } else { VectorLine.Destroy(ref myLine_tmp); if (point1active && point2active) { PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl>(); for (int i = 0; i < crossings.Count; i++) { if (crossings[i] < pc.current_time - 1) { crossings.RemoveAt(i); } } } } }
// Use this for initialization void Start() { linePoints1 = new Vector2[2]; // JS & C# //linePoints1 = new Vector2[2]; // JS & C# linePoints2 = new Vector2[2]; // JS & C# linePoints3 = new Vector2[2]; // JS & C# linePoints4 = new Vector2[2]; // JS & C# linePoints5 = new Vector2[2]; // JS & C# linePoints6 = new Vector2[2]; // JS & C# linePoints7 = new Vector2[2]; // JS & C# linePoints1[0] = new Vector2(pointPair1a.position.x, pointPair1a.position.y); linePoints1[1] = new Vector2(pointPair1b.position.x, pointPair1b.position.y); linePoints2[0] = new Vector2(pointPair2a.position.x, pointPair2a.position.y); linePoints2[1] = new Vector2(pointPair2b.position.x, pointPair2b.position.y); linePoints3[0] = new Vector2(pointPair3a.position.x, pointPair3a.position.y); linePoints3[1] = new Vector2(pointPair3b.position.x, pointPair3b.position.y); linePoints4[0] = new Vector2(pointPair4a.position.x, pointPair4a.position.y); linePoints4[1] = new Vector2(pointPair4b.position.x, pointPair4b.position.y); linePoints5[0] = new Vector2(pointPair5a.position.x, pointPair5a.position.y); linePoints5[1] = new Vector2(pointPair5b.position.x, pointPair5b.position.y); linePoints6[0] = new Vector2(pointPair6a.position.x, pointPair6a.position.y); linePoints6[1] = new Vector2(pointPair6b.position.x, pointPair6b.position.y); linePoints7[0] = new Vector2(pointPair7a.position.x, pointPair7a.position.y); linePoints7[1] = new Vector2(pointPair7b.position.x, pointPair7b.position.y); myLine1 = new VectorLine("BirdLine1", linePoints1, lineMaterial, .03f); // C# myLine2 = new VectorLine("BirdLine2", linePoints2, lineMaterial, .03f); // C# myLine3 = new VectorLine("BirdLine3", linePoints3, lineMaterial, .03f); // C# myLine4 = new VectorLine("BirdLine4", linePoints4, lineMaterial, .03f); // C# myLine5 = new VectorLine("BirdLine5", linePoints5, lineMaterial, .03f); // C# myLine6 = new VectorLine("BirdLine6", linePoints6, lineMaterial, .03f); // C# myLine7 = new VectorLine("BirdLine7", linePoints7, lineMaterial, .03f); // C# myCam = VectorLine.SetCamera(); myCam.isOrthoGraphic = true; myCam.transform.position = new Vector3(0f, 2.2f, -2.66f); myCam.nearClipPlane = 0.3f; myCam.farClipPlane = 1000.0f; myCam.orthographicSize = 2.61f; // this is needed to move a //myLine.drawTransform = pointPair1a; //myLine.drawTransform = pointPair1b; //myLine3.drawTransform = pointPair2a; //myLine4.drawTransform = pointPair2b; //myLine5.drawTransform = pointPair3a; //myLine6.drawTransform = pointPair3b; //myLine7.drawTransform = pointPair4a; myLine1.Draw(); myLine2.Draw(); myLine3.Draw(); myLine4.Draw(); myLine5.Draw(); myLine6.Draw(); myLine7.Draw(); }
// Use this for initialization void Start() { totalSegments = data.totalSegments; spline_ = new VectorLine("Spline", new Vector3[totalSegments + 1], lineMaterial, thickness, LineType.Continuous); spline_.drawTransform = gameObject.transform; VectorLine.SetCamera(renderCamera); //spline_.Draw3DAuto(); }
// Use this for initialization void Start() { totalSegments = data.totalSegments; spline_ = new VectorLine("Spline", new Vector3[totalSegments], lineMaterial, thickness, LineType.Continuous); //spline_.drawTransform = gameObject.transform; VectorLine.SetCamera(renderCamera); SetLinePoints(); //upperRight.SetActive (false); }
/// <summary> /// Use this for initialization /// </summary> void Start() { // We retrieve the ImageTargetBehaviour component // Note: This only works if this script is attached to an ImageTarget mImageTargetBehaviour = GetComponent <ImageTargetBehaviour>(); /// Run GetTargetCoords each 0.1sec InvokeRepeating("GetTargetCoords", 1f, 0.1F); VectorLine.SetCamera(); }
/// <summary> /// DisplayPoints - Display all blob points /// </summary> public void DisplayPoints() { VectorLine.SetCamera(); // If we already have a blobpoint object with an array of points, simply update the points. Otherwise, create the blobpoint object if (blobPoints != null) { blobPoints.points2 = blobPointsPos.ToArray(); } else { blobPoints = new VectorPoints("BlobExtremityPoints", blobPointsPos.ToArray(), Color.green, null, 5f); } //draw the points blobPoints.Draw(); }
public void showTrajectory() { VectorLine.SetCamera(GameObject.Find("Flycam").camera); List <Vector3> points = new List <Vector3>(); for (int i = 0; i < positions.Count - 1; i++) { PedestrianPosition a = (PedestrianPosition)positions.GetByIndex(i); points.Add(new Vector3(a.getX(), 0.01f, a.getY())); } trajectory = VectorLine.SetLine3D(myColor, points.ToArray()); trajectory.lineWidth = 3.0f; pc.trajectoriesShown = true; trajectoryVisible = true; }
/// <summary> /// DisplayContour - Display the contour points, adjust camera position, invert points for correct display. /// </summary> /// <param name="contour"></param> /// <param name="blobNumber"></param> public void DisplayContour(PXCMPointI32[] contour, int blobNumber) { /* Funky Vectrosity camera flip issue*/ VectorLine.SetCamera(this.GetComponent <Camera>()); Camera cam = VectorLine.GetCamera(); cam.transform.position = new Vector3(cam.transform.position.x * -1, cam.transform.position.y * -1, cam.transform.position.z); if (blobLine != null) { VectorLine.Destroy(ref blobLine); } /* can't be cache since the contour length changes based on whats tracked*/ Vector2[] splinePoints = new Vector2[contour.Length]; for (int i = 0; i < contour.Length; i++) { splinePoints[i] = new Vector2(contour[i].x * -1, contour[i].y * -1); } blobLine = new VectorLine("BlobContourPoints", new Vector2[contour.Length + 1], null, 2.0f, LineType.Continuous); blobLine.MakeSpline(splinePoints); blobLine.Draw(); }