public void AnimateClip(TimelineClip cpa, GameObject ato, ClipInfo CI) { cpa.start = CI.start; cpa.duration = CI.duration; cpa.displayName = CI.display; var controlAnim = cpa.asset as ControlPlayableAsset; //controlAnim.postPlayback = ActivationControlPlayable.PostPlaybackState.Active; AnimateBind(controlAnim, ato); }
public void OrientClip(GameObject go, Vector3 goalPos, ClipInfo CI) { var orientClip = steerTrack.CreateClip <OrientToObjectAsset>(); orientClip.start = CI.start; orientClip.duration = CI.duration; orientClip.displayName = CI.display; OrientToObjectAsset orient_clip = orientClip.asset as OrientToObjectAsset; OrientBind(orient_clip, go, goalPos); }
public void SimpleToLerpClip(GameObject agent, Transform goalPos, ClipInfo CI) { var lerpClip = lerpTrack.CreateClip <LerpToMoveObjectAsset>(); lerpClip.start = CI.start; lerpClip.duration = CI.duration; lerpClip.displayName = string.Format("SimpleLerp {0}", goalPos.name); LerpToMoveObjectAsset lerp_clip = lerpClip.asset as LerpToMoveObjectAsset; TransformToBind(lerp_clip, agent, goalPos); }
public void SteerClip(GameObject go, Vector3 startPos, Vector3 goalPos, bool depart, bool arrival, bool isMaster, ClipInfo CI) { var steerClip = steerTrack.CreateClip <SteeringAsset>(); steerClip.start = CI.start; steerClip.duration = CI.duration; steerClip.displayName = CI.display; SteeringAsset steer_clip = steerClip.asset as SteeringAsset; SteerBind(steer_clip, go, startPos, goalPos, depart, arrival, isMaster); }
public ClipInfo ProcessInstruction(GameObject goWithAction, string instruction, List <GameObject> terms, double startTime, double duration) { var instructionParts = instruction.Split(' '); var instructionType = instructionParts[0]; var CI = new ClipInfo(this.playableDirector, startTime, duration, instruction); if (instructionType.Equals("play")) { // implies only 1 argument, unless refactored later var agent = terms[Int32.Parse(instructionParts[1])]; // Clones action and sets binding var goClone = SetAgentToGenericAction(goWithAction, agent); var controlTrackClip = ctrack.CreateDefaultClip(); CI.display = string.Format("playing timeline {0}", goWithAction.name); AnimateClip(controlTrackClip, goClone, CI); } if (instructionType.Equals("attach")) { var parent = terms[Int32.Parse(instructionParts[1])]; var child = terms[Int32.Parse(instructionParts[2])]; var attachClip = attachTrack.CreateClip <AttachToParent>(); attachClip.start = CI.start; attachClip.duration = CI.duration; attachClip.displayName = string.Format("attach parent={0} child={1}", parent.name, child.name); AttachToParent aClip = attachClip.asset as AttachToParent; AttachBind(aClip, parent, child); } if (instructionType.Equals("dettach")) { var child = terms[Int32.Parse(instructionParts[1])]; var dettachClip = attachTrack.CreateClip <DettachToParent>(); dettachClip.start = CI.start; dettachClip.duration = CI.duration; dettachClip.displayName = string.Format("dettach child={0}", child.name); DettachToParent aClip = dettachClip.asset as DettachToParent; DettachBind(aClip, child); } if (instructionType.Equals("transform")) { // parse 5 argument instructions var agent = terms[Int32.Parse(instructionParts[1])]; var origin = terms[Int32.Parse(instructionParts[2])]; var originHeight = float.Parse(instructionParts[3]); var destination = terms[Int32.Parse(instructionParts[4])]; var destinationHeight = float.Parse(instructionParts[5]); // Creating new transforms with custom heights var originTransform = new GameObject(); originTransform.transform.position = new Vector3(origin.transform.position.x, originHeight, origin.transform.position.z); var destinationTransform = new GameObject(); destinationTransform.transform.position = new Vector3(destination.transform.position.x, destinationHeight, destination.transform.position.z); SimpleLerpClip(agent, originTransform.transform, destinationTransform.transform, CI); } if (instructionType.Equals("steer")) { var agent = terms[Int32.Parse(instructionParts[1])]; var source = terms[Int32.Parse(instructionParts[2])]; var sink = terms[Int32.Parse(instructionParts[3])]; var displayName = string.Format("{0} {1} {2} {3}", instructionType, agent.name, source.name, sink.name); CI.display = displayName; // Initiate the Steering capability of the agent var DS_TC = agent.GetComponent <DynoBehavior_TimelineControl>(); DS_TC.InitiateExternally(); var steerStart = new Vector3(source.transform.position.x, agent.transform.position.y, source.transform.position.z); var steerFinish = new Vector3(sink.transform.position.x, agent.transform.position.y, sink.transform.position.z); // arg 1 is agent, arg 2 is source, arg 3 is destination SteerClip(agent, steerStart, steerFinish, true, true, true, CI); } if (instructionType.Equals("orient")) { var agent = terms[Int32.Parse(instructionParts[1])]; var destination = terms[Int32.Parse(instructionParts[2])]; // Initiate the Steering capability of the agent (if not already set; fine if redundant) var DS_TC = agent.GetComponent <DynoBehavior_TimelineControl>(); DS_TC.InitiateExternally(); // var test = destination.transform.position + destination.transform.localPosition; OrientClip(agent, destination.transform.position, CI); } //if (instructionType.Equals("scale")) //{ // var rescale = new Vector3(float.Parse(instructionParts[2]), float.Parse(instructionParts[3]), float.Parse(instructionParts[4])); // var agent = terms[Int32.Parse(instructionParts[1])]; // var destination = new Trans(agent.transform); // destination.localScale = rescale; // SimpleLerpClip(agent, destination, CI); //} //else if (instructionType.Equals("takePosition")) //{ // // argument 1 is to take position of second // var destination = terms[Int32.Parse(instructionParts[2])].transform; // SimpleLerpClip(terms[1], new Trans(destination), CI); //} //else if (instructionType.Equals("addPosition")) //{ // var agent = terms[Int32.Parse(instructionParts[1])]; // // adds vector3 // var addition = new Vector3(float.Parse(instructionParts[2]), float.Parse(instructionParts[3]), float.Parse(instructionParts[4])); // var destination = new Trans(agent.transform); // destination.position += addition; // SimpleLerpClip(agent, destination, CI); //} //else if (instructionType.Equals("parent")) //{ //} //else if (instructionType.Equals("deparent")) //{ //} //else if (instructionType.Equals("steer")) //{ // // noninstantaneous... //} //else //{ // Debug.Log(string.Format("instruction type {0} not yet written.", instructionType)); // throw new System.Exception(); //} return(CI); }