Example #1
0
	IEnumerator DisableLine (VectorLine vectorLine, float time, bool remove) {
		yield return new WaitForSeconds(time);
		if (remove) {
			RemoveLine (vectorLine);
		}
		Vector.DestroyLine (ref vectorLine);
	}
Example #2
0
 protected override void Awake() {
     base.Awake();
     _line = new VectorLine(LineName, new Vector3[2], Color.ToUnityColor(), null, Width);
     //_line.vectorObject.transform.parent = _transform;
     UnityUtility.AttachChildToParent(_line.vectorObject, _transform.gameObject);
     _line.active = false;
 }
Example #3
0
    private void draw3D() {            
            reinit();
                   
            point1 = new GameObject();
            point1.name = "point1-global";
            point1.transform.position = generateRandomPoint();
            point2 = new GameObject();
            point2.name = "point2-global";
            point2.transform.position = generateRandomPoint();

            point3 = new GameObject();
            point3.name = "point3-local";
            point3.transform.localPosition = point1.transform.position; 

            point4 = new GameObject();
            point4.name = "point4-local";
            point4.transform.localPosition = point2.transform.position;

            //List<Vector2> fakeLinePoints = new List<Vector2>(){pos2D1, pos2D1};
            List<Vector3> linePoints = new List<Vector3>(){point1.transform.position, point2.transform.position};
            
            //this._fakeVectorline = new VectorLine("Graph_FakeVectorLine", fakeLinePoints, 1.0f, LineType.Continuous, Joins.Weld);
            this._vectorline = new VectorLine("Graph_TestVectorLine", linePoints, 10.0f, LineType.Continuous, Joins.Weld);

            this._vectorline.color = Color.red;
            this._vectorline.layer = LayerMask.NameToLayer ("Non-Physic");
            
            //this._vectorline.Draw3D(); 
            this._vectorline.Draw3DAuto(); 
    }
Example #4
0
	void tutorialLine (){
		helperLine = new VectorLine("tutorial_line", new List<Vector3>(), lineMaterial, 12.0f,LineType.Continuous);
		helperLine.points3.Add(Camera.main.ScreenToWorldPoint(rightHelper.transform.position));
		helperLine.points3.Add(Camera.main.ScreenToWorldPoint(rightMenu.transform.position));
		helperLine.textureScale = 1.0f;
		helperLine.Draw();
	}
    void Start()
    {
        GridSize = GlobalVars.GridSize;

        VectorLine.SetCamera3D(GameObject.Find(VectrosityCamera));
        LinePoints = new List<Vector3>();

        // Init Stuff

        //CreateGridLines();

        // Creating array of lines

        var myLine = new VectorLine(LineName, LinePoints, null, LineWidth);
        myLine.SetColor(Color.white);

        // Setting up the line

        myLine.Draw3D();
        
        GameObject.Find(LineName).transform.position = new Vector3(0.5f, GridHeight, 0.5f);
        // Position Camera with the Grid

        CreateClickableTile();

    }// Start
Example #6
0
 public void clearBorders()
 {
     VectorLine.Destroy(ref border);
     border = null;
     VectorLine.Destroy(ref glow);
     glow = null;
 }
Example #7
0
  public Curve(Molecule mol, Vector2 pos, Camera VectroCam = null)
  {
    _mol = mol;
    _label = mol.getName();
    _points = new LinkedList<Vector2>();
    //_pts = new Vector2[_maxPoints];
    _pts = new List<Vector2>();
    _minY = 0;
    _maxY = 0;
    _color = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
    //_line = new VectorLine(mol.getName(), _pts, _color, null, 2.0f, LineType.Continuous, Joins.Weld);
    _line = new VectorLine(mol.getName(), _pts, 2.0f, LineType.Continuous, Joins.Weld);
    _line.color = _color;
    _isEnabled = true;
    _vectroCam = VectroCam;
//     _pos = pos;

//     _lines = new VectorLine[_maxPoints];
//     _linesTypes = new _linesTypes[_maxPoints - 1];

    VectorManager.useDraw3D = true;
    if (_vectroCam != null)
      //Vectrosity.VectorLine.SetCamera(_vectroCam);
      Vectrosity.VectorLine.SetCamera3D(_vectroCam);
    else
      Logger.Log("No Camera set for the Graph Window.", Logger.Level.ERROR);
  }
	public void Setup (VectorLine line) {
		if (!VectorManager.use) {
			Debug.LogError("The VectorManager script must be attached to an object in the scene");
			return;
		}
		VectorManager.use.VisibilitySetup (transform, line, out m_objectNumber);
		vectorLine = line;
	}
Example #9
0
	void drawOrange(){
		uiPath_1 = new VectorLine("dragLine_0", new List<Vector3>(), lineMaterial, 22.0f,LineType.Continuous);
		uiPath_1.textureScale = 1.0f;
		uiPath_1.points3.Add(Camera.main.ScreenToWorldPoint(orangeBox.transform.position));
		uiPath_1.points3.Add(Camera.main.ScreenToWorldPoint(edge_1.transform.position));
		uiPath_1.color = Color.black;
		uiPath_1.Draw();
	}
Example #10
0
    public override void initializeVectorLine() {
        this._vectorline = new VectorLine("GraphNL_"+name, _pointsList, 1.0f, LineType.Continuous, Joins.Weld);
		this._vectorline.color = this.color;
		this._vectorline.layer = _panelInfos.layer;
		
        //resize();
		redraw();
    }
Example #11
0
	public void Setup (VectorLine line, bool makeBounds) {
		if (makeBounds) {
			VectorManager.SetupBoundsMesh (gameObject, line);
		}
		
		VectorManager.VisibilitySetup (transform, line, out m_objectNumber);
		vectorLine = line;
	}
Example #12
0
    public PathDisplay(List<VectorLine> visits, VectorLine line,
					List<Color> _color, List<float> _widths)
    {
        path_line = line;
        spot_list = visits;
        color_list = _color;
        width_list = _widths;
    }
Example #13
0
    void Start()
    {
        _vector = new VectorLine("beatcircle", new Vector3[10], Color.white, null, 1F, LineType.Continuous);
        _vector.MakeCircle(Vector3.zero, 0.01F);
        _vector.Draw3D();
        _vector.vectorObject.transform.parent = transform;

        gameObject.AddComponent<Scale>();
    }
	public void Setup (VectorLine line) {
		if (line.lineColors == null) {
			Debug.LogError ("In order to use Brightness.Fog, the line \"" + line.vectorObject.name + "\" must contain segment colors");
			return;
		}
		objectNumber = new RefInt(0);
		VectorManager.use.CheckDistanceSetup (transform, line, line.lineColors[0], objectNumber);
		VectorManager.use.SetDistanceColor (objectNumber.i);
	}
Example #15
0
 public void RemoveLine(VectorLine vectorLine)
 {
     for (int i = 0; i < lineCount; i++) {
         if (vectorLine == lines[i]) {
             RemoveLine (i);
             break;
         }
     }
 }
    public void InitLine(string name)
    {
        boneLine = new VectorLine(name, new Vector2[2] , null, 6f);
        boneLine.color = Color.green;

        boneLine.rectTransform.anchorMin.Set(0.5f, 0.5f);
        boneLine.rectTransform.anchorMax.Set(0.5f, 0.5f);
        boneLine.rectTransform.pivot.Set(0.5f, 0.5f);
    }
Example #17
0
    void AddGrid()
    {
        float rowCount = 12.0f;
        float colCount = 16.0f;

        float colStep = Screen.width / colCount;
        float rowStep = Screen.height / rowCount;

        //		Debug.Log (colStep + " " + rowStep);
        //		Debug.Log (Screen.width + " " + Screen.height);

        //
        //		for (int i = 0; i < rowCount; i++) {
        //
        //
        //			Vector2 a = new Vector2 (0, i * rowStep);
        //
        //			Vector2 b = new Vector2 (Screen.width, i * rowStep);
        //
        //
        //			Debug.DrawLine (a, b, Color.red);
        //
        //		}
        //
        //
        //		for (int j = 0; j < 16; j++) {
        //
        //			Vector2 a = new Vector2 (j * colStep, 0);
        //			Vector2 b = new Vector2 (j * colStep, Screen.height);
        //
        //			Debug.DrawLine (a, b, Color.red);
        //		}

        for (int i = 0; i < rowCount; i++) {

            Vector2 a = new Vector2 (0, i * rowStep);

            Vector2 b = new Vector2 (Screen.width, i * rowStep);

            VectorLine line = new VectorLine ("row" + i, new Vector2[]{a,b}, null, 1.0f);
            line.SetColor (Color.green);

            line.Draw ();
        }

        for (int j = 0; j < 16; j++) {

            Vector2 a = new Vector2 (j * colStep, 0);
            Vector2 b = new Vector2 (j * colStep, Screen.height);

            VectorLine line = new VectorLine ("col" + j, new Vector2[]{a,b}, null, 1.0f);
            line.SetColor (Color.green);

            line.Draw ();
        }
    }
Example #18
0
 public void Setup(VectorLine line, bool m_useLine)
 {
     m_objectNumber = new RefInt(0);
     VectorManager.CheckDistanceSetup (transform, line, line.color, m_objectNumber);
     VectorManager.SetDistanceColor (m_objectNumber.i);
     if (m_useLine) {	// Only if there are no Visibility scripts being used
         this.m_useLine = true;
         m_vectorLine = line;
     }
 }
Example #19
0
 void DrawBackground () {
     float y = Screen.height - yOffset;
     Vector2 start = new Vector2(xOffset, y);
     float x = (xOffset + BackgroundValue)*multiplier + 2 * margin;
     Vector2 end = new Vector2(x, y);
     bgLine = VectorLine.SetLine(bgColor, new Vector2[] { start, end });
     bgLine.lineWidth = bgThickness;
     bgLine.sortingOrder = 1;
     bgLine.Draw();
 }
Example #20
0
 void InitializeHPBar () {
     float y = Screen.height - yOffset;
     Vector2 start = new Vector2(xOffset + margin, y);
     float x = (xOffset + Value)*multiplier + margin;
     Vector2 end = new Vector2(x, y);
     hpLine = VectorLine.SetLine(hpColor, new Vector2[] { start, end });
     hpLine.lineWidth = bgThickness - (2 * margin);
     hpLine.sortingOrder = 2;
     hpLine.Draw();
 }
Example #21
0
    public void init(GameObject goA, GameObject goB, Color color)
    {
        setObjectA(goA);
        setObjectB(goB);

        Vector2[] linePoints = new Vector2[20];

        _line = new VectorLine("CurveLine", linePoints, color, null, 3.0f, LineType.Continuous);
        redraw();
    }
Example #22
0
    private VectorLine CreateVectorLine()
    {
        if (_pool.Count > 0)
        {
            return _pool.Dequeue();
        }

        var val = new VectorLine("trail", new Vector3[2], Color.white, null, 1F, LineType.Continuous);
        return val;
    }
 public void NewColor(string name)
 {
     foreach (VectorLine line in Lines)
     {
         if (line.name == name)
         {
             this.line = line;
         }
     }
 }
Example #24
0
    /// <summary>
    /// 绘制矩形
    /// </summary>
    private void CreateRect(float posX, float posY, float width, float height, Color color)
    {
        VectorLine squareLine = new VectorLine ("Square", new Vector2[8], null, 1.0f, LineType.Discrete, Joins.Weld);

        squareLine.MakeRect (new Rect (posX, posY, width, height));

        squareLine.SetColor (color);

        squareLine.Draw ();
    }
Example #25
0
	void drawYellowPath(){
		if(dragThrow.canUp){
			answerPath_yellow = new VectorLine("dragLine_yellow", new List<Vector3>(), lineMaterial, lineWidth,LineType.Continuous);
			answerPath_yellow.textureScale = 1.0f;
			answerPath_yellow.color = dragThrow.yellowBox.GetComponent<SpriteRenderer>().color;
			for (int i = 0; i < dragThrow.yellow_ans.Length; i++) {
				answerPath_yellow.points3.Add(dragThrow.yellow_ans[i]);
			}
			answerPath_yellow.Draw();
		}
	}
Example #26
0
	void drawOrangePath(){
		if(dragThrow.canRight){
			answerPath_orange = new VectorLine("dragLine_orange", new List<Vector3>(), lineMaterial, lineWidth,LineType.Continuous);
			answerPath_orange.textureScale = 1.0f;
			answerPath_orange.color = dragThrow.orangeBox.GetComponent<SpriteRenderer>().color;
			for (int i = 0; i < dragThrow.orange_ans.Length; i++) {
				answerPath_orange.points3.Add(dragThrow.orange_ans[i]);
			}
			answerPath_orange.Draw();
		}
	}
Example #27
0
    public void setLine(int size, string color, string brush)
    {
        String newLineName = size +","+ color + "," + brush;

        foreach (VectorLine line in Lines)
        {
            if (line.name == newLineName) {
                this.line = line;
            }
        }
    }
Example #28
0
    private VectorLine CreateVectorLine()
    {
        if (_pool.Count > 0)
        {
            return _pool.Dequeue();
        }

        var vl = new VectorLine("frag", new Vector3[] { new Vector3(), new Vector3() }, Color.white, null, 1F, LineType.Continuous);
        vl.vectorObject.transform.parent = transform;
        return vl;
    }
Example #29
0
	void DrawSectors () {
		Vector2 screenTop = new Vector2(Screen.width/2, Screen.height);
		Vector2 screenTopDiff = screenTop - currentInputController.aimFrom;
		Vector2 scaleFactor = new Vector2(10, 10);
		Vector2 topRightPoint = Vector2.Scale(screenTopDiff.Rotate(60f), scaleFactor) + currentInputController.aimFrom;
		Vector2 topLeftPoint = Vector2.Scale(screenTopDiff.Rotate(-60f), scaleFactor) + currentInputController.aimFrom;
		Vector2 bottomPoint = Vector2.Scale(screenTopDiff.Rotate(180f), scaleFactor) + currentInputController.aimFrom;

		debugLineRight = VectorLine.SetLine(Color.red, currentInputController.aimFrom, topRightPoint);
		debugLineLeft = VectorLine.SetLine(Color.red, currentInputController.aimFrom, topLeftPoint);
		debugLineBottom = VectorLine.SetLine(Color.red, currentInputController.aimFrom, bottomPoint);
	}
Example #30
0
    public void Hide()
    {
        if(structure != null)
            structure.NotifyClickAway();

        if(linkToSubject != null)
        {
            VectorLine.Destroy(ref linkToSubject);
            linkToSubject = null;
        }
        transform.position += new Vector3( Screen.width + 10000, 0, 0);
    }
Example #31
0
    protected override void init()
    {
        msh        = new Mesh();
        vertices2D = new List <Vector2>();
        var g = new GameObject(Time.deltaTime.ToString());

        g.AddComponent(typeof(MeshRenderer));
        MeshFilter filter = g.AddComponent(typeof(MeshFilter)) as MeshFilter;

        g.GetComponent <MeshRenderer>().material.color = Color.green;
        g.transform.parent = GisWrapper.polygonParent.transform;
        type        = OperatingToolType.GISPolygon;
        filter.mesh = msh;

        line = new VectorLine(ToString(), new List <Vector2>(), null, 1.0f, LineType.Continuous);
        line.SetColor(Color.white);

        Reset();
    }
Example #32
0
 public static void CheckDistanceSetup(Transform thisTransform, VectorLine line, Color color, RefInt objectNum)
 {
     VectorLine.LineManagerEnable();
     if (vectorLines3 == null)
     {
         vectorLines3   = new List <VectorLine>();
         transforms3    = new List <Transform>();
         oldDistances   = new List <int>();
         colors         = new List <Color>();
         objectNumbers3 = new List <RefInt>();
         VectorLine.LineManagerCheckDistance();
     }
     transforms3.Add(thisTransform);
     vectorLines3.Add(line);
     oldDistances.Add(-1);
     colors.Add(color);
     objectNum.i = _arrayCount3++;
     objectNumbers3.Add(objectNum);
 }
Example #33
0
    /// <summary>
    /// void Start ()
    ///
    /// Initializes the gameboard.
    ///
    /// </summary>
    void Start()
    {
        //Add observers
        NotificationCenter.DefaultCenter().AddObserver(this, "Pause");
        NotificationCenter.DefaultCenter().AddObserver(this, "Unpause");

        //Move gameboard into position
        gameObject.transform.position = new Vector3(0, 0, 1f);

        //Create tileboard
        Debug.Log("Creating TileBoard");
        for (int x = 0; x < GridWidth; x++)
        {
            for (int y = 0; y < GridHeight; y++)
            {
                GameObject g = Instantiate(tilePrefab, new Vector3(x, y, 0), Quaternion.identity) as GameObject;
                g.transform.name   = string.Format("Tile ({0},{1})", x, y);
                g.transform.parent = gameObject.transform;
                tileBoard[x, y]    = g.GetComponent <Tile>();
                g.GetComponent <SliderJoint2D>().anchor = new Vector2(x + GridXOffset, y);
            }
        }
        //Create line object
        arrayLine    = new VectorLine("MyLine", new Vector3[100], Color.green, arrayLineMat, 5.0f, LineType.Continuous, Joins.Fill);
        arrayLineTip = new VectorLine("MyLine", new Vector3[100], Color.red, arrayTipMat, 5.0f, LineType.Continuous, Joins.Fill);
        arrayLine.ZeroPoints();
        arrayLineTip.ZeroPoints();

        //Initialize dimmer
        dim = Instantiate(dimPrefab, new Vector3(-GridXOffset, -1.509109f, -2f), Quaternion.identity) as GameObject;
        dim.transform.name            = "Dimmer";
        dim.transform.parent          = gameObject.transform;
        dim.renderer.enabled          = false;
        dim.renderer.sortingLayerName = "Default";
        dim.renderer.sortingOrder     = 0;

        //Initialize lifebar
        lifeBar.renderer.enabled          = false;
        lifeBar.renderer.sortingLayerName = "GUI";
        lifeBar.renderer.sortingOrder     = 1;

        gameObject.transform.position = new Vector3(GridXOffset, GridYOffset, 0);
    }
Example #34
0
    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>());
    }
Example #35
0
    public void Initialize( )
    {
        SUCCESS_DIST = Screen.width * 0.035f;
        Debug.Log(SUCCESS_DIST);

        target_lines = new VectorLine("target_lines", new Vector2[8], Color.black, null, 4);

        //float w = target_screen_rect.width * Screen.width;

        float max_w = Screen.height * aspect_ratio.x / aspect_ratio.y;
        float min_w = Screen.width / 15;

        float max_h = Screen.width * aspect_ratio.y / aspect_ratio.x;
        float min_h = Screen.height / 15;

        float w = Random.RandomRange(min_w, max_w);
        float h = w * aspect_ratio.y / aspect_ratio.x / ((float)Screen.width / (float)Screen.height);   //target_screen_rect.height * Screen.height;

        while (h > max_h || h < min_h)
        {
            Debug.Log("Was of improper y");
            w = Random.RandomRange(min_w, max_w);
            h = w * aspect_ratio.y / aspect_ratio.x / ((float)Screen.width / (float)Screen.height);
        }

        float x = Random.RandomRange(0, Screen.width - w); //target_screen_rect.x * Screen.width;
        float y = Random.RandomRange(h, Screen.height);    //target_screen_rect.y * Screen.height;

        target_size = new Rect(x, y, w, h);


        target_lines.MakeRect(target_size);
        target_lines.Draw( );

        top_left  = new Vector2(target_size.xMin, target_size.yMax);    // - target_size.height );
        top_right = new Vector2(target_size.xMax, target_size.yMax);    // - target_size.height );

        bottom_left  = new Vector2(target_size.xMin, target_size.yMin); // - target_size.height );
        bottom_right = new Vector2(target_size.xMax, target_size.yMin); // - target_size.height );

        initialized = true;
    }
Example #36
0
    public void FillTrajectoryTrail()
    {
        // Build points list
        var pointsList = new List <Vector3>();

        for (float theta = 0; theta < Pi2; theta += this.TrajectoryTrailDetail)
        {
            var x = (float)(this.distanceFromSun * Math.Cos(theta));
            var z = (float)(this.distanceFromSun * Math.Sin(theta));
            pointsList.Add(new Vector3(x, this.transform.position.y, z));
        }

        // Create path line
        this.trajectoryPath = new VectorLine(
            "PlanetTrajectoryPath",
            pointsList.ToArray(),
            this.TrajectorTrailMaterial,
            this.TrajectoryTrailSize,
            LineType.Continuous);
    }
Example #37
0
        public LegendLine(GraphLines parent, Guid id, int index, Color color)
        {
            Transform transform = parent.m_legendMesh.transform;
            Vector3   position  = transform.position;

            m_id                   = id;
            m_vector               = new VectorLine("LegendLine" + index, new Vector3[2], parent.m_lineMaterial, parent.m_lineWidth, LineType.Discrete);
            m_vector.color         = color;
            m_vector.drawTransform = transform;
            m_vector.Draw3DAuto();

            float spacing = parent.m_legendMesh.characterSize * 1.5F;

            // Position legend line relative to text descriptions
            Vector3 point1 = new Vector3(-2.0F, -(spacing / 2.0F + index * spacing), -position.z);
            Vector3 point2 = new Vector3(-0.5F, point1.y, point1.z);

            m_vector.points3[0] = point1;
            m_vector.points3[1] = point2;
        }
        /// <summary>
        /// This should be called when updating the object's personal properties
        /// </summary>
        public virtual void UpdateObjectParameters()
        {
            var local = GameDiameter;

            if (Parent != null && Parent.Obj != null)
            {
                local = (GameDiameter / Parent.Obj.transform.localScale.x) * 1.5f;
            }
            this.Obj.transform.localScale = new Vector3(local, local, local);

            // This is a dumb way to enforce that the object is in the right location
            UpdateOrbitLocation(0f);
            ForceVisualUpdate();

            if (Parent != null)
            {
                _swimLane = null;
                var sl = SwimLane;
            }
        }
Example #39
0
    // Use this for initialization
    void Start()
    {
        VectorManager.useDraw3D = true;

        var pos3d = transf.Select(x => x.position).ToList();
        var pos2d = pos3d.Select(x => new Vector2(x.x, x.y)).ToList();

        //draw 2d
        vobj.vectorLine.Resize(pos2d.Count + 1);
        vobj.vectorLine.points2 = pos2d;
        vobj.vectorLine.points3 = pos3d;
        vobj.vectorLine.Draw();

        //draw 3d
        var vl = new VectorLine("a", pos3d, 100f);

        vobj3d.SetVectorLine(vl, vobj.texture, mat);
        vl.points3.ForEach(x => Debug.Log(x));
        vl.Draw3DAuto();
    }
Example #40
0
    public void removeLine()
    {
        point1active = false;
        point2active = false;
        PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> ();

        VectorLine.Destroy(ref myLine);
        pc.drawLine   = false;
        lineCrossed   = 0;
        crossingSpeed = 0.0f;

        crossings = new List <decimal> ();

        InfoText it = GameObject.Find("InfoText").GetComponent <InfoText> ();

        if (it.diagram)
        {
            it.removeDiagram();
        }
    }
Example #41
0
    void CreateLine(Color lineColor, int lineSize)
    {
        points = new Vector3[2] {
            RodControllerTest.Instance.rodTip.position, LurePosition.position
        };
        myLine          = VectorLine.SetLine3D(lineColor, points);
        myLine.joins    = Joins.Fill;
        myLine.material = lineMat;
        SetLineWidth(lineSize, lineColor);

        /*VectorLine.SetLineParameters (lineColor, null, lineSize, 1,
         * 1, LineType.Continuous, Joins.Fill);
         * myLine.Resize(N);*/
        myLine.Resize(N);
        if (myLine == null)
        {
            Debug.Log("CreateLine null");
        }
        this.UpdateEndPoints();
    }
    public void showTrajectory()
    {
        VectorLine.SetCamera(GameObject.Find("Flycam").GetComponent <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()));
        }
        if (points.Count < 2)
        {
            return;
        }
        trajectory           = VectorLine.SetLine3D(myColor, points.ToArray());
        trajectory.lineWidth = 3.0f;
        pc.trajectoriesShown = true;
        trajectoryVisible    = true;
    }
Example #43
0
    //实际显示大小
    public float GetWorldLineWidth()
    {
        float ret = Common.ScreenToWorldWidth(mainCam, lineWidth);

        return(ret);

        if (listLine.Count != 0)
        {
            VectorLine line = listLine[0] as VectorLine;
            GameObject obj  = line.GetObj();
            Renderer   rd   = obj.GetComponent <Renderer>();
            if (rd != null)
            {
                ret = Mathf.Min(rd.bounds.size.x, rd.bounds.size.y);
                Debug.Log("line real = " + ret + " w=" + Common.ScreenToWorldWidth(mainCam, lineWidth) + " h=" + Common.ScreenToWorldHeight(mainCam, lineWidth));
            }
        }

        return(ret);
    }
Example #44
0
    void Start()
    {
        startIndex = -visibleLineSegments;
        endIndex   = 0;

        // Make Vector3 array where the size is the number of segments plus one, since we'll use a continuous line
        var linePoints = new List <Vector3>(segments + 1);

        // Make a VectorLine object using the above points, with a width of 2 pixels
        line           = new VectorLine("LeadIn", linePoints, 2.0f, LineType.Continuous, Joins.Weld);
        line.texture   = Manager.use.lineTexture;
        line.material  = Manager.use.lineMaterial;
        line.color     = Manager.use.colorNormal;
        line.capLength = Manager.use.capLength;

        var x = -22;
        var y = -15;

        line.MakeSpline(new Vector3[] { new Vector3(x, y, 10), new Vector3(x, y, 200) });
    }
Example #45
0
    // 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);
    }
Example #46
0
    void Start()
    {
        position = new Vector2(radius + 20, Screen.height - (radius + 20));

        // Set up a white circle for the background of the power bar
        var circle = new VectorLine("BarBackground", new List <Vector2>(50), null, lineWidth, LineType.Continuous, Joins.Weld);

        circle.MakeCircle(position, radius);
        circle.Draw();

        // Make the power bar by drawing a 270° arc
        bar       = new VectorLine("TotalBar", new List <Vector2>(segmentCount + 1), null, lineWidth - 4, LineType.Continuous, Joins.Weld);
        bar.color = Color.black;
        bar.MakeArc(position, radius, radius, 0.0f, 270.0f);
        bar.Draw();

        currentPower = Random.value;
        SetTargetPower();
        // Set the initial bar colors by coloring the segments from the beginning to the current power level
        bar.SetColor(Color.red, 0, (int)Mathf.Lerp(0, segmentCount, currentPower));
    }
Example #47
0
 private void DrawOrbitLine()
 {
     /*
      * float angle = Mathf.Atan2(primary.y - periapsis.y, primary.x - periapsis.x);
      * float a = Vector2.Distance(primary, periapsis) / (1 - eccentricity);
      * float b = Mathf.Sqrt(a * a * (1 - eccentricity * eccentricity));
      * Vector3 orbitOrigin = new Vector3(periapsis.x + a * Mathf.Cos(angle), periapsis.y + a * Mathf.Sin(angle), 10);
      * VectorLine orbitLine = new VectorLine(gameObject.name + " Orbit", new List<Vector3>(GameManager.singleton.orbitLineSegments + 1),
      *  Resources.Load<Texture>("thinline"), 5.0f, LineType.Continuous);
      *
      *
      * orbitLine.MakeEllipse(orbitOrigin, a, b, 180, pointRotation: angle);
      * orbitLine.SetColor(new Color32(255, 255, 255, 64));
      * orbitLine.Draw3D();
      */
     orbitLine = new VectorLine(gameObject.name + " Orbit", GetLineVertices(), Resources.Load <Texture>("thinline"), 5.0f, LineType.Continuous);
     orbitLine.SetColor(orbitColor);
     orbitLine.SetWidths(GetLineWidths());
     orbitLine.Draw3D();
     //List<float> lineWidths = new List<float>();
 }
    public void Setup(VectorLine line, bool makeBounds)
    {
        if (makeBounds)
        {
            VectorManager.SetupBoundsMesh(gameObject, line);
        }
        // Adjust points to this position, so the line doesn't have to be updated with the transform of this object
        // Also make sure the points are unique by creating a new list and copying the points over
        m_originalMatrix = transform.localToWorldMatrix;
        var thisPoints = new List <Vector3>(line.points3);

        for (int i = 0; i < thisPoints.Count; i++)
        {
            thisPoints[i] = m_originalMatrix.MultiplyPoint3x4(thisPoints[i]);
        }
        line.points3 = thisPoints;
        m_vectorLine = line;

        VectorManager.VisibilityStaticSetup(line, out m_objectNumber);
        StartCoroutine(WaitCheck());
    }
    public void Setup(VectorLine line)
    {
        if (!VectorManager.use)
        {
            Debug.LogError("The VectorManager script must be attached to an object in the scene");
            return;
        }
        // Adjust points to this position, so the line doesn't have to be updated with the transform of this object
        // We make a new array since each line must therefore be a unique instance, not a reference to the original set of Vector3s
        var thisPoints = new Vector3[line.points3.Length];
        var thisMatrix = transform.localToWorldMatrix;

        for (int i = 0; i < thisPoints.Length; i++)
        {
            thisPoints[i] = thisMatrix.MultiplyPoint3x4(line.points3[i]);
        }
        line.points3 = thisPoints;
        vectorLine   = line;
        VectorManager.use.VisibilityStaticSetup(line, out m_objectNumber);
        StartCoroutine(WaitCheck());
    }
    public void Setup(VectorLine line, bool makeBounds)
    {
        if (makeBounds)
        {
            VectorManager.SetupBoundsMesh(gameObject, line);
        }
        // Adjust points to this position, so the line doesn't have to be updated with the transform of this object
        // We make a new array since each line must therefore be a unique instance, not a reference to the original set of Vector3s
        var thisPoints = new Vector3[line.points3.Length];
        var thisMatrix = transform.localToWorldMatrix;

        for (int i = 0; i < thisPoints.Length; i++)
        {
            thisPoints[i] = thisMatrix.MultiplyPoint3x4(line.points3[i]);
        }
        line.points3 = thisPoints;
        m_vectorLine = line;

        VectorManager.VisibilityStaticSetup(line, out m_objectNumber);
        StartCoroutine(WaitCheck());
    }
Example #51
0
 public void CheckDistanceSetup(Transform thisTransform, VectorLine line, Color color, RefInt objectNum)
 {
     if (!checkRunning)
     {
         isVisible3     = new List <bool>();
         transforms3    = new List <Transform>();
         vectorLines3   = new List <VectorLine>();
         oldDistances   = new List <int>();
         colors         = new List <Color>();
         objectNumbers3 = new List <RefInt>();
         InvokeRepeating("CheckDistance", .01f, distanceCheckFrequency);
         checkRunning = true;
     }
     isVisible3.Add(true);
     transforms3.Add(thisTransform);
     vectorLines3.Add(line);
     oldDistances.Add(-1);
     colors.Add(color);
     objectNum.i = arrayCount3++;
     objectNumbers3.Add(objectNum);
 }
Example #52
0
    private void Start()
    {
        DrawCurve.use    = this;
        DrawCurve.cam    = Camera.get_main();
        this.oldWidth    = Screen.get_width();
        this.oldSegments = this.segments;
        List <Vector2> vector2List = new List <Vector2>();

        vector2List.Add(new Vector2((float)Screen.get_width() * 0.25f, (float)Screen.get_height() * 0.25f));
        vector2List.Add(new Vector2((float)Screen.get_width() * 0.125f, (float)Screen.get_height() * 0.5f));
        vector2List.Add(new Vector2((float)Screen.get_width() - (float)Screen.get_width() * 0.25f, (float)Screen.get_height() - (float)Screen.get_height() * 0.25f));
        vector2List.Add(new Vector2((float)Screen.get_width() - (float)Screen.get_width() * 0.125f, (float)Screen.get_height() * 0.5f));
        this.controlLine = new VectorLine("Control Line", vector2List, 2f);
        this.controlLine.set_color(Color32.op_Implicit(new Color(0.0f, 0.75f, 0.1f, 0.6f)));
        this.controlLine.Draw();
        this.line = new VectorLine("Curve", new List <Vector2>(this.segments + 1), this.lineTexture, 5f, (LineType)0, (Joins)1);
        this.line.MakeCurve(Vector2.op_Implicit(vector2List[0]), Vector2.op_Implicit(vector2List[1]), Vector2.op_Implicit(vector2List[2]), Vector2.op_Implicit(vector2List[3]), this.segments);
        this.line.Draw();
        this.AddControlObjects();
        this.AddControlObjects();
    }
Example #53
0
        protected override bool create_line()
        {
            if (line == null || points.Length != line.points3.Count)
            {
                destroy_line();
                scaled_space = MapView.MapIsEnabled;
#pragma warning disable IDE0017 // Simplify object initialization
                line = new VectorLine(name, new List <Vector3>(points.Length), width,
                                      LineType.Continuous, Joins.Fill);
#pragma warning restore IDE0017 // Simplify object initialization
                line.texture                 = _material.mainTexture;
                line.material                = _material;
                line.continuousTexture       = true;
                line.ContinuousTextureOffset = 0;
                line.smoothColor             = true;
                line.UpdateImmediate         = true;
                line.capLength               = 0;
                line.layer = scaled_space ? mapMask : flightMask;
            }
            return(line != null);
        }
Example #54
0
    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();

        //
    }
    void Start()
    {
        //VectorLine.SetCamera3D();
        //Vector2[] linePoints = {new Vector2(0,0),new Vector2(1,1)};
        //VectorLine myline = new VectorLine.SetLine(Color.green, new Vector2(0, 0), new Vector2(1, 1));
        Vector2[]  linePoints = { new Vector2(0, 0), new Vector2(1, 1) };
        Material   line       = (Material)Resources.Load("Line");
        VectorLine myline     = new VectorLine("MyLine", linePoints, null, 0.05f, LineType.Continuous);
        //VectorLine.SetCanvasCamera (Camera.main);


        //c.re

        Rect r = new Rect(0, 0, 2, 1);

        //myline.make
        myline.MakeRoundedRect(r, 0.2f, 10);
        myline.SetColor(Color.black);

        myline.Draw();
    }
Example #56
0
    public void AddLine(VectorLine vectorLine, Transform thisTransform, float time)
    {
        if (time > 0.0f)                // Needs to be before the line check, to accommodate re-added lines
        {
            StartCoroutine(DisableLine(vectorLine, time, false));
        }
        for (int i = 0; i < lineCount; i++)
        {
            if (vectorLine == lines[i])
            {
                return;
            }
        }
        lines.Add(vectorLine);
        transforms.Add(thisTransform);

        if (++lineCount == 1)
        {
            enabled = true;
        }
    }
Example #57
0
    /*!
     * \brief Constructor
     * \param graphHeight Max Y value
     * \param graphWidth Max number of values on the X axis (cannot be modified)
     * \param panelinfos contains the panel Transform values \sa PanelInfos
     */
    public TestFlatLine(int graphWidth, float graphHeight, PanelInfos panelInfos, string name = "")
    {
        this.name        = name;
        this._panelInfos = panelInfos;
        this._graphWidth = graphWidth;
        this.graphHeight = graphHeight;
        computeRatios();

        this.color = generateAppropriateColor();

        this._floatList        = new List <float>();
        this._pointsLinkedList = new LinkedList <Vector2>();
        this._pointsList       = new List <Vector2>();

        this._vectorline       = new VectorLine("GraphNL_" + name, _pointsList, 1.0f, LineType.Continuous, Joins.Weld);
        this._vectorline.color = this.color;
        this._vectorline.layer = _panelInfos.layer;

        resize();
        redraw();
    }
Example #58
0
    public void HohmannTransfer(Orbit target)
    {
        if (target.primary != primary)
        {
            Debug.Log("Orbits have different primaries. Cannot calculate Hohmann transfer.");
            return;
        }
        Vector3 transferApsis = target.GetPosition(currentAngle + Mathf.PI + periapsisAngle - target.periapsisAngle);    //apsis opposite current position
        //Debug.Log("Apsis " + transferApsis);
        Vector2 transferCenter = (Vector2)(transferApsis + transform.position) / 2.0f;
        //Debug.Log("Center " + transferCenter);
        float transferEccentricity = Vector2.Distance(transferCenter, primary) / Vector2.Distance(transferCenter, (Vector2)transform.position);
        //float transferC = Vector2.Distance(transferCenter, primary);
        //float transferSemiMajorAxis = Vector2.Distance(transferCenter, (Vector2)transform.position);
        //float transferPeriod = (period + target.period) / 2.0f;
        Vector2 transferPeriapsis;
        float   transferAngle;

        if (Vector2.Distance((Vector2)transform.position, primary) < Vector2.Distance(transferApsis, primary))
        {
            transferPeriapsis = transform.position;
            transferAngle     = 0.0f;
            //Debug.Log(transferStartingAngle);
        }
        else
        {
            //Debug.Log("inward at " + transferApsis);
            transferPeriapsis = transferApsis;
            transferAngle     = Mathf.PI;
            //Debug.Log(transferPeriapsis);
        }
        //GameObject obj = new GameObject();
        //obj.SetActive(false);
        //Orbit transferOrbit = obj.AddComponent<Orbit>();
        VectorLine.Destroy(ref orbitLine);
        Initialize(primary, transferPeriapsis, transferEccentricity, period, transferAngle);
        currentTime = -currentTime;
        DrawOrbitLine();
        //obj.SetActive(true);
    }
    private void generatePointsAndDraw()
    {
        Debug.LogError("TestPanelPerimeter generatePointsAndDraw with tppmode=" + tppmode + " in " + name);
        if (TPPMode.RANDOM == tppmode)
        {
            point1      = new GameObject();
            point1.name = "point1-global";
            Vector2 position1 = generateRandomPoint();
            point1.transform.position = position1;

            point2      = new GameObject();
            point2.name = "point2-global";
            Vector2 position2 = generateRandomPoint();
            point2.transform.position = position2;

            List <Vector2> linePoints = new List <Vector2>()
            {
                position1, position2
            };
            this._vectorline       = new VectorLine("Graph_" + name, linePoints, 1.0f, LineType.Continuous, Joins.Weld);
            this._vectorline.color = this.color;
            this._vectorline.layer = _panelInfos.layer;
            this._vectorline.Draw();
        }
        else if (TPPMode.PERIMETER == tppmode)
        {
            string debug = "linePointsPerimeter=[";
            foreach (Vector2 point in linePointsPerimeter)
            {
                debug += point + ";";
            }
            debug += "]";
            Debug.LogError("generatePointsAndDraw: " + debug);

            this._vectorline       = new VectorLine("Graph_" + name, linePointsPerimeter, 1.0f, LineType.Continuous, Joins.Weld);
            this._vectorline.color = this.color;
            this._vectorline.layer = _panelInfos.layer;
            this._vectorline.Draw();
        }
    }
Example #60
0
    // Update is called once per frame
    void Update()
    {
        if (fromFile)
        {
            shape = VectorLine.BytesToVector3List(shapeFile.bytes);
        }

        if (!isStatic)
        {
            for (int i = 0; i < shape.Count; i++)
            {
                if (!fromFile)
                {
                    line.points3[i] = transform.TransformPoint(mesh.vertices[i]);
                }
                else
                {
                    Vector3 newPoint = transform.TransformPoint(shape[i]);
                    if (i % 2 == 0)
                    {
                        // newPoint = newPoint + Vector3.forward * Mathf.Sin(Time.time * 5f + (float)i/5f);
                    }

                    // newPoint = transform.TransformRotation(shape[i]);
                    line.points3[i] = newPoint;
                    if (i == 0)
                    {
                        // Debug.Log( transform.TransformPoint(shape[i]));
                    }
                }

                if (changeColor)
                {
                    line.SetColor(Color.Lerp(color, new Color(0, 0, 0, 0) + Color.white * 0.5f, Mathf.PingPong(Time.time + offset, 1)), i);
                }
            }

            line.Draw3D();
        }
    }