コード例 #1
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         nbrOfInput++;
         //new point
         double percentPrecedent = splineFollower.result.percent;
         double nbrPoints        = (double)spline.pointCount;
         //Vector3 posPop = new Vector3(nbrOfInput, nbrOfInput, nbrOfInput);
         Vector3     posPop   = GetInstanceDotPositionRay(handTransform, playerTransform);
         SplinePoint newPoint = new SplinePoint();
         newPoint.position = posPop;
         newPoint.normal   = Vector3.up;
         newPoint.size     = 1f;
         newPoint.color    = Color.white;
         //CreateAPointClampSpline(newPoint);
         CreateAPoint(newPoint);
         spline.RebuildImmediate();
         splineFollower.result.percent = (double)(percentPrecedent / ((double)1 / (double)nbrPoints * ((double)nbrPoints + (double)1)));
     }
 }
コード例 #2
0
 void InstantiateANewAnchor(bool previsualisation)
 {
     if (previsualisation == false)
     {
         double      percentPrecedent = splineFollower.result.percent;
         double      nbrPoints        = (double)spline.pointCount;
         SplinePoint lastPoint        = spline.GetPoint(spline.pointCount - 1);
         Vector3     posPop           = GetInstanceDotPositionRay();
         SplinePoint newPoint         = new SplinePoint();
         newPoint.position = posPop;
         newPoint.normal   = curveInstantiator.up;
         newPoint.size     = 1f;
         newPoint.color    = Color.white;
         Vector3 distance = lastPoint.tangent2 - newPoint.position;
         newPoint.tangent  = distance / 2f + newPoint.position;
         newPoint.tangent2 = -distance / 2f + newPoint.position;
         CreateAPoint(newPoint);
         spline.RebuildImmediate();
         splineFollower.result.percent = (double)(percentPrecedent / ((double)1 / (double)nbrPoints * ((double)nbrPoints + (double)1)));
     }
     else
     {
         SplinePoint   lastPoint = spline.GetPoint(spline.pointCount - 1);
         SplinePoint[] points    = new SplinePoint[2];
         points[0] = lastPoint;
         Vector3 newPos = GetInstanceDotPositionRay();
         points[1].position = newPos;
         points[1].normal   = curveInstantiator.transform.up;
         points[1].size     = 1f;
         points[1].color    = Color.red;
         Vector3 distance = points[0].tangent2 - points[1].position;
         points[1].tangent  = distance / 1.5f + points[1].position;
         points[1].tangent2 = -distance / 1.5f + points[1].position;
         previsualisationSpline.SetPoints(points);
     }
 }
コード例 #3
0
    IEnumerator Rebuild()
    {
        yield return(0);

        spline.RebuildImmediate();
    }