public ViewMoverKenBurnsStyle(CameraParameters from, CameraParameters to, double time, Date fromDateTime, Date toDateTime, InterpolationType type) { InterpolationType = type; if (Math.Abs(from.Lng - to.Lng) > 180) { if (from.Lng > to.Lng) { from.Lng -= 360; } else { from.Lng += 360; } } this.fromDateTime = fromDateTime; this.toDateTime = toDateTime; dateTimeSpan = toDateTime - fromDateTime; this.from = from.Copy(); this.to = to.Copy(); fromTime = Date.Now; toTargetTime = time; }
private int CalculateRunTime() { double totalTime = 0.0; for (int i = 0; i < tourStops.Count; i++) { totalTime += (double)(tourStops[i].Duration); if (i > 0) { switch (tourStops[i].Transition) { case TransitionType.Slew: if (tourStops[i].Target.BackgroundImageset == null || (tourStops[i - 1].Target.BackgroundImageset.DataSetType == tourStops[i].Target.BackgroundImageset.DataSetType && ((tourStops[i - 1].Target.BackgroundImageset.DataSetType != ImageSetType.SolarSystem) || (tourStops[i - 1].Target.Target == tourStops[i].Target.Target)))) { CameraParameters start = tourStops[i - 1].EndTarget == null ? tourStops[i - 1].Target.CamParams : tourStops[i - 1].EndTarget.CamParams; ViewMoverSlew slew = ViewMoverSlew.Create(start, tourStops[i].Target.CamParams); totalTime += slew.MoveTime * 1000; } break; case TransitionType.Instant: break; case TransitionType.CrossFade: break; case TransitionType.FadeToBlack: break; default: break; } } } return((int)totalTime); }
public static CameraParameters InterpolateGreatCircle(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove) { CameraParameters result = new CameraParameters(); double alpha = EaseCurve(alphaIn, type); double alphaBIn = Math.Min(1.0, alphaIn * 2); double alphaB = EaseCurve(alphaBIn, type); result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha); result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha); Vector3d left = Coordinates.GeoTo3dDouble(from.Lat, from.Lng); Vector3d right = Coordinates.GeoTo3dDouble(to.Lat, to.Lng); Vector3d mid = Vector3d.Slerp(left, right, alpha); Vector2d midV2 = Coordinates.CartesianToLatLng(mid); result.Lat = midV2.Y; result.Lng = midV2.X; result.Zoom = Math.Pow(2, LogN(to.Zoom, 2) * alpha + LogN(from.Zoom, 2) * (1.0 - alpha)); result.Opacity = (double)(to.Opacity * alpha + from.Opacity * (1.0 - alpha)); result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha); result.TargetReferenceFrame = to.TargetReferenceFrame; if (to.Target == from.Target) { result.Target = to.Target; } else { result.Target = SolarSystemObjects.Custom; } return(result); }
public static Place CreateCameraParams(string name, CameraParameters camParams, Classification classification, string constellation, ImageSetType type, SolarSystemObjects target) { Place temp = new Place(); temp.constellation = constellation; temp.name = name; temp.Classification = classification; temp.camParams = camParams; temp.Type = type; temp.Target = target; return temp; }
public void Render(RenderContext renderContext) { //window.SetupMatricesOverlays(); if (tour == null || tour.CurrentTourStop == null || !playing) { return; } renderContext.Save(); UpdateSlideStates(); if (!onTarget) { slideStartTime = Date.Now; if (renderContext.OnTarget(Tour.CurrentTourStop.Target)) { onTarget = true; overlayBlend.State = !Tour.CurrentTourStop.FadeInOverlays; overlayBlend.TargetState = true; if (tour.CurrentTourStop.MusicTrack != null) { tour.CurrentTourStop.MusicTrack.Play(); } if (tour.CurrentTourStop.VoiceTrack != null) { tour.CurrentTourStop.VoiceTrack.Play(); } string caption = ""; foreach (Overlay overlay in tour.CurrentTourStop.Overlays) { if (overlay.Name.ToLowerCase() == "caption") { TextOverlay text = overlay as TextOverlay; if (text != null) { caption = text.TextObject.Text; } } overlay.Play(); } LayerManager.SetVisibleLayerList(tour.CurrentTourStop.Layers); if (tour.CurrentTourStop.EndTarget != null && tour.CurrentTourStop.EndTarget.ZoomLevel != -1) { if (tour.CurrentTourStop.Target.Type == ImageSetType.SolarSystem) { // TODO fix this when Planets are implenented //tour.CurrentTourStop.Target.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.StartTime)); //tour.CurrentTourStop.EndTarget.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.EndTime)); } renderContext.ViewMover = new ViewMoverKenBurnsStyle(tour.CurrentTourStop.Target.CamParams, tour.CurrentTourStop.EndTarget.CamParams, tour.CurrentTourStop.Duration / 1000.0, tour.CurrentTourStop.StartTime, tour.CurrentTourStop.EndTime, tour.CurrentTourStop.InterpolationType); } Settings.TourSettings = tour.CurrentTourStop; SpaceTimeController.Now = tour.CurrentTourStop.StartTime; SpaceTimeController.SyncToClock = false; WWTControl.scriptInterface.FireSlideChanged(caption); } } //todo implement gl based tour rendering if (renderContext.gl != null) { renderContext.SetupMatricesOverlays(); //todo Factor opacity in somehow ?? //view.overlays.Opacity = overlayBlend.Opacity; if (currentMasterSlide != null) { foreach (Overlay overlay in currentMasterSlide.Overlays) { overlay.TweenFactor = 1f; overlay.Draw3D(renderContext, false); } } if (onTarget) { foreach (Overlay overlay in tour.CurrentTourStop.Overlays) { if (overlay.Name.ToLowerCase() != "caption" || WWTControl.scriptInterface.ShowCaptions) { overlay.TweenFactor = (float)CameraParameters.EaseCurve(tour.CurrentTourStop.TweenPosition, overlay.InterpolationType == InterpolationType.DefaultV ? tour.CurrentTourStop.InterpolationType : overlay.InterpolationType); overlay.Draw3D(renderContext, false); } } } renderContext.Restore(); //DrawPlayerControls(renderContext); } else { renderContext.Device.Scale(renderContext.Height / 1116, renderContext.Height / 1116); double aspectOrig = 1920 / 1116; double aspectNow = renderContext.Width / renderContext.Height; renderContext.Device.Translate(-((1920 - (aspectNow * 1116)) / 2), 0); //todo Factor opacity in somehow ?? //view.overlays.Opacity = overlayBlend.Opacity; if (currentMasterSlide != null) { foreach (Overlay overlay in currentMasterSlide.Overlays) { overlay.TweenFactor = 1f; overlay.Draw3D(renderContext, false); } } if (onTarget) { foreach (Overlay overlay in tour.CurrentTourStop.Overlays) { if (overlay.Name.ToLowerCase() != "caption" || WWTControl.scriptInterface.ShowCaptions) { overlay.TweenFactor = (float)CameraParameters.EaseCurve(tour.CurrentTourStop.TweenPosition, overlay.InterpolationType == InterpolationType.DefaultV ? tour.CurrentTourStop.InterpolationType : overlay.InterpolationType); overlay.Draw3D(renderContext, false); } } } else { int i = 0; } renderContext.Restore(); DrawPlayerControls(renderContext); } }
public CameraParameters Copy() { CameraParameters temp = new CameraParameters(); temp.Lat = Lat; temp.Lng = Lng; temp.Zoom = Zoom; temp.Rotation = Rotation; temp.Angle = Angle; temp.RaDec = RaDec; temp.Opacity = Opacity; temp.ViewTarget = ViewTarget.Copy(); temp.Target = Target; temp.TargetReferenceFrame = TargetReferenceFrame; return temp; }
public static CameraParameters InterpolateGreatCircle(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove) { CameraParameters result = new CameraParameters(); double alpha = EaseCurve(alphaIn, type); double alphaBIn = Math.Min(1.0, alphaIn * 2); double alphaB = EaseCurve(alphaBIn, type); result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha); result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha); Vector3d left = Coordinates.GeoTo3dDouble(from.Lat, from.Lng); Vector3d right = Coordinates.GeoTo3dDouble(to.Lat, to.Lng); Vector3d mid = Vector3d.Slerp(left, right, alpha); Vector2d midV2 = Coordinates.CartesianToLatLng(mid); result.Lat = midV2.Y; result.Lng = midV2.X; result.Zoom = Math.Pow(2, LogN(to.Zoom, 2) * alpha + LogN(from.Zoom, 2) * (1.0 - alpha)); result.Opacity = (double)(to.Opacity * alpha + from.Opacity * (1.0 - alpha)); result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha); result.TargetReferenceFrame = to.TargetReferenceFrame; if (to.Target == from.Target) { result.Target = to.Target; } else { result.Target = SolarSystemObjects.Custom; } return result; }
public static CameraParameters Interpolate(CameraParameters from, CameraParameters to, double alphaIn, InterpolationType type, bool fastDirectionMove) { CameraParameters result = new CameraParameters(); double alpha = EaseCurve(alphaIn, type); double alphaBIn = Math.Min(1.0, alphaIn * 2); double alphaB = EaseCurve(alphaBIn, type); result.Angle = to.Angle * alpha + from.Angle * (1.0 - alpha); result.Rotation = to.Rotation * alpha + from.Rotation * (1.0 - alpha); if (fastDirectionMove) { result.Lat = to.Lat * alphaB + from.Lat * (1.0 - alphaB); result.Lng = to.Lng * alphaB + from.Lng * (1.0 - alphaB); } else { result.Lat = to.Lat * alpha + from.Lat * (1.0 - alpha); result.Lng = to.Lng * alpha + from.Lng * (1.0 - alpha); } result.Zoom = Math.Pow(2, LogN(to.Zoom, 2) * alpha + LogN(from.Zoom, 2) * (1.0 - alpha)); result.Opacity = (double)(to.Opacity * alpha + from.Opacity * (1.0 - alpha)); result.ViewTarget = Vector3d.Lerp(from.ViewTarget, to.ViewTarget, alpha); result.TargetReferenceFrame = to.TargetReferenceFrame; if (to.Target == from.Target) { result.Target = to.Target; } else { result.Target = SolarSystemObjects.Custom; } return result; }
public static CameraParameters Create(double lat, double lng, double zoom, double rotation, double angle, float opactity) { CameraParameters temp = new CameraParameters(); temp.Lat = lat; temp.Lng = lng; temp.Zoom = zoom; temp.Rotation = rotation; temp.Angle = angle; temp.RaDec = false; temp.Opacity = opactity; temp.ViewTarget = Vector3d.Create(0, 0, 0); temp.Target = SolarSystemObjects.Custom; temp.TargetReferenceFrame = ""; return temp; }
public void GotoTargetFull(bool noZoom, bool instant, CameraParameters cameraParams, Imageset studyImageSet, Imageset backgroundImageSet) { RenderNeeded = true; //if (cameraParams == this.viewCamera) //{ // instant = true; //} tracking = false; trackingObject = null; targetStudyImageset = studyImageSet; targetBackgroundImageset = backgroundImageSet; if (noZoom) { cameraParams.Zoom = RenderContext.ViewCamera.Zoom; cameraParams.Angle = RenderContext.ViewCamera.Angle; cameraParams.Rotation = RenderContext.ViewCamera.Rotation; } else { if (cameraParams.Zoom == -1 || cameraParams.Zoom == 0) { if (RenderContext.Space) { cameraParams.Zoom = 1.40625; } else { cameraParams.Zoom = 0.09F; } } } // if (instant || (Math.Abs(ViewLat - cameraParams.Lat) < .000000000001 && Math.Abs(ViewLong - cameraParams.Lng) < .000000000001 && Math.Abs(ZoomFactor - cameraParams.Zoom) < .000000000001)) if (instant || (Math.Abs(RenderContext.ViewCamera.Lat - cameraParams.Lat) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Lng - cameraParams.Lng) < .000000000001 && Math.Abs(RenderContext.ViewCamera.Zoom - cameraParams.Zoom) < .000000000001)) { Mover = null; RenderContext.TargetCamera = cameraParams.Copy(); RenderContext.ViewCamera = RenderContext.TargetCamera.Copy(); //if (Space && Settings.Active.LocalHorizonMode) //{ // Coordinates currentAltAz = Coordinates.EquitorialToHorizon(Coordinates.FromRaDec(viewCamera.RA, viewCamera.Dec), SpaceTimeController.Location, SpaceTimeController.Now); // targetAlt = alt = currentAltAz.Alt; // targetAz = az = currentAltAz.Az; //} mover_Midpoint(); moving = true; } else { Mover = ViewMoverSlew.Create(RenderContext.ViewCamera, cameraParams); RenderNeeded = true; Mover.Midpoint = mover_Midpoint; } }
public void GotoTarget3(CameraParameters camParams, bool noZoom, bool instant) { tracking = false; trackingObject = null; GotoTargetFull(noZoom, instant, camParams, RenderContext.ForegroundImageset, RenderContext.BackgroundImageset); }
public void Init(CameraParameters from, CameraParameters to) { if (Math.Abs(from.Lng - to.Lng) > 180) { if (from.Lng > to.Lng) { from.Lng -= 360; } else { from.Lng += 360; } } if (to.Zoom <= 0) { to.Zoom = 360; } if (from.Zoom <= 0) { from.Zoom = 360; } this.from = from; this.to = to; fromTime = Date.Now; double zoomUpTarget = 360.0; double travelTime; double lngDist = Math.Abs(from.Lng - to.Lng); double latDist = Math.Abs(from.Lat - to.Lat); double distance = Math.Sqrt(latDist * latDist + lngDist * lngDist); zoomUpTarget = (distance / 3) * 20; if (zoomUpTarget > 360.0) { zoomUpTarget = 360.0; } if (zoomUpTarget < from.Zoom) { zoomUpTarget = from.Zoom; } travelTime = (distance / 180.0) * (360 / zoomUpTarget) * travelTimeFactor; double rotateTime = Math.Max(Math.Abs(from.Angle - to.Angle), Math.Abs(from.Rotation - to.Rotation)) ; double logDistUp = Math.Max(Math.Abs(Util.LogN(zoomUpTarget, 2) - Util.LogN(from.Zoom, 2)), rotateTime); upTargetTime = upTimeFactor * logDistUp; downTargetTime = upTargetTime + travelTime; double logDistDown = Math.Abs(Util.LogN(zoomUpTarget, 2) - Util.LogN(to.Zoom, 2)); toTargetTime = downTargetTime + Math.Max((downTimeFactor * logDistDown),rotateTime); fromTop = from.Copy(); fromTop.Zoom = zoomUpTarget; fromTop.Angle = (from.Angle + to.Angle) / 2.0; //todo make short wrap arounds.. fromTop.Rotation = (from.Rotation + to.Rotation) / 2.0; toTop = to.Copy(); toTop.Zoom = fromTop.Zoom; toTop.Angle = fromTop.Angle; toTop.Rotation = fromTop.Rotation; }
public static ViewMoverSlew CreateUpDown(CameraParameters from, CameraParameters to, double upDowFactor) { ViewMoverSlew temp = new ViewMoverSlew(); temp.upTimeFactor = temp.downTimeFactor = upDowFactor; temp.Init(from.Copy(), to.Copy()); return temp; }
public static ViewMoverSlew Create(CameraParameters from, CameraParameters to) { ViewMoverSlew temp = new ViewMoverSlew(); temp.Init(from, to); return temp; }
public void Init(CameraParameters from, CameraParameters to) { if (Math.Abs(from.Lng - to.Lng) > 180) { if (from.Lng > to.Lng) { from.Lng -= 360; } else { from.Lng += 360; } } if (to.Zoom <= 0) { to.Zoom = 360; } if (from.Zoom <= 0) { from.Zoom = 360; } this.from = from; this.to = to; fromTime = Date.Now; double zoomUpTarget = 360.0; double travelTime; double lngDist = Math.Abs(from.Lng - to.Lng); double latDist = Math.Abs(from.Lat - to.Lat); double distance = Math.Sqrt(latDist * latDist + lngDist * lngDist); zoomUpTarget = (distance / 3) * 20; if (zoomUpTarget > 360.0) { zoomUpTarget = 360.0; } if (zoomUpTarget < from.Zoom) { zoomUpTarget = from.Zoom; } travelTime = (distance / 180.0) * (360 / zoomUpTarget) * travelTimeFactor; double rotateTime = Math.Max(Math.Abs(from.Angle - to.Angle), Math.Abs(from.Rotation - to.Rotation)); double logDistUp = Math.Max(Math.Abs(Util.LogN(zoomUpTarget, 2) - Util.LogN(from.Zoom, 2)), rotateTime); upTargetTime = upTimeFactor * logDistUp; downTargetTime = upTargetTime + travelTime; double logDistDown = Math.Abs(Util.LogN(zoomUpTarget, 2) - Util.LogN(to.Zoom, 2)); toTargetTime = downTargetTime + Math.Max((downTimeFactor * logDistDown), rotateTime); fromTop = from.Copy(); fromTop.Zoom = zoomUpTarget; fromTop.Angle = (from.Angle + to.Angle) / 2.0; //todo make short wrap arounds.. fromTop.Rotation = (from.Rotation + to.Rotation) / 2.0; toTop = to.Copy(); toTop.Zoom = fromTop.Zoom; toTop.Angle = fromTop.Angle; toTop.Rotation = fromTop.Rotation; }