void Start() { textLine = new VectorLine("Text", new List <Vector2>(), 1.0f); textLine.color = Color.yellow; textLine.drawTransform = transform; textLine.MakeText(text, new Vector2(Screen.width / 2 - text.Length * textSize / 2, Screen.height / 2 + textSize / 2), textSize); }
void Start() { Random.seed = 42; hero = GameObject.Find("pre_bat"); VectorLine vl = new VectorLine("help", new Vector3[60], lineMat, lineWidth, LineType.Discrete, Joins.Weld); //CreateLine (new Vector3 (0.0f, 0.0f, 0.0f), new Vector3 (400.0f, 400.0f, 0.0f)); vl.MakeText("123456", new Vector3(10.0f, 310.0f, 0.0f), 15.0f); vl.endCap = "Cap"; //vl.joins = Joins.Weld; vl.Draw(); // }
// Use this for initialization void Start() { index = mainCounter; mainCounter++; // VectorLine.SetEndCap("Arrow", EndCap.Front, axisEndCapTexture, axisEndCapTexture); List <Vector3> ptsXY = new List <Vector3>(); List <Vector3> ptsXZ = new List <Vector3>(); List <Vector3> ptsYZ = new List <Vector3>(); //GRID XY if (displayGridXY) { for (int i = 1; i <= gridNSteps; i++) { ptsXY.Add(new Vector3(0, i * gridDelta, 0)); ptsXY.Add(new Vector3((gridNSteps + 1) * gridDelta, i * gridDelta, 0)); ptsXY.Add(new Vector3(i * gridDelta, 0, 0)); ptsXY.Add(new Vector3(i * gridDelta, (gridNSteps + 1) * gridDelta, 0)); } gridXY = new VectorLine("gridXY", ptsXY, gridThickness); gridXY.color = new Color(1, 1, 1, gridXYAlpha); } if (displayGridXZ) { //GRID XZ for (int i = 1; i <= gridNSteps; i++) { ptsXZ.Add(new Vector3(i * gridDelta, 0, 0)); ptsXZ.Add(new Vector3(i * gridDelta, 0, (gridNSteps + 1) * gridDelta)); ptsXZ.Add(new Vector3(0, 0, i * gridDelta)); ptsXZ.Add(new Vector3((gridNSteps + 1) * gridDelta, 0, i * gridDelta)); } gridXZ = new VectorLine("gridXZ", ptsXZ, gridThickness); gridXZ.color = new Color(1, 1, 1, gridXZAlpha); } if (displayGridYZ) { //GRID YZ for (int i = 1; i <= gridNSteps; i++) { ptsYZ.Add(new Vector3(0, i * gridDelta, 0)); ptsYZ.Add(new Vector3(0, i * gridDelta, (gridNSteps + 1) * gridDelta)); ptsYZ.Add(new Vector3(0, 0, i * gridDelta)); ptsYZ.Add(new Vector3(0, (gridNSteps + 1) * gridDelta, i * gridDelta)); } gridYZ = new VectorLine("gridYZ", ptsYZ, gridThickness); gridYZ.color = new Color(1, 1, 1, gridYZAlpha); } axisX = new VectorLine("axisX", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(axisLength, 0, 0) }, axisThickness); axisX.color = axisXColor; // axisX.endCap = "Arrow"; axisY = new VectorLine("axisY", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(0, axisLength, 0) }, axisThickness); axisY.color = axisYColor; axisZ = new VectorLine("axisZ", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(0, 0, axisLength) }, axisThickness); axisZ.color = axisZColor; if (displayNegativeAxis) { axisNegX = new VectorLine("axisNegX", Tools3D.CreateDashedLine(Vector3.zero, new Vector3(-axisLength, 0, 0), .5f, .5f), axisThickness); axisNegX.color = new Color(axisXColor.r, axisXColor.g, axisXColor.b, axisXColor.a * .5f); axisNegY = new VectorLine("axisNegY", Tools3D.CreateDashedLine(Vector3.zero, new Vector3(0, -axisLength, 0), .5f, .5f), axisThickness); axisNegY.color = new Color(axisYColor.r, axisYColor.g, axisYColor.b, axisYColor.a * .5f); axisNegZ = new VectorLine("axisNegZ", Tools3D.CreateDashedLine(Vector3.zero, new Vector3(0, 0, -axisLength), .5f, .5f), axisThickness); axisNegZ.color = new Color(axisZColor.r, axisZColor.g, axisZColor.b, axisZColor.a * .5f); } if (displayXYZ) { letterX = new VectorLine("letterX", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(axisLength, 0, 0) }, 1f); letterX.MakeText("X", new Vector3(axisLength + .5f, .5f, 0), 1); letterX.color = Color.red; letterY = new VectorLine("letterY", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(axisLength, 0, 0) }, 1f); letterY.MakeText("Y", new Vector3(-.25f, axisLength + 1.5f, 0), 1); letterY.color = Color.green; letterZ = new VectorLine("letterZ", new List <Vector3>() { new Vector3(0, 0, 0), new Vector3(axisLength, 0, 0) }, 1f); letterZ.MakeText("Z", new Vector3(0, .5f, axisLength + .5f), 1); letterZ.color = Color.blue; } if (displaySphericalEnds) { sphericalEnds = new List <Transform>(); //on s'occupe de l'axe Ox sphericalEnds.Add(CreateSphere(Color.red, Vector3.right * axisLength, .5f).transform); if (traceXEndPos) { GameObject tracerGO = Instantiate(tracersPrefabs[0]) as GameObject; tracerGO.transform.parent = sphericalEnds[sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } //on s'occupe de l'axe Oy sphericalEnds.Add(CreateSphere(Color.green, Vector3.up * axisLength, .5f).transform); if (traceYEndPos) { GameObject tracerGO = Instantiate(tracersPrefabs[1]) as GameObject; tracerGO.transform.parent = sphericalEnds[sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } //on s'occupe de l'axe Oz sphericalEnds.Add(CreateSphere(Color.blue, Vector3.forward * axisLength, .5f).transform); if (traceZEndPos) { GameObject tracerGO = Instantiate(tracersPrefabs[2]) as GameObject; tracerGO.transform.parent = sphericalEnds[sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } } }
// Use this for initialization void Start () { index = mainCounter; mainCounter++; List<Vector3> ptsXY = new List<Vector3> (); List<Vector3> ptsXZ = new List<Vector3> (); List<Vector3> ptsYZ = new List<Vector3> (); //GRID XY if (displayGridXY) { for (int i = 1; i < gridNSteps; i++) { ptsXY.Add (new Vector3 (0, i * gridDelta, 0)); ptsXY.Add (new Vector3 ((gridNSteps + 1) * gridDelta, i * gridDelta, 0)); ptsXY.Add (new Vector3 (i * gridDelta, 0, 0)); ptsXY.Add (new Vector3 (i * gridDelta, (gridNSteps + 1) * gridDelta, 0)); } gridXY = new VectorLine ("gridXY", ptsXY, textureGridXY, gridThickness); } if (displayGridXZ) { //GRID XZ for (int i = 1; i < gridNSteps; i++) { ptsXZ.Add (new Vector3 (i * gridDelta, 0, 0)); ptsXZ.Add (new Vector3 (i * gridDelta, 0, (gridNSteps + 1) * gridDelta)); ptsXZ.Add (new Vector3 (0, 0, i * gridDelta)); ptsXZ.Add (new Vector3 ((gridNSteps + 1) * gridDelta, 0, i * gridDelta)); } gridXZ = new VectorLine ("gridXZ", ptsXZ, textureGridXZ, gridThickness); } if (displayGridYZ) { //GRID YZ for (int i = 1; i < gridNSteps; i++) { ptsYZ.Add (new Vector3 (0, i * gridDelta, 0)); ptsYZ.Add (new Vector3 (0, i * gridDelta, (gridNSteps + 1) * gridDelta)); ptsYZ.Add (new Vector3 (0, 0, i * gridDelta)); ptsYZ.Add (new Vector3 (0, (gridNSteps + 1) * gridDelta, i * gridDelta)); } gridYZ = new VectorLine ("gridYZ", ptsYZ, textureGridYZ, gridThickness); } axisX = new VectorLine ("axisX", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (axisLength, 0, 0) }, textureAxisX, axisThickness); axisY = new VectorLine ("axisY", new List<Vector3> (){ new Vector3 (0, 0, 0), new Vector3 (0, axisLength, 0) }, textureAxisY, axisThickness); axisZ = new VectorLine ("axisZ", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (0, 0, axisLength) }, textureAxisZ, axisThickness); if (displayNegativeAxis) { axisNegX = new VectorLine ("axisNegX", new List<Vector3> (){ new Vector3 (0, 0, 0), new Vector3 (-axisLength, 0, 0) }, textureAxisNegX, axisThickness); axisNegY = new VectorLine ("axisNegY", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (0, -axisLength, 0) }, textureAxisNegY, axisThickness); axisNegZ = new VectorLine ("axisNegZ", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (0, 0, -axisLength) }, textureAxisNegZ, axisThickness); } if (displayXYZ) { letterX = new VectorLine ("letterX", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (axisLength, 0, 0) }, textureAxisX, 1f); letterX.MakeText ("X", new Vector3 (axisLength + .5f, .5f, 0), 1); letterY = new VectorLine ("letterY", new List<Vector3> () { new Vector3 (0, 0, 0), new Vector3 (axisLength, 0, 0) }, textureAxisY, 1f); letterY.MakeText ("Y", new Vector3 (-.25f, axisLength + 1.5f, 0), 1); letterZ = new VectorLine ("letterZ", new List<Vector3> (){ new Vector3 (0, 0, 0), new Vector3 (axisLength, 0, 0) }, textureAxisZ, 1f); letterZ.MakeText ("Z", new Vector3 (0, .5f, axisLength + .5f), 1); } if (displaySphericalEnds) { sphericalEnds = new List<Transform> (); //on s'occupe de l'axe Ox sphericalEnds.Add (CreateSphere (Color.red, Vector3.right * axisLength, .5f).transform); if (traceXEndPos) { GameObject tracerGO = Instantiate (tracers [0]) as GameObject; tracerGO.transform.parent = sphericalEnds [sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } //on s'occupe de l'axe Oy sphericalEnds.Add (CreateSphere (Color.green, Vector3.up * axisLength, .5f).transform); if (traceYEndPos) { GameObject tracerGO = Instantiate (tracers [1]) as GameObject; tracerGO.transform.parent = sphericalEnds [sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } //on s'occupe de l'axe Oz sphericalEnds.Add (CreateSphere (Color.blue, Vector3.forward * axisLength, .5f).transform); if (traceZEndPos) { GameObject tracerGO = Instantiate (tracers [2]) as GameObject; tracerGO.transform.parent = sphericalEnds [sphericalEnds.Count - 1]; tracerGO.transform.localPosition = Vector3.zero; } } }
void OnGUI() { // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed if (!showDrawingTools) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Start Drawing")) { showDrawingTools = true; } } else if (!drawingDone) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Done")) { drawingDone = true; } } else if (!showVectorDrawing) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 100, 150, 50), "Draw V-T Graph")) { showVectorDrawing = true; } if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Back To The Schene")) { //Buraya Kamera değiştirme scripti gelcek. VectorLine.Destroy (ref allGuide); VectorLine.Destroy (ref atGraphAfterVt); VectorLine.Destroy (ref gecici); VectorLine.Destroy (ref guideY); VectorLine.Destroy (ref line); VectorLine.Destroy (ref rectV); VectorLine.Destroy (ref refPointsOnX); VectorLine.Destroy (ref refPointsOnY); VectorLine.Destroy (ref textVec); VectorLine.Destroy (ref vtGraph); VectorPoints.Destroy (ref dots); for (int i =0; i<linePointsYNmb.Length;i++) { VectorLine.Destroy (ref linePointsYNmb[i]); } for (int i =0; i<textVectors.Length;i++){ VectorLine.Destroy (ref textVectors[i]); } finish = true; walkOrDraw.btnClicked=false; } } else { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 100, 150, 50), "Reset")) { showDrawingTools=false; showVectorDrawing=false; drawingDone=false; VectorLine.Destroy(ref dots); VectorLine.Destroy(ref line); VectorLine.Destroy(ref vtGraph); VectorLine.Destroy(ref atGraphAfterVt); VectorLine.Destroy(ref refPointsOnX); VectorLine.Destroy(ref refPointsOnY); for (int i=0; i<50; i++) { VectorLine.Destroy(ref textVectors[i]); textVectors[i]=new VectorLine("Text"+i,new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); } for (int i=0; i<100; i++) { linePoints[i]=Vector2.zero; } for(int i=0;i<100;i++){ atGraphAfterVtPoints[i]=Vector2.zero; } for (int i=0; i<49; i++) { canerinArray[i]=Vector2.zero; } for (int i=0; i<49; i++) { VelocityArray[i]=Vector2.zero; } for(int i=0;i<50;i++){ dotPoints[i]=Vector2.zero; } numberOfDots = 0; dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots; linePointsX=new Vector2[(maxW/snToPixel)*4]; for (int i =0; i<=maxW/snToPixel*2; i+=2) { linePointsX[i].x=minW+i*snToPixel/2; linePointsX[i].y=(Screen.height/2)-5; linePointsX[i+1].x=minW+i*snToPixel/2; linePointsX[i+1].y=(Screen.height/2)+5; } //snToPixel en az 5 olabilir ise. linePointsY=new Vector2[(maxH/5)*4]; for (int i =0; i<=maxH / snToPixel * 2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixel/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixel/2; } //Numara yazımı for (int i =0; i<(maxH/5)*2; i+=2) { VectorLine.Destroy(ref linePointsYNmb[i/2]); } for (int i =0; i<=maxH / snToPixel*2+2; i+=2) { linePointsYNmb[i/2]=new VectorLine("Numb"+i/2,new Vector2[2]{new Vector2(minW-15,minH+i*snToPixel/2),new Vector2(minW,minH+i*snToPixel/2)},null,2f,LineType.Discrete,Joins.Weld); if(i/2*snToPixel>maxH/2) linePointsYNmb[i/2].MakeText(""+(i/2*snToPixel-maxH/2)/snToPixel,new Vector2(minW-15,minH+i*snToPixel/2),10f); else linePointsYNmb[i/2].MakeText(""+(maxH/2-(i/2-1)*snToPixel)/snToPixel*-1 ,new Vector2(minW-25,minH+i*snToPixel/2),10f); linePointsYNmb[i/2].Draw(); } VectorLine.Destroy (ref textVec); textVec=new VectorLine("Text"+(index),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); if(refY>Screen.height/2) textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(mousePos.y-minH-maxH/2)/snToPixel+")",new Vector2(mousePos.x,mousePos.y+25),10f); else textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(maxH/2-(mousePos.y-minH))/snToPixel*-1+")",new Vector2(mousePos.x,mousePos.y+25),10f); refY = minH; refX = minW; time = minW; index = 0; oldWidth = Screen.width; SetLine(); finish = false; CizimBasladi = false; CizimBitti = false; instantiated = false; inside = false; gecici = new VectorLine("gecici", new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH)}, Color.white, null, 2f, LineType.Discrete); gecici.Draw(); guideY = new VectorLine ("guideY",new Vector2[2]{new Vector2(time,minH),new Vector2(time,maxH+minH)},Color.red,null,2f,LineType.Discrete); guideY.Draw (); allGuide=new VectorLine("Guide",new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,maxH+minH),new Vector2(minW,Screen.height/2),new Vector2(maxW+minW,Screen.height/2)},null,3f,LineType.Discrete); allGuide.Draw (); /* plane.transform.localScale = new Vector3 ((float)(1.35f*maxW)/(float)(Screen.width),0.1f,(float)(Screen.height-minH*2)/(float)Screen.height); plane.transform.position = new Vector3(plane.transform.position.x,plane.transform.position.y,Camera.main.transform.position.z+1); */ box.x = -Screen.width/2+minW; box.y= -Screen.height/2+minH; box.width = maxW; box.height = maxH; bg.pixelInset = box; rectV = new VectorLine ("Rectangle",new Vector2[8],Color.black,null,4f); rectV.capLength = 2; rectV.MakeRect (new Rect (minW, Screen.height - minH, maxW, maxH)); rectV.Draw(); } if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Back To The Schene")) { //Buraya Kamera değiştirme scripti gelcek. VectorLine.Destroy (ref allGuide); VectorLine.Destroy (ref atGraphAfterVt); VectorLine.Destroy (ref gecici); VectorLine.Destroy (ref guideY); VectorLine.Destroy (ref line); VectorLine.Destroy (ref rectV); VectorLine.Destroy (ref refPointsOnX); VectorLine.Destroy (ref refPointsOnY); VectorLine.Destroy (ref textVec); VectorLine.Destroy (ref vtGraph); VectorPoints.Destroy (ref dots); for (int i =0; i<linePointsYNmb.Length;i++) { VectorLine.Destroy (ref linePointsYNmb[i]); } for (int i =0; i<textVectors.Length;i++){ VectorLine.Destroy (ref textVectors[i]); } finish = true; walkOrDraw.btnClicked=false; } } }
// Update is called once per frame void Update() { if (showDrawingTools) { mousePos = transform.InverseTransformPoint (Input.mousePosition); if (mousePos.y < Screen.height - minH && mousePos.y > minH && mousePos.x > minW && mousePos.x < Screen.width - minW) inside = true; else inside = false; if (CizimBasladi == true && refX < mousePos.x && inside == true) { if (!(Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift)))//false ise refY = mousePos.y;//sonrada ivmeyi değiştirebilmek için if ((Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))) { gecici.points2 = new Vector2[4] { new Vector2 (refX, refYx), new Vector2 (refX, refY), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; } else if (index > 0)//ilk line çizildimi? ilk line da y'de çizgi yok. gecici.points2 = new Vector2[4] { new Vector2 (refX, refYx), new Vector2 (refX, mousePos.y), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; else gecici.points2 = new Vector2[4] { new Vector2 (mousePos.x, mousePos.y), new Vector2 (mousePos.x, mousePos.y), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; gecici.Draw (); VectorLine.Destroy (ref textVec); textVec = new VectorLine ("Text" + (index), new Vector2[2]{new Vector2 (refX, refY - 5),new Vector2 (refX + 15, refY + 15)}, Color.black, null, 2f, LineType.Discrete, Joins.Weld); if (refY > Screen.height / 2) textVec.MakeText ("(t=" + (mousePos.x - minW) / snToPixel + ",a=" + (refY - minH - maxH / 2) / snToPixel + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); else textVec.MakeText ("(t=" + (mousePos.x - minW) / snToPixel + ",a=" + (maxH / 2 - (refY - minH)) / snToPixel * -1 + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); textVec.Draw (); guideY.points2 = new Vector2[2]{new Vector2 (mousePos.x, minH),new Vector2 (mousePos.x, maxH + minH)}; guideY.Draw (); CizimBitti = true; } if (Input.GetMouseButtonDown (0) && finish == false && inside == true) { instantiated = true; CizimBasladi = true; refY = mousePos.y; } if (Input.GetMouseButtonUp (0) && finish == false && inside == true) { dotPoints [numberOfDots] = new Vector2 (refX, refY);//önce ilk değeri index olarak kullanıp sonra arttırır (ex ++i) dots.maxDrawIndex = numberOfDots; numberOfDots++; dots.drawTransform = transform; dots.Draw (); /* textVectors[numberOfDots-1]= new VectorLine("Text"+(numberOfDots-1),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); textVectors[numberOfDots-1].MakeText("("+refX/snToPixel+","+refY/snToPixel+")",new Vector2(refX,refY+25),10f); textVectors[numberOfDots-1].Draw(); */ /*point yazdırma textVector=new VectorLine("Text",new Vector2(refX,refY),null,5f); textVector.MakeText ("sdfgdfad",new Vector2(refX,refY),30f); */ refYx = mousePos.y; gecici.points2 = new Vector2[4] { new Vector2 (minW, minH), new Vector2 (minW, minH), new Vector2 (minW, minH), new Vector2 (minW, minH) }; gecici.Draw (); linePoints [2 * index] = new Vector2 (refX, refY); if (refX < mousePos.x) { refX = mousePos.x; } else { refX += snToPixel; } linePoints [2 * index + 1] = new Vector2 (refX, refY); line.maxDrawIndex = 2 * index + 1; index++; guideY.points2 = new Vector2[2]{new Vector2 (refX, minH),new Vector2 (refX, maxH + minH)}; guideY.Draw (); dotPoints [numberOfDots] = new Vector2 (refX, refY);//önce ilk değeri index olarak kullanıp sonra arttırır (ex ++i) dots.maxDrawIndex = numberOfDots; numberOfDots++; dots.drawTransform = transform; dots.Draw (); VectorLine.Destroy (ref textVec); textVectors [numberOfDots] = new VectorLine ("Text" + (index), new Vector2[2] { new Vector2 (refX, refY - 5), new Vector2 (refX + 15, refY + 15) }, Color.black, null, 2f, LineType.Discrete, Joins.Weld); if (refY > Screen.height / 2) textVectors [numberOfDots].MakeText ("(t=" + (refX - minW) / snToPixel + ",a=" + (refY - minH - maxH / 2) / snToPixel + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); else textVectors [numberOfDots].MakeText ("(t=" + (refX - minW) / snToPixel + ",a=" + (maxH / 2 - (refY - minH)) / snToPixel * -1 + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); textVectors [numberOfDots].Draw (); /* if(linePoints[i*2+1].y>Screen.height/2) canerinArray[i].y=((linePoints[i*2+1].y)-minH-maxH/2)/snToPixel; else canerinArray[i].y=((maxH/2-(linePoints[i*2+1].y-minH))/snToPixel)*-1; canerinArray[i].x=(linePoints[i*2+1].x-minW)/snToPixel; */ /* textVectors[numberOfDots-1]= new VectorLine("Text"+(numberOfDots-1),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); textVectors[numberOfDots-1].MakeText("("+refX/snToPixel+","+refY/snToPixel+")",new Vector2(refX,refY+25),10f); textVectors[numberOfDots-1].Draw(); */ CizimBitti = true; CizimBasladi = false; } if (finish == false && CizimBitti == true && inside == true) { line.Draw (); CizimBitti = false; } if (oldWidth != Screen.width) { oldWidth = Screen.width; VectorLine.SetCamera (); } if (drawingDone) { VectorLine.Destroy (ref guideY); StartCoroutine ("SetArray"); } if (showVectorDrawing) { VelocityArray [0] = Vector2.zero;//initial velocity given int maxheight = 0; float snToPixelH = snToPixel; for (int i=0; i<=canerinIndex+1; i++) { VelocityArray [i + 1] = new Vector2 (canerinArray [i].x * snToPixel, VelocityArray [i].y + canerinArray [i].x * canerinArray [i].y * snToPixelH); if (Mathf.Abs (VelocityArray [maxheight].y) < Mathf.Abs (VelocityArray [i + 1].y)) maxheight = i + 1; } //Minimum 5 pixel olmak zorunda if (Mathf.Abs (VelocityArray [maxheight].y) > maxH / 2 && snToPixelH > 5) { snToPixelH = (maxH / 2) / Mathf.Abs (VelocityArray [maxheight].y / snToPixelH); } //hız değerleri. ilknokta farklı hesaplanıyor. VelocityArray [1] = new Vector2 (canerinArray [0].x * snToPixel, (VelocityArray [0].y + canerinArray [0].x * canerinArray [0].y * snToPixelH)); for (int i=1; i<=canerinIndex+1; i++) { VelocityArray [i + 1] = new Vector2 (canerinArray [i].x * snToPixel, (VelocityArray [i].y + (canerinArray [i].x - canerinArray [i - 1].x) * canerinArray [i].y * snToPixelH)); //debuging //print (canerinArray[i].x*snToPixel+"=time"+VelocityArray[i].y+"(ilk hız)+"+canerinArray[i].x+"(time)*"+canerinArray[i].y+"(hız)*"+snToPixelH+"snToPixelH"); } //0 noktasından çizlen grafiği taşır for (int i=0; i<=canerinIndex+1; i++) { VelocityArray [i] = new Vector2 (VelocityArray [i].x + minW, VelocityArray [i].y + maxH / 2 + minH); } VectorLine.Destroy(ref vtGraph); vtGraph = new VectorLine ("V-t Graph", VelocityArray, Color.yellow, null, 5f, LineType.Continuous); vtGraph.maxDrawIndex = canerinIndex + 1; vtGraph.Draw (); for (int i =0; i<=(maxH/snToPixelH)*2+2; i+=2) { linePointsY [i].x = minW - 5; linePointsY [i].y = minH + i * snToPixelH / 2; linePointsY [i + 1].x = minW + 5; linePointsY [i + 1].y = minH + i * snToPixelH / 2; } refPointsOnY.points2 = linePointsY; refPointsOnY.Draw (); //Numara yazımı for (int i =0; i<=maxH / snToPixelH*2+2; i+=2) { VectorLine.Destroy (ref linePointsYNmb [i / 2]); linePointsYNmb [i / 2] = new VectorLine ("Numb" + i / 2, new Vector2[2] { new Vector2 (minW - 15, minH + i * snToPixelH / 2), new Vector2 (minW, minH + i * snToPixelH / 2) }, Color.yellow, null, 2f, LineType.Discrete, Joins.Weld); if (Mathf.Round (((i / 2) * snToPixelH - maxH / 2) / snToPixelH) % 5 == 0) { if (i / 2 * snToPixel > maxH / 2) linePointsYNmb [i / 2].MakeText ("" + Mathf.Round ((i / 2 * snToPixelH - maxH / 2) / snToPixelH), new Vector2 (minW - 40, minH + i * snToPixelH / 2), 10f); else linePointsYNmb [i / 2].MakeText ("" + Mathf.Round ((maxH / 2 - (i / 2 - 1) * snToPixelH) / snToPixelH * -1), new Vector2 (minW - 50, minH + i * snToPixelH / 2), 10f); linePointsYNmb [i / 2].Draw (); } else VectorLine.Destroy (ref linePointsYNmb [i / 2]); } int newIndex = 0; for (int i=0; i<100; i++) { atGraphAfterVtPoints [i] = new Vector2 (linePoints [i].x, linePoints [i].y / snToPixel * snToPixelH + (Screen.height / 2 - (Screen.height / 2 / snToPixel * snToPixelH)) - snToPixelH); if (linePoints [i] != Vector2.zero) newIndex++; } VectorLine.Destroy(ref atGraphAfterVt); atGraphAfterVt = new VectorLine ("Line", atGraphAfterVtPoints, Color.white, null, 2f, LineType.Continuous, Joins.Weld); atGraphAfterVt.maxDrawIndex = newIndex - 1; atGraphAfterVt.drawTransform = transform; VectorLine.Destroy (ref line); atGraphAfterVt.Draw (); for (int i=0; i<numberOfDots; i++) { dotPoints [i] = new Vector2 (linePoints [i].x, linePoints [i].y / snToPixel * snToPixelH + (Screen.height / 2 - (Screen.height / 2 / snToPixel * snToPixelH)) - snToPixelH); } VectorLine.Destroy (ref dots); dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots - 1; dots.points2 = dotPoints; dots.Draw (); } } }
// Use this for initialization void Start() { refY = minH; refX = minW; time = minW; index = 0; oldWidth = Screen.width; finish = false; CizimBasladi = false; CizimBitti = false; instantiated = false; inside = false; textVectors=new VectorLine[50]; for (int i=0; i<50; i++) { textVectors[i]=new VectorLine("Text"+i,new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); } textVec=new VectorLine("GuideText",new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); maxH = Screen.height - 2 * minH; maxW = Screen.width - 2 * minW; linePoints= new Vector2[100]; for (int i=0; i<100; i++) { linePoints[i]=Vector2.zero; } atGraphAfterVtPoints = new Vector2[100]; for(int i=0;i<100;i++){ atGraphAfterVtPoints[i]=Vector2.zero; } canerinArray = new Vector2[49]; for (int i=0; i<49; i++) { canerinArray[i]=Vector2.zero; } VelocityArray=new Vector2[50]; for (int i=0; i<49; i++) { VelocityArray[i]=Vector2.zero; } dotPoints = new Vector2[50]; for(int i=0;i<50;i++){ dotPoints[i]=Vector2.zero; } numberOfDots = 0; dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots; linePointsX=new Vector2[(maxW/snToPixel)*4]; for (int i =0; i<=maxW/snToPixel*2; i+=2) { linePointsX[i].x=minW+i*snToPixel/2; linePointsX[i].y=(Screen.height/2)-5; linePointsX[i+1].x=minW+i*snToPixel/2; linePointsX[i+1].y=(Screen.height/2)+5; } //snToPixel en az 5 olabilir ise. linePointsY=new Vector2[(maxH/5)*4]; for (int i =0; i<=maxH / snToPixel * 2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixel/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixel/2; } //Numara yazımı linePointsYNmb=new VectorLine[(maxH/5)*2]; for (int i =0; i<=maxH / snToPixel*2+2; i+=2) { linePointsYNmb[i/2]=new VectorLine("Numb"+i/2,new Vector2[2]{new Vector2(minW-15,minH+i*snToPixel/2),new Vector2(minW,minH+i*snToPixel/2)},null,2f,LineType.Discrete,Joins.Weld); if(i/2*snToPixel>maxH/2) linePointsYNmb[i/2].MakeText(""+(i/2*snToPixel-maxH/2)/snToPixel,new Vector2(minW-15,minH+i*snToPixel/2),10f); else linePointsYNmb[i/2].MakeText(""+(maxH/2-(i/2-1)*snToPixel)/snToPixel*-1 ,new Vector2(minW-25,minH+i*snToPixel/2),10f); linePointsYNmb[i/2].Draw(); } VectorLine.Destroy (ref textVec); textVec=new VectorLine("Text"+(index),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); if(refY>Screen.height/2) textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(mousePos.y-minH-maxH/2)/snToPixel+")",new Vector2(mousePos.x,mousePos.y+25),10f); else textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(maxH/2-(mousePos.y-minH))/snToPixel*-1+")",new Vector2(mousePos.x,mousePos.y+25),10f); textVec.Draw(); gecici = new VectorLine("gecici", new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH)}, Color.white, null, 2f, LineType.Discrete); gecici.Draw(); guideY = new VectorLine ("guideY",new Vector2[2]{new Vector2(time,minH),new Vector2(time,maxH+minH)},Color.red,null,2f,LineType.Discrete); guideY.Draw (); allGuide=new VectorLine("Guide",new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,maxH+minH),new Vector2(minW,Screen.height/2),new Vector2(maxW+minW,Screen.height/2)},null,3f,LineType.Discrete); allGuide.Draw (); /* plane.transform.localScale = new Vector3 ((float)(1.35f*maxW)/(float)(Screen.width),0.1f,(float)(Screen.height-minH*2)/(float)Screen.height); plane.transform.position = new Vector3(plane.transform.position.x,plane.transform.position.y,Camera.main.transform.position.z+1); */ box.x = -Screen.width/2+minW; box.y= -Screen.height/2+minH; box.width = maxW; box.height = maxH; bg.pixelInset = box; rectV = new VectorLine ("Rectangle",new Vector2[8],Color.black,null,4f); rectV.capLength = 2; rectV.MakeRect (new Rect (minW, Screen.height - minH, maxW, maxH)); rectV.Draw(); SetLine(); }