public override void OnInspectorGUI() { MMMotionData motionData = (MMMotionData)target; GUILayout.Label("Framerate: " + motionData.config.frameRate); GUILayout.Space(10f); GUILayout.Label("Trajectory ponts: " + motionData.config.trajectoryTimePoints.Count); foreach (var point in motionData.config.trajectoryTimePoints) { GUILayout.Label(point + "s"); } GUILayout.Space(10f); GUILayout.Label("Tracked joints: " + motionData.config.trackedBones.Count); foreach (var joint in motionData.config.trackedBones) { GUILayout.Label(joint.ToString()); } GUILayout.Space(10f); GUILayout.Label("Animation clips: " + motionData.satelliteData.Length); foreach (var data in motionData.satelliteData) { GUILayout.Label("Animation name: " + data.Value + ". Start frame: " + data.Key); } GUILayout.Space(10f); GUILayout.Label("Poses: " + motionData.Length); }
public void PreProcess() { Debug.Log("Creating Asset"); string path = "Assets/Resources/MotionData"; if (!AssetDatabase.IsValidFolder(path)) { if (!AssetDatabase.IsValidFolder("Assets/Resources")) { AssetDatabase.CreateFolder("Assets", "Resources"); } AssetDatabase.CreateFolder("Assets/Resources", "MotionData"); } //AnimationScriptableObjectContainer w = new AnimationScriptableObjectContainer(); MMMotionData motionAsset = CreateInstance <MMMotionData>(); motionAsset = CreateOrReplaceAsset(motionAsset, path + "/MotionData.asset"); int clipsLength = 0; List <AnimLookup> lookupList = new List <AnimLookup>(); List <MotionFrameInfo> frameList = new List <MotionFrameInfo>(); foreach (var mmAnimationClip in mmAnimationClips) { // Create satellite data for animation lookup lookupList.Add(new AnimLookup(clipsLength, mmAnimationClip.animClip.name)); clipsLength += mmAnimationClip.Length; //Create combined array I guess.. for (int i = 0; i < mmAnimationClip.Length; i++) { Vector3[] positionPoints = new Vector3[config.trajectoryTimePoints.Count]; Vector3[] forwardPoints = new Vector3[config.trajectoryTimePoints.Count]; bool isInvalid = false; for (int j = 0; j < config.trajectoryTimePoints.Count; j++) { int projectedIndex = Mathf.RoundToInt(config.trajectoryTimePoints[j] * config.frameRate) + i; if (projectedIndex < mmAnimationClip.Length && projectedIndex >= 0) { positionPoints[j] = mmAnimationClip .baseTrajectory[i].rootWorldToLocalMatrix.MultiplyPoint3x4(mmAnimationClip .baseTrajectory[ Mathf.RoundToInt(config.trajectoryTimePoints[j] * config.frameRate) + i] .position); forwardPoints[j] = mmAnimationClip .baseTrajectory[i].rootWorldToLocalMatrix.MultiplyVector(mmAnimationClip .baseTrajectory[ Mathf.RoundToInt(config.trajectoryTimePoints[j] * config.frameRate) + i] .forward); } else { isInvalid = true; } } if (isInvalid) { clipsLength--; continue; } List <Vector3> charSpacePositions = new List <Vector3>(); List <Vector3> charSpaceVelocities = new List <Vector3>(); for (int j = 0; j < mmAnimationClip.basePoses[i].jointPositions.Count; j++) { Vector3 tempPos = mmAnimationClip.baseTrajectory[i].rootWorldToLocalMatrix .MultiplyVector(mmAnimationClip.basePoses[i].jointPositions[j]); Vector3 tempVel = mmAnimationClip.baseTrajectory[i].rootWorldToLocalMatrix .MultiplyVector(mmAnimationClip.basePoses[i].jointVelocities[j]); charSpacePositions.Add(tempPos); charSpaceVelocities.Add(tempVel); } TrajectoryInfo tempTraj = new TrajectoryInfo(positionPoints, forwardPoints); Pose tempPose = new Pose(charSpacePositions, charSpaceVelocities); frameList.Add(new MotionFrameInfo(tempTraj, tempPose, 0)); } } /*motionAsset.trajectoryInfo = trajectories; * motionAsset.poseInfo = poses;*/ motionAsset.config = config; motionAsset.Length = clipsLength; motionAsset.frameInfo = frameList.ToArray(); motionAsset.satelliteData = lookupList.ToArray(); AssetDatabase.SaveAssets(); CreateAnimatorController(); }