public void Run(CommandArgs e) //命令插件核心,按下按钮后执行的部分 { MessageBox.Show(ApplicationForm, "这是一次倒立的实践!"); BoneCollection bones = Scene.ActiveModel.Bones; for (int i = 0; i < bones.Count; i++) { if (bones[i].Name != "全ての親") { continue; } MotionLayerCollection layers = bones[i].Layers; for (int i2 = 0; i2 < layers.Count; i2++) { MotionFrameCollection frameDates = layers[i2].Frames; for (int f = 0; f < 30; f++) { MotionFrameData data = new MotionFrameData(); data.FrameNumber = f * 10; data.Quaternion = Quaternion.RotationAxis(new Vector3(0, 0, 1), 6 * f); //Vector3 vector = frameDatas.GetFrame(f * 10).Position; //vector.Y += 10; frameDates.AddKeyFrame(data); } } } }
void ProcessLayer(Random r, long beginFrame, long endFrame, MotionFrameCollection frames, bool isPositionLocal, bool isRotationLocal, Bone localBone) { var newKeyFrames = ProcessFrames(r, beginFrame, endFrame, keyFrameInterval, noiseValueInterval, new HashSet <long>(frames.Where(_ => _.Selected).Select(_ => _.FrameNumber))) .Select(_ => { var baseFrame = frames.GetFrame(_.Key); var localRotation = GetLocalRotation(isRotationLocal, localBone, _.Value.RotationWidth, _.Value.RotationQuaternion); baseFrame.FrameNumber = Math.Max(_.Key + GetNoise(r, keyShiftWidth), 0); baseFrame.Quaternion = isRotationLocal ? Quaternion.Multiply(baseFrame.Quaternion, _.Value.RotationQuaternion) : Quaternion.Multiply(_.Value.RotationQuaternion, baseFrame.Quaternion); baseFrame.Position += isPositionLocal ? GetLocalPosition(isPositionLocal, localBone, _.Value.PositionWidth, baseFrame.Quaternion) : _.Value.PositionWidth; baseFrame.Selected = true; return(baseFrame); }) .ToArray(); foreach (var i in frames.Where(_ => _.Selected)) { frames.RemoveKeyFrame(i.FrameNumber); } frames.AddKeyFrame(newKeyFrames.ToLookup(_ => _.FrameNumber) .Select(_ => _.Last()) .ToList()); }
static void ProcessMotionFrames(long beginFrame, long endFrame, MotionFrameCollection collection, List <MotionFrameData> selectedFrames) { if (!selectedFrames.Any()) { return; } foreach (var j in selectedFrames) { collection.RemoveKeyFrame(j.FrameNumber); } foreach (var j in RevertFrames ( selectedFrames, beginFrame, endFrame, _ => _.FrameNumber, (_, value) => new MotionFrameData(value, _.Position, _.Quaternion), _ => new[] { _.InterpolRA, _.InterpolRB, _.InterpolXA, _.InterpolXB, _.InterpolYA, _.InterpolYB, _.InterpolZA, _.InterpolZB }, (_, value) => new MotionFrameData(_.FrameNumber, _.Position, _.Quaternion) { InterpolRA = value[0], InterpolRB = value[1], InterpolXA = value[2], InterpolXB = value[3], InterpolYA = value[4], InterpolYB = value[5], InterpolZA = value[6], InterpolZB = value[7], Selected = true, } )) { collection.AddKeyFrame((MotionFrameData)j); } }
void ProcessLayer(Random r, long beginFrame, long endFrame, MotionFrameCollection frames, bool isPositionLocal, bool isRotationLocal, Bone localBone) { var newKeyFrames = ProcessFrames(r, beginFrame, endFrame, keyFrameInterval, noiseValueInterval, new HashSet<long>(frames.Where(_ => _.Selected).Select(_ => _.FrameNumber))) .Select(_ => { var baseFrame = frames.GetFrame(_.Key); var localRotation = GetLocalRotation(isRotationLocal, localBone, _.Value.RotationWidth, _.Value.RotationQuaternion); baseFrame.FrameNumber = Math.Max(_.Key + GetNoise(r, keyShiftWidth), 0); baseFrame.Quaternion = isRotationLocal ? Quaternion.Multiply(baseFrame.Quaternion, _.Value.RotationQuaternion) : Quaternion.Multiply(_.Value.RotationQuaternion, baseFrame.Quaternion); baseFrame.Position += isPositionLocal ? GetLocalPosition(isPositionLocal, localBone, _.Value.PositionWidth, baseFrame.Quaternion) : _.Value.PositionWidth; baseFrame.Selected = true; return baseFrame; }) .ToArray(); foreach (var i in frames.Where(_ => _.Selected)) frames.RemoveKeyFrame(i.FrameNumber); frames.AddKeyFrame(newKeyFrames.ToLookup(_ => _.FrameNumber) .Select(_ => _.Last()) .ToList()); }