Пример #1
0
        /*
         * Recalculate reach cones if the Limit Points have changed
         * */
        public void BuildReachCones()
        {
            smoothIterations = Mathf.Clamp(smoothIterations, 0, 3);

            // Make another array for the points so that they could be smoothed without changing the initial points
            P = new Vector3[points.Length];
            for (int i = 0; i < points.Length; i++)
            {
                P[i] = points[i].point.normalized;
            }

            for (int i = 0; i < smoothIterations; i++)
            {
                P = SmoothPoints();
            }

            // Calculating the reach cones
            reachCones = new ReachCone[P.Length];
            for (int i = 0; i < reachCones.Length - 1; i++)
            {
                reachCones[i] = new ReachCone(Vector3.zero, axis.normalized, P[i], P[i + 1]);
            }

            reachCones[P.Length - 1] = new ReachCone(Vector3.zero, axis.normalized, P[P.Length - 1], P[0]);

            for (int i = 0; i < reachCones.Length; i++)
            {
                reachCones[i].Calculate();
            }
        }
        /// <summary>
        /// Rebuild the reach codes when the limits change
        /// </summary>
        public void BuildReachCones()
        {
            _SmoothingIterations = Mathf.Clamp(_SmoothingIterations, 0, 3);

            // Use the original boundery points as a base and them smooth
            // by doubling the points (each iteration)
            mReachPoints = new Vector3[BoundaryPoints.Count];
            for (int i = 0; i < BoundaryPoints.Count; i++)
            {
                mReachPoints[i] = BoundaryPoints[i].normalized;
            }

            // Smooth for each iteration. The increase is quadradic,
            // so be careful about doing this too foten.
            for (int i = 0; i < _SmoothingIterations; i++)
            {
                mReachPoints = SmoothReachPoints();
            }

            // Use the newly smoothed points to create the condes
            mReachCones = new ReachCone[mReachPoints.Length];
            for (int i = 0; i < mReachCones.Length - 1; i++)
            {
                //mReachCones[i] = new ReachCone(Vector3.zero, mBone.BoneForward.normalized, mReachPoints[i], mReachPoints[i + 1]);
                mReachCones[i] = new ReachCone(Vector3.zero, Vector3.forward, mReachPoints[i], mReachPoints[i + 1]);
            }

            // This last cone closes the whole system
            //mReachCones[mReachPoints.Length - 1] = new ReachCone(Vector3.zero, mBone.BoneForward.normalized, mReachPoints[mReachPoints.Length - 1], mReachPoints[0]);
            mReachCones[mReachPoints.Length - 1] = new ReachCone(Vector3.zero, Vector3.forward, mReachPoints[mReachPoints.Length - 1], mReachPoints[0]);

            // Finally, pre-process the cones since some calculations only need to be done once
            for (int i = 0; i < mReachCones.Length; i++)
            {
                mReachCones[i].PreProcess();
            }
        }
Пример #3
0
		/*
		 * Recalculate reach cones if the Limit Points have changed
		 * */
		public void BuildReachCones() {
			smoothIterations = Mathf.Clamp(smoothIterations, 0, 3);
			
			// Make another array for the points so that they could be smoothed without changing the initial points
			P = new Vector3[points.Length];
			for (int i = 0; i < points.Length; i++) P[i] = points[i].point.normalized;
			
			for (int i = 0; i < smoothIterations; i++) P = SmoothPoints();
			
			// Calculating the reach cones
			reachCones = new ReachCone[P.Length]; 
			for (int i = 0; i < reachCones.Length - 1; i++) {
				reachCones[i] = new ReachCone(Vector3.zero, axis.normalized, P[i], P[i + 1]);
			}
			
			reachCones[P.Length - 1] = new ReachCone(Vector3.zero, axis.normalized, P[P.Length - 1], P[0]);
			
			for (int i = 0; i < reachCones.Length; i++) reachCones[i].Calculate();
		}