private VmdLightFrame[] CreateLightFrames([NotNull] ScenarioObject scenarioObject) { var lightFrameList = new List <VmdLightFrame>(); var lightControls = scenarioObject.Scenario.WhereToArray(s => s.Type == ScenarioDataType.LightColor); foreach (var lightControl in lightControls) { var n = (int)((float)lightControl.AbsoluteTime * 60.0f); int frameIndex; if (_conversionConfig.Transform60FpsTo30Fps) { frameIndex = n / 2; } else { frameIndex = n; } var frame = new VmdLightFrame(frameIndex); frame.Position = new Vector3(0.5f, -1f, -0.5f); var c = lightControl.Color; frame.Color = new Vector3(c.R, c.G, c.B); lightFrameList.Add(frame); } return(lightFrameList.ToArray()); }
private VmdLightFrame ReadLightFrame() { var frame = new VmdLightFrame(); frame.FrameIndex = _reader.ReadInt32(); frame.Color = _reader.ReadVector3(); frame.Position = _reader.ReadVector3(); return(frame); }
private void ReadLightFrames([NotNull] VmdMotion motion) { var frameCount = _reader.ReadInt32(); var frames = new VmdLightFrame[frameCount]; for (var i = 0; i < frameCount; ++i) { frames[i] = ReadLightFrame(); } motion.LightFrames = frames; }
private void WriteLightFrame([NotNull] VmdLightFrame frame) { _writer.Write(frame.FrameIndex); _writer.Write(frame.Color); _writer.Write(frame.Position); }
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; } }