Ejemplo n.º 1
0
        protected override Vector3 UpdateTarget (RichFunnel fn) {

            Matrix4x4 m = graph.GetMatrix ();
            Matrix4x4 mi = m.inverse;


            Debug.DrawRay (m.MultiplyPoint3x4 (tr.position), Vector3.up*2, Color.red);
            Debug.DrawRay (mi.MultiplyPoint3x4 (tr.position), Vector3.up*2, Color.green);

            buffer.Clear ();

            /* Current position. We read and write to tr.position as few times as possible since doing so
		 * is much slower than to read and write from/to a local variable
		 */
            Vector3 position = tr.position;
            bool requiresRepath;

            // Update, but first convert our position to graph space, then convert the result back to world space
            var positionInGraphSpace = m.MultiplyPoint3x4 (position);
            positionInGraphSpace = fn.Update (positionInGraphSpace, buffer, 2, out lastCorner, out requiresRepath);
            position = mi.MultiplyPoint3x4 (positionInGraphSpace);

            Debug.DrawRay ( position, Vector3.up*3, Color.black );

            // convert the result to world space from graph space
            for ( int i=0; i < buffer.Count; i++ ) {
                buffer[i] = mi.MultiplyPoint3x4 ( buffer[i] );
                Debug.DrawRay ( buffer[i], Vector3.up*3, Color.yellow );
            }

            if (requiresRepath && !waitingForPathCalc) {
                UpdatePath ();
            }
		
            return position;
        }
Ejemplo n.º 2
0
		protected virtual Vector3 UpdateTarget ( RichFunnel fn ) {
			buffer.Clear ();
			/* Current position. We read and write to tr.position as few times as possible since doing so
			 * is much slower than to read and write from/to a local variable
			 */
			Vector3 position = tr.position;
			bool requiresRepath;
			position = fn.Update (position, buffer, 2, out lastCorner, out requiresRepath);
	
			if (requiresRepath && !waitingForPathCalc) {
				UpdatePath ();
			}
	
			return position;
		}