Esempio n. 1
0
 public void Redraw(bool draft = false)
 {
     if (Rs == null)
     {
         this.SmartDestroy();
     }
     Rs.RefreshMesh(true, true, true);
     //Redraw(true, true, true, draft);
 }
Esempio n. 2
0
    public void selectNearestItem(Vector3 position)
    {
        float      nearestItemDistance   = 999999999f;
        RageSpline previousActiveControl = activeControl;

        // Iterate all the GUI controls and find out which is the closest
        for (int index = 0; index < rageSpline.GetPointCount(); index++)
        {
            if ((controlPoints[index].transform.position - position).magnitude < nearestItemDistance)
            {
                nearestItemDistance     = (controlPoints[index].transform.position - position).magnitude;
                activeControlPointIndex = index;
                activeControlType       = ControlType.Point;
                activeControl           = controlPoints[index];
            }
            if ((inControlPoints[index].transform.position - position).magnitude < nearestItemDistance)
            {
                nearestItemDistance     = (inControlPoints[index].transform.position - position).magnitude;
                activeControlPointIndex = index;
                activeControlType       = ControlType.InCtrl;
                activeControl           = inControlPoints[index];
            }
            if ((outControlPoints[index].transform.position - position).magnitude < nearestItemDistance)
            {
                nearestItemDistance     = (outControlPoints[index].transform.position - position).magnitude;
                activeControlPointIndex = index;
                activeControlType       = ControlType.OutCtrl;
                activeControl           = outControlPoints[index];
            }
        }

        // Check if the closest is near enough
        if (nearestItemDistance > maxSelectionRange)
        {
            activeControl           = null;
            activeControlPointIndex = -1;
            activeControlType       = ControlType.NotSelected;
        }

        // Did the selected control change?
        if (previousActiveControl != activeControl)
        {
            // Reset the previously selected control to unselected color
            if (previousActiveControl != null)
            {
                previousActiveControl.SetFillColor1(unSelectedColor);
                previousActiveControl.RefreshMesh();
            }
            // Fill the newly selected control with selectedColor
            if (activeControl != null)
            {
                activeControl.SetFillColor1(selectedColor);
                activeControl.RefreshMesh();
            }
        }
    }
Esempio n. 3
0
 void Update()
 {
     if (Input.GetKey(KeyCode.J))
     {
         for (int i = 0; i < rageSpline.spline.points.Length - 1; i++)
         {
             float rnd    = Random.Range(-0.25f, 0.25f);
             var   newPos = rageSpline.GetPosition(i);
             rageSpline.SetPoint(i, new Vector3(newPos.x + rnd, newPos.y + rnd));
         }
     }
     rageSpline.RefreshMesh();
 }
Esempio n. 4
0
 public void Redraw(bool triangulate, bool calculateNormals, bool calculatePhysics, bool draft)
 {
     if (_rageSpline == null)
     {
         return;
     }
     _rageSpline.FlattenZ    = false;
     _rageSpline.FixOverlaps = !draft;
     if (!draft)
     {
         _rageSpline.RefreshMesh(true, true, true);
         //_rageSpline.Redraw (true, true, true, 0, 1f);
         return;
     }
     _currentStartNormals = _rageSpline.Redraw(_rageSpline.spline.Triangulate, calculateNormals, calculatePhysics, _currentStartNormals, 0.5f);  // ProgressiveNormalsPrecalc);
 }