private static async Task CreateCameraKeyframe(MapView mapView, MapPoint orig_cameraPoint, ProjectionTransformation transformation, CameraTrack cameraTrack, TimeSpan currentTimespanValue, double pitch, double heading, bool ignoreRotation = false, bool ignoreTranslation = false) { await QueuedTask.Run(() => { Keyframe keyFrame = null; MapPoint projected_cameraPoint = (MapPoint)GeometryEngine.Instance.ProjectEx(orig_cameraPoint, transformation); if (mapView.ViewingMode == MapViewingMode.Map) { var camera = new Camera(projected_cameraPoint.X, projected_cameraPoint.Y, CameraZOffset, heading, null, CameraViewpoint.LookAt); keyFrame = cameraTrack.CreateKeyframe(camera, currentTimespanValue, AnimationTransition.FixedArc, .5); } else { var camera = new Camera(projected_cameraPoint.X, projected_cameraPoint.Y, (projected_cameraPoint.Z + CameraZOffset), pitch, heading, null, CameraViewpoint.LookAt); keyFrame = cameraTrack.CreateKeyframe(camera, currentTimespanValue, AnimationTransition.FixedArc, .5); } if (ignoreRotation) { CameraKeyframe camKey = keyFrame as CameraKeyframe; camKey.HeadingTransition = AnimationTransition.None; camKey.RollTransition = AnimationTransition.None; camKey.PitchTransition = AnimationTransition.None; } if (ignoreTranslation) { CameraKeyframe camKey = keyFrame as CameraKeyframe; camKey.XTransition = AnimationTransition.None; camKey.YTransition = AnimationTransition.None; camKey.ZTransition = AnimationTransition.None; } }); }
public CameraMotion ReadCameraMotion(BinaryReader reader, bool motionReadAlready = false) { if (!motionReadAlready) { Read(reader); } var ret = new CameraMotion(); var cameraMotionNum = reader.ReadInt32(); Dictionary <int, CameraKeyframe> keyframes = new Dictionary <int, CameraKeyframe>(); for (var i = 0; i < cameraMotionNum; ++i) { var nFrame = reader.ReadInt32(); var focalLength = reader.ReadSingle(); var position = MmdReaderUtil.ReadVector3(reader); var rotation = MmdReaderUtil.ReadVector3(reader); var interpolator = reader.ReadBytes(24); var fov = reader.ReadUInt32(); var orthographic = reader.ReadByte(); var keyframe = new CameraKeyframe { Fov = fov, FocalLength = focalLength, Orthographic = orthographic != 0, Position = position, Rotation = rotation, Interpolation = interpolator }; keyframes[nFrame] = keyframe; } var frameList = keyframes.Select(entry => entry).ToList().OrderBy(kv => kv.Key).ToList(); ret.KeyFrames = frameList; return(ret); }