예제 #1
0
    public void updateDraw(Vector3 inputPos)
    {
        //  if (playerSelected)
        //   {
        if (trailReference == null)
        {
            distance                 = 0;
            trailReference           = ((GameObject)Instantiate(motionPathPrefeb, this.transform.position, Quaternion.identity)).GetComponent <SplineTrailRenderer>();
            trailReference.maxLength = 0;

            /*
             * dragAxis = Vector3.Cross(Vector3.up, (Camera.main.transform.position - this.transform.position)).normalized;
             * Vector3 n = Vector3.Cross(dragAxis, Vector3.up).normalized;
             * dragPlane = new Plane(n, this.transform.position);*/
        }
        else if (trailReference != null)
        {
            trailReference.maxLength = trailReference.spline.Length();

            /*
             * float PLDis = 0;
             * Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             * dragPlane.Raycast(ray, out PLDis);
             */
            trailReference.transform.position = inputPos;
        }
        // }
    }
예제 #2
0
 public void startDraw()
 {
     playerSelected = true;
     if (trailReference != null)
     {
         trailReference.Clear();
         Destroy(trailReference.gameObject);
         trailReference = null;
     }
 }
예제 #3
0
    void Start()
    {
        SplineTrailRenderer trail = GetComponent <SplineTrailRenderer>();

        trail.Clear();
        trail.spline.Clear();

        foreach (Transform t in pointList)
        {
            trail.spline.knots.Add(new Knot(t.position));
        }

        trail.spline.Parametrize();
    }
예제 #4
0
 public void ImitateTrail(SplineTrailRenderer trail)
 {
     emit             = trail.emit;
     emissionDistance = trail.emissionDistance;
     height           = trail.height;
     width            = trail.width;
     vertexColor      = trail.vertexColor;
     normal           = trail.normal;
     meshDisposition  = trail.meshDisposition;
     fadeType         = trail.fadeType;
     fadeLengthBegin  = trail.fadeLengthBegin;
     fadeLengthEnd    = trail.fadeLengthEnd;
     maxLength        = trail.maxLength;
     debugDrawSpline  = trail.debugDrawSpline;
     GetComponent <Renderer>().material = trail.GetComponent <Renderer>().material;
 }
예제 #5
0
 public void ImitateTrail(SplineTrailRenderer trail)
 {
     this.emit              = trail.emit;
     this.emissionDistance  = trail.emissionDistance;
     this.height            = trail.height;
     this.width             = trail.width;
     this.vertexColor       = trail.vertexColor;
     this.normal            = trail.normal;
     this.meshDisposition   = trail.meshDisposition;
     this.fadeType          = trail.fadeType;
     this.fadeLengthBegin   = trail.fadeLengthBegin;
     this.fadeLengthEnd     = trail.fadeLengthEnd;
     this.maxLength         = trail.maxLength;
     this.debugDrawSpline   = trail.debugDrawSpline;
     base.renderer.material = trail.renderer.material;
 }
예제 #6
0
 public void ImitateTrail(SplineTrailRenderer trail)
 {
     emit = trail.emit;
     emissionDistance = trail.emissionDistance;
     height = trail.height;
     width = trail.width;
     vertexColor = trail.vertexColor;
     normal = trail.normal;
     meshDisposition = trail.meshDisposition;
     fadeType = trail.fadeType;
     fadeLengthBegin = trail.fadeLengthBegin;
     fadeLengthEnd = trail.fadeLengthEnd;
     maxLength = trail.maxLength;
     debugDrawSpline = trail.debugDrawSpline;
     GetComponent<Renderer> ().material = trail.GetComponent<Renderer> ().material;
 }
예제 #7
0
    void SwitchTrail()
    {
        if(trailPrefabs.Count > 0 && ++currentTrailIndex >= trailPrefabs.Count)
        {
            currentTrailIndex = 0;
        }

        if(currentTrailIndex < trailPrefabs.Count)
        {
            if(currentTrail != null)
            {
                Destroy(currentTrail.gameObject);
            }

            currentTrail = (Instantiate(trailPrefabs[currentTrailIndex]) as GameObject).GetComponent<SplineTrailRenderer>();
            trailRef.ImitateTrail(currentTrail);
        }
    }
예제 #8
0
    void SwitchTrail()
    {
        if (trailPrefabs.Count > 0 && ++currentTrailIndex >= trailPrefabs.Count)
        {
            currentTrailIndex = 0;
        }

        if (currentTrailIndex < trailPrefabs.Count)
        {
            if (currentTrail != null)
            {
                Destroy(currentTrail);
            }

            currentTrail = (Instantiate(trailPrefabs[currentTrailIndex]) as GameObject).GetComponent <SplineTrailRenderer>();
            trailRef.ImitateTrail(currentTrail);
        }
    }
예제 #9
0
    // Update is called once per frame
    void LateUpdate()
    {
        /*
         *      if (Input.GetMouseButtonDown (0)) {
         *              startMousePos = Input.mousePosition;
         *
         *              hit = new RaycastHit ();
         *              if (!Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, Mathf.Infinity))
         *                      return;
         *
         *              if (hit.collider != this.GetComponent<Collider> ())
         *                      return;
         *
         *              playerSelected = true;
         *              if (trailReference != null) {
         *                      trailReference.Clear ();
         *                      Destroy (trailReference.gameObject);
         *                      trailReference = null;
         *              }
         *              //ownerBip.getCameraControler().allowRotation = false;
         *      } else if (Input.GetMouseButton (0) && playerSelected) {
         *              currMousePos = Input.mousePosition;
         *
         *              if (trailReference == null && (currMousePos - startMousePos).magnitude > 20) {
         *                      distance = 0;
         *                      trailReference = ((GameObject)Instantiate (motionPathPrefeb, this.transform.position, Quaternion.identity)).GetComponent<SplineTrailRenderer> ();
         *                      trailReference.maxLength = 0;
         *
         *                      dragAxis = Vector3.Cross (Vector3.up, (Camera.main.transform.position - this.transform.position)).normalized;
         *                      Vector3 n = Vector3.Cross (dragAxis, Vector3.up).normalized;
         *                      dragPlane = new Plane (n, this.transform.position);
         *              } else if (trailReference != null) {
         *
         *                      trailReference.maxLength = trailReference.spline.Length();
         *
         *                      float PLDis = 0;
         *                      Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         *                      dragPlane.Raycast(ray, out PLDis);
         *
         *                      trailReference.transform.position = ray.GetPoint(PLDis);
         *              }
         *      }else if(Input.GetMouseButtonUp(0)){
         *              playerSelected = false;
         *              //ownerBip.getCameraControler().allowRotation = true;
         *      }*/

        if (trailReference != null && trailReference.maxLength > 0.1f)
        {
            float length = trailReference.spline.Length();
            distance = Mathf.Clamp(distance + GUIManager.instance.followSpeed.value * Time.deltaTime, 0, length);
            trailReference.maxLength = Mathf.Max(length - distance + 0.5f, 0);
            Vector3 tpos = trailReference.spline.FindPositionFromDistance(distance);
            ownerBip.setHandTouchState(HandTouchState.touch, null, tpos, (HandTouchMode)touchIkID);
            //ownerBip.setLookState (HeadLookState.lookTarget, null, tpos);

            if (trailReference.maxLength <= 0.5f)
            {
                trailReference.Clear();
                Destroy(trailReference.gameObject);
                trailReference = null;

                ownerBip.setHandTouchState(HandTouchState.touch, null, Vector3.zero, (HandTouchMode)touchIkID);
                //ownerBip.setLookState (HeadLookState.none, null, Vector3.zero);
            }
        }
    }