void Awake() { Actor = GetComponent <Actor>(); NN = GetComponent <MANN>(); MotionEditing = GetComponent <MotionEditing>(); TargetDirection = new Vector3(transform.forward.x, 0f, transform.forward.z); TargetVelocity = Vector3.zero; PID = new PIDController(0.2f, 0.8f, 0f); Positions = new Vector3[Actor.Bones.Length]; Forwards = new Vector3[Actor.Bones.Length]; Ups = new Vector3[Actor.Bones.Length]; Velocities = new Vector3[Actor.Bones.Length]; Trajectory = new Trajectory(Points, Controller.GetNames(), transform.position, TargetDirection); if (Controller.Styles.Length > 0) { for (int i = 0; i < Trajectory.Points.Length; i++) { Trajectory.Points[i].Styles[0] = 1f; } } for (int i = 0; i < Actor.Bones.Length; i++) { Positions[i] = Actor.Bones[i].Transform.position; Forwards[i] = Actor.Bones[i].Transform.forward; Ups[i] = Actor.Bones[i].Transform.up; Velocities[i] = Vector3.zero; } if (NN.Parameters == null) { Debug.Log("No parameters saved."); return; } NN.LoadParameters(); }
void Awake() { Actor = GetComponent <Actor>(); NN = GetComponent <MANN>(); MotionEditing = GetComponent <MotionEditing>(); TargetDirection = new Vector3(transform.forward.x, 0f, transform.forward.z); TargetVelocity = Vector3.zero; PID = new PIDController(0.2f, 0.8f, 0f); Positions = new Vector3[Actor.Bones.Length]; Forwards = new Vector3[Actor.Bones.Length]; Ups = new Vector3[Actor.Bones.Length]; Velocities = new Vector3[Actor.Bones.Length]; Trajectory = new Trajectory(Points, Controller.GetNames(), transform.position, TargetDirection); if (Controller.Styles.Length > 0) { for (int i = 0; i < Trajectory.Points.Length; i++) { Trajectory.Points[i].Styles[0] = 1f; } } for (int i = 0; i < Actor.Bones.Length; i++) { Positions[i] = Actor.Bones[i].Transform.position; Forwards[i] = Actor.Bones[i].Transform.forward; Ups[i] = Actor.Bones[i].Transform.up; Velocities[i] = Vector3.zero; } if (NN.Parameters == null) { Debug.Log("No parameters saved."); return; } NN.LoadParameters(); string time = DateTime.Now.ToString(@"MMdd HH-mm-ss"); file = new System.IO.StreamWriter(@".\skeleton_" + time + "_.txt", true); }
void Awake() { Actor = GetComponent <Actor>(); NN = GetComponent <MANN>(); MotionEditing = GetComponent <MotionPostprocessing>(); if (AnimationAuthoring == null) { Debug.Log("No AnimationAuthoring linked!"); return; } if (AnimationAuthoring.ControlPoints.Count <= 0) { Debug.Log("No Controlpoints defined."); return; } AnimationAuthoring.GenerateLookUpPoints(AnimationAuthoring.TimeDelta); AnimationAuthoring.CreateCP = false; Point p0 = AnimationAuthoring.GetLookUpPoint(0); Point p1 = AnimationAuthoring.GetLookUpPoint(AnimationAuthoring.TimeDelta); Vector3 direction = (p1.GetPosition() - p0.GetPosition()).normalized; TargetDirection = direction; TargetVelocity = p0.GetVelocity(); Positions = new Vector3[Actor.Bones.Length]; Forwards = new Vector3[Actor.Bones.Length]; Ups = new Vector3[Actor.Bones.Length]; Velocities = new Vector3[Actor.Bones.Length]; StyleNames = new string[] { "Idle", "Move", "Jump", "Sit", "Stand", "Lie", "Sneak", "Eat", "Hydrate" }; Trajectory = new Trajectory(Points, StyleNames, AnimationAuthoring.ControlPoints[0].Transform.position, TargetDirection, AnimationAuthoring); Actor.transform.position = AnimationAuthoring.ControlPoints[0].Transform.position; Actor.transform.LookAt(AnimationAuthoring.ControlPoints[0].Transform); //Compute Posture for (int i = 0; i < Actor.Bones.Length; i++) { Positions[i] = Actor.Bones[i].Transform.position; Forwards[i] = Actor.Bones[i].Transform.forward; Ups[i] = Actor.Bones[i].Transform.up; Velocities[i] = Vector3.zero; } if (StyleNames.Length > 0) { for (int i = 0; i < Trajectory.Points.Length; i++) { //IDLE Trajectory.Points[i].Styles[0] = 1f; } for (int i = 0; i < Trajectory.Points.Length; i++) { float timestamp = 0 + ((i - RootPointIndex) / 60f); //Set Direction to next point Point p = AnimationAuthoring.GetLookUpPoint(timestamp); Point p2 = AnimationAuthoring.GetLookUpPoint(timestamp + AnimationAuthoring.TimeDelta); Vector3 dir = (p2.GetPosition() - p.GetPosition()).normalized; p.SetDirection(dir); Trajectory.Points[i].SetDirection(p.GetDirection().normalized); Trajectory.Points[i].SetVelocity(p.GetVelocity()); Trajectory.Points[i].SetPosition(p.GetPosition()); Trajectory.Points[i].SetSpeed(p.GetSpeed()); Trajectory.Points[i].TerrainHeight = p.GetPosition().y; } } if (NN.Parameters == null) { Debug.Log("No parameters saved."); return; } //Trigger callback once to init transforms for (int i = 0; i < AnimationAuthoring.ControlPoints.Count; i++) { if (AnimationAuthoring.ControlPoints[i].GetTransform().hasChanged) { AnimationAuthoring.ControlPoints[i].GetTransform().hasChanged = false; } } NN.LoadParameters(); }