示例#1
0
        internal static void PrepTourLayers()
        {
            if (TourPlayer.Playing)
            {
                TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController;
                if (player != null)
                {
                    TourDocument tour = player.Tour;

                    if (tour.CurrentTourStop != null)
                    {
                        player.UpdateTweenPosition(-1);


                        if (!tour.CurrentTourStop.KeyFramed)
                        {
                            tour.CurrentTourStop.UpdateLayerOpacity();
                            foreach (Guid key in tour.CurrentTourStop.Layers.Keys)
                            {
                                LayerInfo info = tour.CurrentTourStop.Layers[key];

                                if (LayerList.ContainsKey(info.ID))
                                {
                                    LayerList[info.ID].Opacity = info.FrameOpacity;
                                    LayerList[info.ID].SetParams(info.FrameParams);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public void PlayTour(string url)
        {
            if (uiController is TourPlayer)
            {
                TourPlayer player = (TourPlayer)uiController;
                player.Stop(false);
            }

            tour = TourDocument.FromUrl(url, delegate
            {
                TourPlayer player = new TourPlayer();
                player.Tour = tour;
                tour.CurrentTourstopIndex = -1;
                uiController = player;
                player.Play();

            }
            );
        }
示例#3
0
        //todo remove the stuff from draw that is redundant once predraw has run
        internal static void PreDraw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested)
        {
            if (!AllMaps.ContainsKey(referenceFrame))
            {
                return;
            }



            LayerMap thisMap = AllMaps[referenceFrame];

            if (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0)
            {
                return;
            }
            if (TourPlayer.Playing)
            {
                TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController as TourPlayer;
                if (player != null)
                {
                    TourDocument tour = player.Tour;
                    if (tour.CurrentTourStop != null)
                    {
                        player.UpdateTweenPosition(-1);
                        tour.CurrentTourStop.UpdateLayerOpacity();
                        foreach (Guid key in tour.CurrentTourStop.Layers.Keys)
                        {
                            LayerInfo info = tour.CurrentTourStop.Layers[key];
                            if (LayerList.ContainsKey(info.ID))
                            {
                                LayerList[info.ID].Opacity = info.FrameOpacity;
                                LayerList[info.ID].SetParams(info.FrameParams);
                            }
                        }
                    }
                }
            }

            Matrix3d matOld            = renderContext.World;
            Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating;
            double   oldNominalRadius  = renderContext.NominalRadius;

            if (thisMap.Frame.Reference == ReferenceFrames.Custom)
            {
                thisMap.ComputeFrame(renderContext);
                if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital)
                //if (true)
                {
                    renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World);
                }
                else
                {
                    renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating);
                }
                renderContext.NominalRadius = thisMap.Frame.MeanRadius;
            }



            for (int pass = 0; pass < 2; pass++)
            {
                foreach (Layer layer in AllMaps[referenceFrame].Layers)
                {
                    if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer)))
                    {
                        if (layer.Enabled) // && astronomical == layer.Astronomical)
                        {
                            double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime);
                            double layerEnd   = SpaceTimeController.UtcToJulian(layer.EndTime);
                            double fadeIn     = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0);
                            double fadeOut    = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0);

                            if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut)
                            {
                                float fadeOpacity = 1;
                                if (SpaceTimeController.JNow < layerStart)
                                {
                                    fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000));
                                }

                                if (SpaceTimeController.JNow > layerEnd)
                                {
                                    fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000));
                                }
                                if (thisMap.Frame.Reference == ReferenceFrames.Sky)
                                {
                                    layer.Astronomical = true;
                                }
                                layer.PreDraw(renderContext, opacity * fadeOpacity);
                            }
                        }
                    }
                }
            }
            if (nested)
            {
                foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys)
                {
                    LayerMap map = AllMaps[referenceFrame].ChildMaps[key];
                    if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity))
                    {
                        PreDraw(renderContext, opacity, astronomical, map.Name, nested);
                    }
                }
            }
            renderContext.NominalRadius        = oldNominalRadius;
            renderContext.World                = matOld;
            renderContext.WorldBaseNonRotating = matOldNonRotating;
        }
示例#4
0
        internal static void Draw(RenderContext renderContext, float opacity, bool astronomical, string referenceFrame, bool nested, bool cosmos)
        {
            if (!AllMaps.ContainsKey(referenceFrame))
            {
                return;
            }



            LayerMap thisMap = AllMaps[referenceFrame];

            if (!thisMap.Enabled || (thisMap.ChildMaps.Count == 0 && thisMap.Layers.Count == 0 && !(thisMap.Frame.ShowAsPoint || thisMap.Frame.ShowOrbitPath)))
            {
                return;
            }
            if (TourPlayer.Playing)
            {
                TourPlayer player = (TourPlayer)WWTControl.Singleton.uiController;
                if (player != null)
                {
                    TourDocument tour = player.Tour;
                    if (tour.CurrentTourStop != null)
                    {
                        player.UpdateTweenPosition(-1);
                        tour.CurrentTourStop.UpdateLayerOpacity();

                        foreach (Guid key in tour.CurrentTourStop.Layers.Keys)
                        {
                            LayerInfo info = tour.CurrentTourStop.Layers[key];

                            if (LayerList.ContainsKey(info.ID))
                            {
                                LayerList[info.ID].Opacity = info.FrameOpacity;
                                LayerList[info.ID].SetParams(info.FrameParams);
                            }
                        }
                    }
                }
            }

            Matrix3d matOld            = renderContext.World;
            Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating;
            double   oldNominalRadius  = renderContext.NominalRadius;

            if (thisMap.Frame.Reference == ReferenceFrames.Custom)
            {
                thisMap.ComputeFrame(renderContext);
                if (thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Orbital && thisMap.Frame.ReferenceFrameType != ReferenceFrameTypes.Trajectory)
                //if (true)
                {
                    renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.World);
                }
                else
                {
                    renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating);
                }
                renderContext.NominalRadius = thisMap.Frame.MeanRadius;
            }



            if (thisMap.Frame.ShowAsPoint)
            {
                // todo Draw point planet...
                // Planets.DrawPointPlanet(renderContext.Device, new Vector3d(0, 0, 0), (float).2, thisMap.Frame.RepresentativeColor, true);
            }



            for (int pass = 0; pass < 2; pass++)
            {
                foreach (Layer layer in AllMaps[referenceFrame].Layers)
                {
                    if ((pass == 0 && layer is ImageSetLayer) || (pass == 1 && !(layer is ImageSetLayer)))
                    {
                        if (layer.Enabled) // && astronomical == layer.Astronomical)
                        {
                            double layerStart = SpaceTimeController.UtcToJulian(layer.StartTime);
                            double layerEnd   = SpaceTimeController.UtcToJulian(layer.EndTime);
                            double fadeIn     = SpaceTimeController.UtcToJulian(layer.StartTime) - ((layer.FadeType == FadeType.FadeIn || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0);
                            double fadeOut    = SpaceTimeController.UtcToJulian(layer.EndTime) + ((layer.FadeType == FadeType.FadeOut || layer.FadeType == FadeType.Both) ? (layer.FadeSpan / 864000000) : 0);

                            if (SpaceTimeController.JNow > fadeIn && SpaceTimeController.JNow < fadeOut)
                            {
                                float fadeOpacity = 1;
                                if (SpaceTimeController.JNow < layerStart)
                                {
                                    fadeOpacity = (float)((SpaceTimeController.JNow - fadeIn) / (layer.FadeSpan / 864000000));
                                }

                                if (SpaceTimeController.JNow > layerEnd)
                                {
                                    fadeOpacity = (float)((fadeOut - SpaceTimeController.JNow) / (layer.FadeSpan / 864000000));
                                }
                                layer.Astronomical = astronomical;
                                //if (thisMap.Frame.Reference == ReferenceFrames.Sky)
                                //{
                                //    layer.Astronomical = true;
                                //}
                                layer.Draw(renderContext, opacity * fadeOpacity, cosmos);
                            }
                        }
                    }
                }
            }
            if (nested)
            {
                foreach (string key in AllMaps[referenceFrame].ChildMaps.Keys)
                {
                    LayerMap map = AllMaps[referenceFrame].ChildMaps[key];
                    if (map.Frame.ShowOrbitPath && Settings.Active.SolarSystemOrbits)
                    {
                        if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Orbital)
                        {
                            if (map.Frame.Orbit == null)
                            {
                                map.Frame.Orbit = new Orbit(map.Frame.Elements, 360, map.Frame.RepresentativeColor, 1, (float)renderContext.NominalRadius);
                            }
                            Matrix3d matSaved = renderContext.World;
                            renderContext.World = Matrix3d.MultiplyMatrix(thisMap.Frame.WorldMatrix, renderContext.WorldBaseNonRotating);

                            map.Frame.Orbit.Draw3D(renderContext, 1f * .25f, Vector3d.Create(0, 0, 0));
                            renderContext.World = matSaved;
                        }
                        else if (map.Frame.ReferenceFrameType == ReferenceFrameTypes.Trajectory)
                        {
                            //todo add trajectories back
                            //if (map.Frame.trajectoryLines == null)
                            //{
                            //    map.Frame.trajectoryLines = new LineList(renderContext.Device);
                            //    map.Frame.trajectoryLines.ShowFarSide = true;
                            //    map.Frame.trajectoryLines.UseNonRotatingFrame = true;

                            //    int count = map.Frame.Trajectory.Count - 1;
                            //    for (int i = 0; i < count; i++)
                            //    {
                            //        Vector3d pos1 = map.Frame.Trajectory[i].Position;
                            //        Vector3d pos2 = map.Frame.Trajectory[i + 1].Position;
                            //        pos1.Multiply(1 / renderContext.NominalRadius);
                            //        pos2.Multiply(1 / renderContext.NominalRadius);
                            //        map.Frame.trajectoryLines.AddLine(pos1, pos2, map.Frame.RepresentativeColor, new Dates());
                            //    }
                            //}
                            //Matrix3D matSaved = renderContext.World;
                            //renderContext.World = thisMap.Frame.WorldMatrix * renderContext.WorldBaseNonRotating;

                            //map.Frame.trajectoryLines.DrawLines(renderContext, Earth3d.MainWindow.showMinorOrbits.Opacity * .25f);
                            //renderContext.World = matSaved;
                        }
                    }

                    if ((map.Frame.Reference == ReferenceFrames.Custom || map.Frame.Reference == ReferenceFrames.Identity))
                    {
                        Draw(renderContext, opacity, astronomical, map.Name, nested, cosmos);
                    }
                }
            }
            renderContext.NominalRadius        = oldNominalRadius;
            renderContext.World                = matOld;
            renderContext.WorldBaseNonRotating = matOldNonRotating;
        }