private void WriteBoneFrame([NotNull] VmdBoneFrame frame) { WriteString(frame.Name, 15); _writer.Write(frame.FrameIndex); _writer.Write(frame.Position); _writer.Write(frame.Rotation); WriteMultidimArray(frame.Interpolation); }
private void ReadBoneFrames([NotNull] VmdMotion motion) { var frameCount = _reader.ReadInt32(); var frames = new VmdBoneFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadBoneFrame(); } motion.BoneFrames = frames; }
public static VmdBoneFrame CopyWithDifferentFrameIndex([NotNull] this VmdBoneFrame thisFrame, int newFrameIndex) { var frame = new VmdBoneFrame(); frame.Name = thisFrame.Name; frame.FrameIndex = newFrameIndex; Buffer.BlockCopy(thisFrame.Interpolation, 0, frame.Interpolation, 0, thisFrame.Interpolation.Length); frame.Position = thisFrame.Position; frame.Rotation = thisFrame.Rotation; return(frame); }
private VmdBoneFrame ReadBoneFrame() { var frame = new VmdBoneFrame(); frame.Name = ReadString(15); frame.FrameIndex = _reader.ReadInt32(); frame.Position = _reader.ReadVector3(); frame.Rotation = _reader.ReadQuaternion(); ReadMultiDimArray(frame.Interpolation); return(frame); }
public static VmdBoneFrame LerpTo([NotNull] this VmdBoneFrame thisFrame, [NotNull] VmdBoneFrame nextFrame, float t, float frameRateRatio = 1) { Debug.Assert(thisFrame.Name == nextFrame.Name, "thisFrame.Name == nextFrame.Name"); t = MathHelper.Clamp(t, 0, 1); var frame = new VmdBoneFrame(); frame.Name = thisFrame.Name; frame.FrameIndex = (int)(MathHelper.Lerp(thisFrame.FrameIndex, nextFrame.FrameIndex, t) * frameRateRatio); Buffer.BlockCopy(thisFrame.Interpolation, 0, frame.Interpolation, 0, thisFrame.Interpolation.Length); frame.Position = Vector3.Lerp(thisFrame.Position, nextFrame.Position, t); frame.Rotation = Quaternion.Lerp(thisFrame.Rotation, nextFrame.Rotation, t); return(frame); }
private IReadOnlyList <VmdBoneFrame> CreateBoneFrames([NotNull] IBodyAnimationSource bodyMotionSource, [NotNull] PrettyAvatar avatar, [NotNull] PmxModel pmx) { var boneLookup = new BoneLookup(_conversionConfig); var mltdHierarchy = boneLookup.BuildBoneHierarchy(avatar); var pmxHierarchy = boneLookup.BuildBoneHierarchy(pmx); if (_conversionConfig.AppendIKBones || _conversionConfig.AppendEyeBones) { throw new NotSupportedException("Character motion frames generation (from MLTD) is not supported when appending bones (eyes and/or IK) is enabled."); } else { Debug.Assert(mltdHierarchy.Count == pmxHierarchy.Count, "Hierarchy number should be equal between MLTD and MMD."); } foreach (var mltdBone in mltdHierarchy) { mltdBone.Initialize(); } foreach (var pmxBone in pmxHierarchy) { pmxBone.Initialize(); } var animation = bodyMotionSource.Convert(); var boneCount = mltdHierarchy.Count; var animatedBoneCount = animation.BoneCount; var keyFrameCount = animation.KeyFrames.Count; { void MarkNamedBone(string name) { var bone = pmx.Bones.FirstOrDefault(b => b.Name == name); if (bone != null) { bone.IsMltdKeyBone = true; } else { Debug.Print("Warning: trying to mark bone {0} as MLTD key bone but the bone is missing from the model.", name); } } var names1 = animation.KeyFrames.Take(animatedBoneCount) .Select(kf => kf.Path).ToArray(); var names = names1.Select(boneLookup.GetVmdBoneNameFromBonePath).ToArray(); // Mark MLTD key bones. foreach (var name in names) { MarkNamedBone(name); } // Special cases MarkNamedBone("KUBI"); MarkNamedBone("頭"); } Debug.Assert(keyFrameCount % animatedBoneCount == 0, "keyFrameCount % animatedBoneCount == 0"); var iterationTimes = keyFrameCount / animatedBoneCount; var boneFrameList = new List <VmdBoneFrame>(); // Reduce memory pressure of allocating new delegates (see mltdHierarchy.FirstOrDefault(...)) var boneMatchPredicateCache = new Func <PmxBone, bool> [boneCount]; for (var j = 0; j < boneCount; j += 1) { var refBone = pmx.Bones[j]; boneMatchPredicateCache[j] = bone => bone.Name == refBone.Name; } // Cache `mltdBoneName`s so we don't have to compute them all in every iteration var boneNameCache = new Dictionary <string, string>(); // OK, now perform iterations for (var i = 0; i < iterationTimes; ++i) { if (_conversionConfig.Transform60FpsTo30Fps) { if (i % 2 == 1) { continue; } } var keyFrameIndexStart = i * animatedBoneCount; for (var j = 0; j < animatedBoneCount; ++j) { var keyFrame = animation.KeyFrames[keyFrameIndexStart + j]; string mltdBoneName; if (boneNameCache.ContainsKey(keyFrame.Path)) { mltdBoneName = boneNameCache[keyFrame.Path]; } else { if (keyFrame.Path.Contains("BODY_SCALE/")) { mltdBoneName = keyFrame.Path.Replace("BODY_SCALE/", string.Empty); } else { mltdBoneName = keyFrame.Path; } boneNameCache.Add(keyFrame.Path, mltdBoneName); } var targetBone = mltdHierarchy.SingleOrDefault(bone => bone.Name == mltdBoneName); if (targetBone == null) { //throw new ArgumentException("Bone not found."); continue; // Shika doesn't have the "POSITION" bone. } BoneNode transferredBone = null; foreach (var kv in BoneAttachmentMap) { if (kv.Key == mltdBoneName) { transferredBone = mltdHierarchy.SingleOrDefault(bone => bone.Name == kv.Value); if (transferredBone == null) { throw new ArgumentException(); } break; } } if (keyFrame.HasPositions) { // ReSharper disable once PossibleInvalidOperationException var x = keyFrame.PositionX.Value; // ReSharper disable once PossibleInvalidOperationException var y = keyFrame.PositionY.Value; // ReSharper disable once PossibleInvalidOperationException var z = keyFrame.PositionZ.Value; var t = new Vector3(x, y, z); t = t.FixUnityToOpenTK(); if (_conversionConfig.ScaleToVmdSize) { t = t * _scalingConfig.ScaleUnityToPmx; } targetBone.LocalPosition = t; //if (transferredBone != null) { // transferredBone.LocalPosition = t; //} } if (keyFrame.HasRotations) { // ReSharper disable once PossibleInvalidOperationException var x = keyFrame.AngleX.Value; // ReSharper disable once PossibleInvalidOperationException var y = keyFrame.AngleY.Value; // ReSharper disable once PossibleInvalidOperationException var z = keyFrame.AngleZ.Value; var q = UnityRotation.EulerDeg(x, y, z); q = q.FixUnityToOpenTK(); targetBone.LocalRotation = q; if (transferredBone != null) { transferredBone.LocalRotation = q; } } } foreach (var mltdBone in mltdHierarchy) { mltdBone.UpdateTransform(); } for (var j = 0; j < boneCount; ++j) { var pmxBone = pmxHierarchy[j]; var mltdBone = mltdHierarchy[j]; { var predicate = boneMatchPredicateCache[j]; var pb = pmx.Bones.FirstOrDefault(predicate); #if DEBUG if (pb == null) { // Lazy evaluation of the assertion message Debug.Assert(pb != null, $"PMX bone with the name \"{pmxBone.Name}\" should exist."); } #endif if (!pb.IsMltdKeyBone) { continue; } } var skinMatrix = mltdBone.SkinMatrix; var mPmxBindingPose = pmxBone.BindingPose; var mWorld = pmxBone.Parent?.WorldMatrix ?? Matrix4.Identity; // skinMatrix == inv(mPmxBindingPose) x mLocal x mWorld var mLocal = mPmxBindingPose * skinMatrix * mWorld.Inverted(); // Here, translation is in... world coords? WTF? var t = mLocal.ExtractTranslation(); var q = mLocal.ExtractRotation(); if (pmxBone.Parent != null) { t = t - (pmxBone.InitialPosition - pmxBone.Parent.InitialPosition); } int frameIndex; if (_conversionConfig.Transform60FpsTo30Fps) { frameIndex = i / 2; } else { frameIndex = i; } var vmdBoneName = boneLookup.GetVmdBoneNameFromBoneName(mltdBone.Path); var boneFrame = new VmdBoneFrame(frameIndex, vmdBoneName); boneFrame.Position = t; boneFrame.Rotation = q; boneFrameList.Add(boneFrame); pmxBone.LocalPosition = t; pmxBone.LocalRotation = q; pmxBone.UpdateTransform(); } } return(boneFrameList); }
private static IReadOnlyList <VmdBoneFrame> CreateBoneFrames([NotNull] CharacterImasMotionAsset bodyMotion, [NotNull] Avatar avatar, [NotNull] PmxModel pmx) { var mltdHierarchy = BoneUtils.BuildBoneHierarchy(avatar); var pmxHierarchy = BoneUtils.BuildBoneHierarchy(pmx); if (ConversionConfig.Current.AppendIKBones || ConversionConfig.Current.AppendEyeBones) { throw new NotSupportedException("Character motion frames generation (from MLTD) is not supported when appending bones (eyes and/or IK) is enabled."); } else { Debug.Assert(mltdHierarchy.Count == pmxHierarchy.Count, "Hierarchy number should be equal between MLTD and MMD."); } foreach (var mltdBone in mltdHierarchy) { mltdBone.Initialize(); } foreach (var pmxBone in pmxHierarchy) { pmxBone.Initialize(); } var animation = BodyAnimation.CreateFrom(bodyMotion); var boneCount = mltdHierarchy.Count; var animatedBoneCount = animation.BoneCount; var keyFrameCount = animation.KeyFrames.Count; do { void MarkNamedBone(string name) { var bone = pmx.Bones.FirstOrDefault(b => b.Name == name); if (bone != null) { bone.IsMltdKeyBone = true; } else { Debug.Print("Warning: trying to mark bone {0} as MLTD key bone but the bone is missing from the model.", name); } } var names1 = animation.KeyFrames.Take(animatedBoneCount) .Select(kf => kf.Path).ToArray(); var names = names1.Select(BoneUtils.GetVmdBoneNameFromBonePath).ToArray(); // Mark MLTD key bones. foreach (var name in names) { MarkNamedBone(name); } // Special cases MarkNamedBone("KUBI"); MarkNamedBone("頭"); } while (false); Debug.Assert(keyFrameCount % animatedBoneCount == 0, "keyFrameCount % animatedBoneCount == 0"); var iterationTimes = keyFrameCount / animatedBoneCount; var boneFrameList = new List <VmdBoneFrame>(); for (var i = 0; i < iterationTimes; ++i) { if (ConversionConfig.Current.Transform60FpsTo30Fps) { if (i % 2 == 1) { continue; } } var keyFrameIndexStart = i * animatedBoneCount; for (var j = 0; j < animatedBoneCount; ++j) { var keyFrame = animation.KeyFrames[keyFrameIndexStart + j]; var mltdBoneName = keyFrame.Path.Replace("BODY_SCALE/", string.Empty); var targetBone = mltdHierarchy.SingleOrDefault(bone => bone.Name == mltdBoneName); if (targetBone == null) { //throw new ArgumentException("Bone not found."); continue; // Shika doesn't have the "POSITION" bone. } BoneNode transferredBone = null; foreach (var kv in BoneAttachmentMap) { if (kv.Key == mltdBoneName) { transferredBone = mltdHierarchy.SingleOrDefault(bone => bone.Name == kv.Value); if (transferredBone == null) { throw new ArgumentException(); } break; } } if (keyFrame.HasPositions) { var x = keyFrame.PositionX.Value; var y = keyFrame.PositionY.Value; var z = keyFrame.PositionZ.Value; var t = new Vector3(x, y, z); t = t.FixUnityToOpenTK(); if (ConversionConfig.Current.ScaleToVmdSize) { t = t * ScalingConfig.ScaleUnityToPmx; } targetBone.LocalPosition = t; //if (transferredBone != null) { // transferredBone.LocalPosition = t; //} } if (keyFrame.HasRotations) { var x = keyFrame.AngleX.Value; var y = keyFrame.AngleY.Value; var z = keyFrame.AngleZ.Value; var q = UnityRotation.EulerDeg(x, y, z); q = q.FixUnityToOpenTK(); targetBone.LocalRotation = q; if (transferredBone != null) { transferredBone.LocalRotation = q; } } } foreach (var mltdBone in mltdHierarchy) { mltdBone.UpdateTransform(); } for (var j = 0; j < boneCount; ++j) { var pmxBone = pmxHierarchy[j]; var mltdBone = mltdHierarchy[j]; { var pb = pmx.Bones.FirstOrDefault(b => b.Name == pmxBone.Name); Debug.Assert(pb != null, $"PMX bone with the name \"{pmxBone.Name}\" should exist."); if (!pb.IsMltdKeyBone) { continue; } } var skinMatrix = mltdBone.SkinMatrix; var mPmxBindingPose = pmxBone.BindingPose; var mWorld = pmxBone.Parent?.WorldMatrix ?? Matrix4.Identity; // skinMatrix == inv(mPmxBindingPose) x mLocal x mWorld var mLocal = mPmxBindingPose * skinMatrix * mWorld.Inverted(); // Here, translation is in... world coords? WTF? var t = mLocal.ExtractTranslation(); var q = mLocal.ExtractRotation(); if (pmxBone.Parent != null) { t = t - (pmxBone.InitialPosition - pmxBone.Parent.InitialPosition); } int frameIndex; if (ConversionConfig.Current.Transform60FpsTo30Fps) { frameIndex = i / 2; } else { frameIndex = i; } var vmdBoneName = BoneUtils.GetVmdBoneNameFromBoneName(mltdBone.Path); var boneFrame = new VmdBoneFrame(frameIndex, vmdBoneName); boneFrame.Position = t; boneFrame.Rotation = q; boneFrameList.Add(boneFrame); pmxBone.LocalPosition = t; pmxBone.LocalRotation = q; pmxBone.UpdateTransform(); } } return(boneFrameList); }
private VmdBoneFrame[] CreateBoneFrames([NotNull] IBodyAnimationSource mainDance, [NotNull] PrettyAvatar avatar, [NotNull] PmxModel pmx, [NotNull] ScenarioObject baseScenario, [CanBeNull] ScenarioObject formationInfo, [CanBeNull] IBodyAnimationSource danceAppeal, int formationNumber, AppealType appealType) { var boneLookup = new BoneLookup(_conversionConfig); var mltdHierarchy = boneLookup.BuildBoneHierarchy(avatar); mltdHierarchy.AssertAllUnique(); var pmxHierarchy = boneLookup.BuildBoneHierarchy(pmx); pmxHierarchy.AssertAllUnique(); if (_conversionConfig.AppendIKBones || _conversionConfig.AppendEyeBones) { throw new NotSupportedException("Character motion frames generation (from MLTD) is not supported when appending bones (eyes and/or IK) is enabled."); } else { Debug.Assert(mltdHierarchy.Length == pmxHierarchy.Length, "Hierarchy number should be equal between MLTD and MMD."); } foreach (var mltdBone in mltdHierarchy) { mltdBone.Initialize(); } foreach (var pmxBone in pmxHierarchy) { pmxBone.Initialize(); } var mainAnimation = mainDance.Convert(); var appealAnimation = danceAppeal?.Convert(); var mltdBoneCount = mltdHierarchy.Length; var animatedBoneCount = mainAnimation.BoneCount; var keyFrameCount = mainAnimation.KeyFrames.Length; { var names1 = mainAnimation.KeyFrames.Take(animatedBoneCount) .Select(kf => kf.Path).ToArray(); var names = names1.Select(boneLookup.GetVmdBoneNameFromBonePath).ToArray(); // Mark MLTD key bones. foreach (var name in names) { MarkNamedBoneAsKeyBone(pmx, name); } // Special cases MarkNamedBoneAsKeyBone(pmx, "KUBI"); MarkNamedBoneAsKeyBone(pmx, "頭"); } Debug.Assert(keyFrameCount % animatedBoneCount == 0, "keyFrameCount % animatedBoneCount == 0"); // Use this value to export visible frames only var resultFrameCount = (int)(mainAnimation.Duration * FrameRate.Mltd); // Use this value to export all frames, including invisible frames in normal MVs (e.g. seek targets) // var resultFrameCount = keyFrameCount / animatedBoneCount; var boneFrameList = new List <VmdBoneFrame>(); // Reduce memory pressure of allocating new delegates (see mltdHierarchy.FirstOrDefault(...)) var boneMatchPredicateCache = new Predicate <PmxBone> [mltdBoneCount]; for (var j = 0; j < mltdBoneCount; j += 1) { var refBone = pmx.Bones[j]; boneMatchPredicateCache[j] = bone => bone.Name == refBone.Name; } // Cache `mltdBoneName`s so we don't have to compute them all in every iteration var boneNameCache = new Dictionary <string, string>(); var transform60FpsTo30Fps = _conversionConfig.Transform60FpsTo30Fps; var scaleToVmdSize = _conversionConfig.ScaleToVmdSize; var unityToVmdScale = _scalingConfig.ScaleUnityToVmd; var baseFormationList = CollectFormationChanges(formationInfo, AppealType.None); var appealFormationList = CollectFormationChanges(formationInfo, appealType); var appealTimes = AppealHelper.CollectAppealTimeInfo(baseScenario); var seekFrameControls = CollectSeekFrames(baseScenario, formationNumber); var seekFrameCounter = 0; var lastSoughtFrame = -1; // OK, now perform iterations for (var mltdFrameIndex = 0; mltdFrameIndex < resultFrameCount; ++mltdFrameIndex) { if (transform60FpsTo30Fps) { if (mltdFrameIndex % 2 == 1) { continue; } } var shouldUseAppeal = appealType != AppealType.None && (appealTimes.StartFrame <= mltdFrameIndex && mltdFrameIndex < appealTimes.EndFrame) && appealAnimation != null; var animation = shouldUseAppeal ? appealAnimation : mainAnimation; int projectedFrameIndex; if (shouldUseAppeal) { var indexInAppeal = mltdFrameIndex - appealTimes.StartFrame; if (indexInAppeal >= appealAnimation.FrameCount) { indexInAppeal = appealAnimation.FrameCount - 1; } // `indexInAppeal`, unlike `mltdFrameIndex`, has not been scaled yet if (transform60FpsTo30Fps) { projectedFrameIndex = indexInAppeal / 2; } else { projectedFrameIndex = indexInAppeal; } } else { projectedFrameIndex = CalculateSeekFrameTarget(mltdFrameIndex, seekFrameControls, ref lastSoughtFrame, ref seekFrameCounter); } var formationList = shouldUseAppeal ? appealFormationList : baseFormationList; formationList.TryGetCurrentValue(mltdFrameIndex, out var formations); Vector4 idolOffset; if (formations == null || formations.Length < formationNumber) { idolOffset = Vector4.Zero; } else { idolOffset = formations[formationNumber - 1]; } var keyFrameIndexStart = projectedFrameIndex * animatedBoneCount; for (var j = 0; j < animatedBoneCount; ++j) { var keyFrame = animation.KeyFrames[keyFrameIndexStart + j]; var mltdBoneName = GetMltdBoneNameWithoutBodyScale(boneNameCache, keyFrame); // Uniqueness is asserted above var targetBone = mltdHierarchy.Find(bone => bone.Name == mltdBoneName); if (targetBone == null) { //throw new ArgumentException("Bone not found."); continue; // Shika doesn't have the "POSITION" bone. } BoneNode transferredBone = null; foreach (var kv in BoneAttachmentMap) { if (kv.Key != mltdBoneName) { continue; } var attachmentTarget = kv.Value; // Uniqueness is asserted above transferredBone = mltdHierarchy.Find(bone => bone.Name == attachmentTarget); if (transferredBone == null) { throw new ArgumentException("Cannot find transferred bone."); } break; } if (keyFrame.HasPositions) { // ReSharper disable once PossibleInvalidOperationException var x = keyFrame.PositionX.Value; // ReSharper disable once PossibleInvalidOperationException var y = keyFrame.PositionY.Value; // ReSharper disable once PossibleInvalidOperationException var z = keyFrame.PositionZ.Value; if (string.Equals(keyFrame.Path, "MODEL_00", StringComparison.Ordinal)) { var worldRotation = Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(idolOffset.W)); var newOrigin = worldRotation * new Vector3(x, y, z); var newPosition = newOrigin + idolOffset.Xyz; (x, y, z) = (newPosition.X, newPosition.Y, newPosition.Z); } var t = new Vector3(x, y, z); t = t.FixUnityToMmd(); if (scaleToVmdSize) { t = t * unityToVmdScale; } targetBone.LocalPosition = t; //if (transferredBone != null) { // transferredBone.LocalPosition = t; //} } if (keyFrame.HasRotations) { // ReSharper disable once PossibleInvalidOperationException var x = keyFrame.AngleX.Value; // ReSharper disable once PossibleInvalidOperationException var y = keyFrame.AngleY.Value; // ReSharper disable once PossibleInvalidOperationException var z = keyFrame.AngleZ.Value; if (string.Equals(keyFrame.Path, "MODEL_00", StringComparison.Ordinal)) { // The W component stores rotation y += idolOffset.W; } var q = UnityRotation.EulerDeg(x, y, z); q = q.FixUnityToOpenTK(); targetBone.LocalRotation = q; if (transferredBone != null) { transferredBone.LocalRotation = q; } } } foreach (var mltdBone in mltdHierarchy) { mltdBone.UpdateTransform(); } for (var j = 0; j < mltdBoneCount; ++j) { var pmxBone = pmxHierarchy[j]; var mltdBone = mltdHierarchy[j]; { var predicate = boneMatchPredicateCache[j]; var pb = pmx.Bones.Find(predicate); #if DEBUG if (pb == null) { // Lazy evaluation of the assertion message Debug.Assert(pb != null, $"PMX bone with the name \"{pmxBone.Name}\" should exist."); } #endif if (!pb.IsMltdKeyBone) { continue; } } var skinMatrix = mltdBone.SkinMatrix; var mPmxBindingPose = pmxBone.BindingPose; var mWorld = pmxBone.Parent?.WorldMatrix ?? Matrix4.Identity; // skinMatrix == inv(mPmxBindingPose) x mLocal x mWorld var mLocal = mPmxBindingPose * skinMatrix * mWorld.Inverted(); // Here, translation is in... world coords? WTF? var t = mLocal.ExtractTranslation(); var q = mLocal.ExtractRotation(); if (pmxBone.Parent != null) { t = t - (pmxBone.InitialPosition - pmxBone.Parent.InitialPosition); } int vmdFrameIndex; if (_conversionConfig.Transform60FpsTo30Fps) { vmdFrameIndex = mltdFrameIndex / 2; } else { vmdFrameIndex = mltdFrameIndex; } var mltdBoneName = GetMltdBoneNameWithoutBodyScale(boneNameCache, mltdBone.Path); var vmdBoneName = boneLookup.GetVmdBoneNameFromBoneName(mltdBone.Path); var boneFrame = new VmdBoneFrame(vmdFrameIndex, vmdBoneName); var isMovable = BoneLookup.IsBoneMovable(mltdBoneName); boneFrame.Position = isMovable ? t : Vector3.Zero; boneFrame.Rotation = q; boneFrameList.Add(boneFrame); pmxBone.LocalPosition = t; pmxBone.LocalRotation = q; pmxBone.UpdateTransform(); } } return(boneFrameList.ToArray()); }
private VmdMotion ReadMotion() { var signature = ReadString(20); if (signature != "Vocaloid Motion Data") { throw new FormatException("VMD signature is not found."); } var motion = new VmdMotion(); var formatVersionString = ReadString(10); motion.Version = Convert.ToInt32(formatVersionString); motion.ModelName = ReadString(20); ReadBoneFrames(); ReadFacialFrames(); ReadCameraFrames(); ReadLightFrames(); // Unknown 2 _reader.ReadBytes(4); if (_reader.BaseStream.Position != _reader.BaseStream.Length) { ReadIKFrames(); } if (_reader.BaseStream.Position != _reader.BaseStream.Length) { throw new FormatException("The VMD file may contain other data that this reader does not recognize."); } return(motion); void ReadBoneFrames() { var frameCount = _reader.ReadInt32(); var frames = new VmdBoneFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadBoneFrame(); } motion.BoneFrames = frames; } void ReadFacialFrames() { var frameCount = _reader.ReadInt32(); var frames = new VmdFacialFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadFacialFrame(); } motion.FacialFrames = frames; } void ReadCameraFrames() { var frameCount = _reader.ReadInt32(); var frames = new VmdCameraFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadCameraFrame(); } motion.CameraFrames = frames; } void ReadLightFrames() { var frameCount = _reader.ReadInt32(); var frames = new VmdLightFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadLightFrame(); } motion.LightFrames = frames; } void ReadIKFrames() { var frameCount = _reader.ReadInt32(); var frames = new VmdIKFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadIKFrame(); } motion.IKFrames = frames; } }