public static IOAnimation ImportAnimation(string filePath, ImportSettings settings) { var anim = new MayaAnim(); anim.Open(filePath); return(anim.GetAnimation()); }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <returns></returns> public IOScene GetScene(string filePath) { IOScene scene = new IOScene(); scene.Animations.Add(MayaAnim.ImportAnimation(filePath, new ImportSettings())); return(scene); }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <returns></returns> public void ExportScene(IOScene scene, string filePath, ExportSettings settings) { if (scene.Models.Count == 0) { throw new Exception($"Failed to export animation! Model must have a skeleton to export!"); } MayaAnim.ExportAnimation(filePath, settings, scene.Animations[0], scene.Models[0].Skeleton); }
private float GetOutputValue(MayaAnim anim, AnimData data, float value) { if (data.output == OutputType.angular) { if (anim.header.angularUnit == "deg") { return((float)(value * Math.PI / 180)); } } return(value); }
static MayaAnim CreateMayaAnimation(ExportSettings settings, IOAnimation animation, IOSkeleton skeleton) { MayaAnim anim = new MayaAnim(); anim.header.startTime = 0; anim.header.endTime = animation.GetFrameCount(); // get bone order List <IOBone> BonesInOrder = getBoneTreeOrder(skeleton); if (settings.MayaAnim2015) { BonesInOrder = BonesInOrder.OrderBy(f => f.Name, StringComparer.Ordinal).ToList(); } foreach (IOBone b in BonesInOrder) { AnimBone animBone = new AnimBone() { name = b.Name }; anim.Bones.Add(animBone); var group = animation.Groups.FirstOrDefault(x => x.Name.Equals(b.Name)); if (group == null) { continue; } foreach (var track in group.Tracks) { switch (track.ChannelType) { case IOAnimationTrackType.PositionX: AddAnimData(settings, animBone, track, ControlType.translate, TrackType.translateX); break; case IOAnimationTrackType.PositionY: AddAnimData(settings, animBone, track, ControlType.translate, TrackType.translateY); break; case IOAnimationTrackType.PositionZ: AddAnimData(settings, animBone, track, ControlType.translate, TrackType.translateZ); break; case IOAnimationTrackType.RotationEulerX: AddAnimData(settings, animBone, track, ControlType.rotate, TrackType.rotateX); break; case IOAnimationTrackType.RotationEulerY: AddAnimData(settings, animBone, track, ControlType.rotate, TrackType.rotateY); break; case IOAnimationTrackType.RotationEulerZ: AddAnimData(settings, animBone, track, ControlType.rotate, TrackType.rotateZ); break; case IOAnimationTrackType.ScaleX: AddAnimData(settings, animBone, track, ControlType.scale, TrackType.scaleX); break; case IOAnimationTrackType.ScaleY: AddAnimData(settings, animBone, track, ControlType.scale, TrackType.scaleY); break; case IOAnimationTrackType.ScaleZ: AddAnimData(settings, animBone, track, ControlType.scale, TrackType.scaleZ); break; } } } return(anim); }