public void FromTLE(string line1, string line2, double gravity) { Epoch = SpaceTimeController.TwoLineDateToJulian(line1.Substr(18, 14)); Eccentricity = double.Parse("0." + line2.Substr(26, 7)); Inclination = double.Parse(line2.Substr(8, 8)); LongitudeOfAscendingNode = double.Parse(line2.Substr(17, 8)); ArgumentOfPeriapsis = double.Parse(line2.Substr(34, 8)); double revs = double.Parse(line2.Substr(52, 11)); MeanAnomolyAtEpoch = double.Parse(line2.Substr(43, 8)); MeanDailyMotion = revs * 360.0; double part = (86400.0 / revs) / (Math.PI * 2.0); SemiMajorAxis = Math.Pow((part * part) * gravity, 1.0 / 3.0); SemiMajorAxisUnits = AltUnits.Meters; }
public string ToTLE() { //Epoch need to convert to TLE time string. // Ecentricity remove "0." from the begin and trim to 7 digits // Inclination decimal degrees 8 digits max // LOAN decimal degrees 8 digits // AOP // mean anomoly at epoch 8 digits // Mean motion (revs per day) Compute // Convert Semi-major-axis to meters from storage unit // Compute revs StringBuilder line1 = new StringBuilder(); line1.Append("1 99999U 00111AAA "); line1.Append(SpaceTimeController.JulianToTwoLineDate(Epoch)); line1.Append(" "); // line1.Append("-.00000001"); line1.Append(SemiMajorAxis.ToExponential(4)); line1.Append(" 00000-0 "); line1.Append(ToTLEExponential(MeanDailyMotion, 5)); //line1.Append("-00000-1 0 "); line1.Append(" 001"); line1.Append(ComputeTLECheckSum(line1.ToString())); line1.AppendLine(""); StringBuilder line2 = new StringBuilder(); line2.Append("2 99999 "); line2.Append(TLENumberString(Inclination, 3, 4) + " "); line2.Append(TLENumberString(LongitudeOfAscendingNode, 3, 4) + " "); line2.Append((TLENumberString(Eccentricity, 1, 7) + " ").Substring(2)); line2.Append(TLENumberString(ArgumentOfPeriapsis, 3, 4) + " "); line2.Append(TLENumberString(MeanAnomolyAtEpoch, 3, 4) + " "); line2.Append(ToTLEExponential(MeanDailyMotion / 207732, 5)); line2.Append("00001"); line2.Append(ComputeTLECheckSum(line2.ToString())); line2.AppendLine(""); return(line1.ToString() + line2.ToString()); }
private static void MakeEclipticText() { int year = SpaceTimeController.Now.GetUTCFullYear(); if (EclipOvTextBatch == null) { EclipOvTextBatch = new Text3dBatch(80); EclipticTextYear = year; double obliquity = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow); Matrix3d mat = Matrix3d.RotationX((-obliquity / 360.0 * (Math.PI * 2))); double daysPerYear = 365.25; if (DT.IsLeap(year, true)) { monthDays[1] = 29; daysPerYear = 366; } else { monthDays[1] = 28; daysPerYear = 365; } int count = 2 * (int)daysPerYear; EclipticCount = (int)daysPerYear; double jYear = SpaceTimeController.UtcToJulian(new Date(year, 0, 1, 12, 0, 0)); int index = 0; double d = 0; for (int m = 0; m < 12; m++) { int daysThisMonth = (int)monthDays[m]; for (int i = 0; i < daysThisMonth; i++) { AstroRaDec sunRaDec = Planets.GetPlanetLocationJD("Sun", jYear); COR sunEcliptic = CT.Eq2Ec(sunRaDec.RA, sunRaDec.Dec, obliquity); d = sunEcliptic.X; double dd = d;// +180; if (i == Math.Floor(daysThisMonth / 2.0)) { Vector3d center = Vector3d.TransformCoordinate(Vector3d.Create((Math.Cos((dd * Math.PI * 2.0) / 360)), .025f, (Math.Sin((dd * Math.PI * 2.0) / 360))), mat); Vector3d up = Vector3d.TransformCoordinate(Vector3d.Create((Math.Cos((dd * Math.PI * 2.0) / 360)), .045f, (Math.Sin((dd * Math.PI * 2.0) / 360))), mat); up.Subtract(center); up.Normalize(); EclipOvTextBatch.Add(new Text3d(center, up, monthNames[m], 80, .000159375)); } index++; index++; jYear += 1; } d += monthDays[m]; } } }
public static bool DrawEcliptic(RenderContext renderContext, float opacity, Color drawColor) { Color col = drawColor; int year = SpaceTimeController.Now.GetUTCFullYear(); if (eclipticOverviewLineList == null || year != EclipticYear) { if (eclipticOverviewLineList != null) { eclipticOverviewLineList.Clear(); eclipticOverviewLineList = null; } EclipticYear = year; double obliquity = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow); Matrix3d mat = Matrix3d.RotationX((-obliquity / 360.0 * (Math.PI * 2))); double daysPerYear = 365.25; if (DT.IsLeap(year, true)) { monthDays[1] = 29; daysPerYear = 366; } else { monthDays[1] = 28; daysPerYear = 365; } int count = 2 * (int)daysPerYear; EclipticCount = (int)daysPerYear; double jYear = SpaceTimeController.UtcToJulian(new Date(year, 0, 1, 12, 0, 0)); int index = 0; double d = 0; eclipticOverviewLineList = new SimpleLineList(); eclipticOverviewLineList.DepthBuffered = false; for (int m = 0; m < 12; m++) { int daysThisMonth = (int)monthDays[m]; for (int i = 0; i < daysThisMonth; i++) { AstroRaDec sunRaDec = Planets.GetPlanetLocationJD("Sun", jYear); COR sunEcliptic = CT.Eq2Ec(sunRaDec.RA, sunRaDec.Dec, obliquity); d = sunEcliptic.X; double width = .005f; if (i == 0) { width = .01f; } double dd = d;// +180; eclipticOverviewLineList.AddLine( Vector3d.TransformCoordinate(Vector3d.Create((Math.Cos((dd * Math.PI * 2.0) / 360)), width, (Math.Sin((dd * Math.PI * 2.0) / 360))), mat), Vector3d.TransformCoordinate(Vector3d.Create((Math.Cos((dd * Math.PI * 2.0) / 360)), -width, (Math.Sin((dd * Math.PI * 2.0) / 360))), mat) ); index++; jYear += 1; } d += monthDays[m]; } } eclipticOverviewLineList.DrawLines(renderContext, opacity, drawColor); return(true); }
public override bool Draw(RenderContext renderContext, float opacity, bool flat) { RenderContext device = renderContext; //if (shaderA == null) //{ // MakeVertexShaderA(device); //} if (bufferIsFlat != flat) { CleanUp(); bufferIsFlat = flat; } if (dirty) { PrepVertexBuffer(device, opacity); } double jNow = SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate); float adjustedScale = scaleFactor; if (flat && astronomical && (markerScale == MarkerScales.World)) { adjustedScale = (float)(scaleFactor / (renderContext.ViewCamera.Zoom / 360)); } if (triangleList2d != null) { triangleList2d.Decay = decay; triangleList2d.Sky = this.Astronomical; triangleList2d.TimeSeries = timeSeries; triangleList2d.JNow = jNow; triangleList2d.Draw(renderContext, opacity * Opacity, CullMode.Clockwise); } if (triangleList != null) { triangleList.Decay = decay; triangleList.Sky = this.Astronomical; triangleList.TimeSeries = timeSeries; triangleList.JNow = jNow; triangleList.Draw(renderContext, opacity * Opacity, CullMode.Clockwise); } if (pointList != null) { pointList.DepthBuffered = false; pointList.Decay = decay; pointList.Sky = this.Astronomical; pointList.TimeSeries = timeSeries; pointList.JNow = jNow; pointList.scale = (markerScale == MarkerScales.World) ? (float)adjustedScale : -(float)adjustedScale; pointList.Draw(renderContext, opacity * Opacity, false); } if (lineList != null) { lineList.Sky = this.Astronomical; lineList.Decay = decay; lineList.TimeSeries = timeSeries; lineList.JNow = jNow; lineList.DrawLines(renderContext, opacity * Opacity); } if (lineList2d != null) { lineList2d.Sky = this.Astronomical; lineList2d.Decay = decay; lineList2d.TimeSeries = timeSeries; lineList2d.ShowFarSide = ShowFarSide; lineList2d.JNow = jNow; lineList2d.DrawLines(renderContext, opacity * Opacity); } //device.RenderState.AlphaBlendEnable = true; //device.RenderState.SourceBlend = Microsoft.DirectX.Direct3D.Blend.SourceAlpha; //device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.InvSourceAlpha; //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha; //TextureOperation oldTexOp = device.TextureState[0].ColorOperation; //bool zBufferEnabled = device.RenderState.ZBufferEnable; //if (astronomical && !bufferIsFlat) //{ // device.RenderState.ZBufferEnable = true; //} //else //{ // device.RenderState.ZBufferEnable = false; //} //device.TextureState[0].ColorOperation = TextureOperation.Disable; //FillMode oldMode = device.RenderState.FillMode; //DateTime baseDate = new DateTime(2010, 1, 1, 12, 00, 00); //device.RenderState.FillMode = FillMode.Solid; //device.SetTexture(0, null); //device.Indices = shapeFileIndex; //device.VertexShader = shaderA; //// Vector3 cam = Vector3d.TransformCoordinate(Earth3d.cameraPosition, Matrix3d.Invert(renderContext.World)).Vector3; //Vector3 cam = Vector3.TransformCoordinate(renderContext.CameraPosition.Vector3, Matrix.Invert(renderContext.Device.Transform.World)); //constantTableA.SetValue(device, cameraHandleA, new Vector4(cam.X, cam.Y, cam.Z, 1)); //constantTableA.SetValue(device, jNowHandleA, (float)(SpaceTimeController.JNow - SpaceTimeController.UtcToJulian(baseDate))); //constantTableA.SetValue(device, decayHandleA, timeSeries ? decay : 0f); //float adjustedScale = scaleFactor; //if (flat && astronomical && (markerScale == MarkerScales.World)) //{ // adjustedScale = (float)(scaleFactor / (Earth3d.MainWindow.ZoomFactor / 360)); //} //constantTableA.SetValue(device, scaleHandleA, (markerScale == MarkerScales.World) ? (float)adjustedScale : -(float)adjustedScale); //constantTableA.SetValue(device, skyHandleA, astronomical ? -1 : 1); //constantTableA.SetValue(device, opacityHandleA, opacity * this.Opacity); //constantTableA.SetValue(device, showFarSideHandleA, ShowFarSide ? 1f : 0f); //// Matrix matrixWVP = Earth3d.WorldMatrix * Earth3d.ViewMatrix * Earth3d.ProjMatrix; ////Matrix matrixWVP = device.Transform.World * device.Transform.View * device.Transform.Projection; //Matrix3d matrixWVP = renderContext.World * renderContext.View * renderContext.Projection; //constantTableA.SetValue(device, worldViewHandleA, matrixWVP.Matrix); //device.SetStreamSource(0, shapeFileVertex, 0); ////device.VertexFormat = VertexFormats.None; ////device.VertexDeclaration = vertexDeclA; //device.VertexFormat = PointVertex.Format; //device.RenderState.PointSpriteEnable = plotType != PlotTypes.Point; //device.RenderState.PointScaleEnable = (markerScale == MarkerScales.World && plotType != PlotTypes.Point) ? true : false; //device.RenderState.PointSize = 0; //device.RenderState.PointScaleA = 0; //device.RenderState.PointScaleB = 0; //device.RenderState.PointScaleC = 10000000f; //switch (plotType) //{ // case PlotTypes.Gaussian: // device.SetTexture(0, Grids.StarProfile); // break; // case PlotTypes.Circle: // device.SetTexture(0, CircleTexture); // break; // case PlotTypes.Point: // device.SetTexture(0, null); // break; // //case PlotTypes.Square: // // device.SetTexture(0, null); // // break; // //case PlotTypes.Custom: // // break; // case PlotTypes.PushPin: // device.SetTexture(0, PushPin.GetPushPinTexture(markerIndex)); // break; // default: // break; //} //device.RenderState.CullMode = Cull.None; //device.RenderState.AlphaBlendEnable = true; //device.RenderState.SourceBlend = Microsoft.DirectX.Direct3D.Blend.SourceAlpha; //if (plotType == PlotTypes.Gaussian) //{ // device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.One; //} //else //{ // device.RenderState.DestinationBlend = Microsoft.DirectX.Direct3D.Blend.InvSourceAlpha; //} //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha; //device.TextureState[0].ColorOperation = TextureOperation.Modulate; //device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; //device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; //device.TextureState[0].AlphaOperation = TextureOperation.Modulate; //device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; //device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; //device.TextureState[1].ColorOperation = TextureOperation.Disable; //device.TextureState[1].ColorArgument1 = TextureArgument.Current; //device.TextureState[1].ColorArgument2 = TextureArgument.Constant; //device.TextureState[1].AlphaOperation = TextureOperation.Disable; //device.TextureState[1].AlphaArgument1 = TextureArgument.Current; //device.TextureState[1].AlphaArgument2 = TextureArgument.Constant; //device.TextureState[1].ConstantColor = Color.FromArgb(255, 255, 255, 255); //// device.TextureState[1].ConstantColor = Color.FromArgb(0, 0, 0, 0); //device.DrawPrimitives(PrimitiveType.PointList, 0, shapeVertexCount); //device.RenderState.PointSpriteEnable = false; ////device.DrawUserPrimitives(PrimitiveType.LineList, segments, points); //device.RenderState.FillMode = oldMode; //device.TextureState[0].ColorOperation = oldTexOp; //device.VertexShader = null; //device.RenderState.ZBufferEnable = zBufferEnabled; //device.RenderState.AlphaBlendEnable = false; //device.RenderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlue; return(true); }
//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; }
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; }
protected override bool PrepVertexBuffer(RenderContext renderContext, float opacity) { table.Lock(); if (lineList != null) { lineList.Clear(); } if (lineList2d != null) { lineList2d.Clear(); } if (triangleList != null) { triangleList.Clear(); } if (pointList != null) { pointList.Clear(); } if (triangleList2d != null) { triangleList2d.Clear(); } if (lineList == null) { lineList = new LineList(); } if (pointList == null) { pointList = new PointList(renderContext); } lineList.TimeSeries = this.timeSeries; if (lineList2d == null) { lineList2d = new LineList(); lineList2d.DepthBuffered = false; } lineList.TimeSeries = this.timeSeries; if (triangleList == null) { triangleList = new TriangleList(); } if (triangleList2d == null) { triangleList2d = new TriangleList(); triangleList2d.DepthBuffered = false; } positions.Clear(); UInt32 currentIndex = 0; // device.RenderState.FillMode = FillMode.WireFrame; Color colorLocal = Color; // colorLocal.A = (byte)(Color.A * Opacity); // for space 3d double ecliptic = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI; Dictionary <string, bool> selectDomain = new Dictionary <string, bool>(); double mr = 0; // double mr = LayerManager.AllMaps[ReferenceFrame].Frame.MeanRadius; if (mr != 0) { meanRadius = mr; } Vector3d position = new Vector3d(); float pointSize = .0002f; Color pointColor = Colors.White; float pointStartTime = 0; float pointEndTime = 0; foreach (string[] row in table.Rows) { try { bool selected = false; if (geometryColumn > -1 || (this.CoordinatesType == CoordinatesTypes.Spherical && (lngColumn > -1 && latColumn > -1)) || ((this.CoordinatesType == CoordinatesTypes.Rectangular) && (XAxisColumn > -1 && YAxisColumn > -1))) { double Xcoord = 0; double Ycoord = 0; double Zcoord = 0; double alt = 1; double altitude = 0; double distParces = 0; double factor = GetScaleFactor(AltUnit, 1); if (altColumn == -1 || AltType == AltTypes.SeaLevel || bufferIsFlat) { alt = 1; if (astronomical & !bufferIsFlat) { alt = UiTools.AuPerLightYear * 100; } } else { if (AltType == AltTypes.Depth) { factor = -factor; } alt = 0; try { alt = double.Parse(row[altColumn]); } catch { } if (astronomical) { factor = factor / (1000 * UiTools.KilometersPerAu); distParces = (alt * factor) / UiTools.AuPerParsec; altitude = (factor * alt); alt = (factor * alt); } else if (AltType == AltTypes.Distance) { altitude = (factor * alt); alt = (factor * alt / meanRadius); } else { altitude = (factor * alt); alt = 1 + (factor * alt / meanRadius); } } //todo remove hack when alt is fixed //alt = 1; if (CoordinatesType == CoordinatesTypes.Spherical && lngColumn > -1 && latColumn > -1) { //Xcoord = Coordinates.Parse(row[lngColumn]); //Ycoord = Coordinates.Parse(row[latColumn]); Xcoord = double.Parse(row[lngColumn]); Ycoord = double.Parse(row[latColumn]); if (astronomical) { if (RaUnits == RAUnits.Hours) { Xcoord *= 015; } if (bufferIsFlat) { // Xcoord += 180; } } double offset = 0; //todo EGM96Geoid.Height(Ycoord, Xcoord); // if (altitude != 0) { //altitude += offset; //alt += offset / meanRadius; } Vector3d pos = Coordinates.GeoTo3dDoubleRad(Ycoord, Xcoord, alt); if (astronomical && !bufferIsFlat) { pos.RotateX(ecliptic); } position = pos; positions.Add(position); } else if (this.CoordinatesType == CoordinatesTypes.Rectangular) { double xyzScale = GetScaleFactor(CartesianScale, CartesianCustomScale) / meanRadius; if (ZAxisColumn > -1) { Zcoord = double.Parse(row[ZAxisColumn]); } Xcoord = double.Parse(row[XAxisColumn]); Ycoord = double.Parse(row[YAxisColumn]); if (XAxisReverse) { Xcoord = -Xcoord; } if (YAxisReverse) { Ycoord = -Ycoord; } if (ZAxisReverse) { Zcoord = -Zcoord; } position = Vector3d.Create((Xcoord * xyzScale), (Zcoord * xyzScale), (Ycoord * xyzScale)); positions.Add(position); } // SqlGeometry pntGeo = SqlGeometry.Point(Xcoord,Ycoord, 4326); //// SqlGeometry pntGeo = SqlGeometry.Point(new SqlChars(String.Format("Point ({0} {1})", Xcoord,Ycoord).ToCharArray()), 4326); // if (!geo.STContains(pntGeo)) // { // continue; // } switch (ColorMap) { case ColorMaps.Same_For_All: pointColor = colorLocal; break; case ColorMaps.Per_Column_Literal: if (ColorMapColumn > -1) { pointColor = ParseColor(row[ColorMapColumn], colorLocal); } else { pointColor = colorLocal; } break; //case ColorMaps.Group_by_Range: // break; //case ColorMaps.Gradients_by_Range: // break; //case ColorMaps.Group_by_Values: // pointColor = ColorDomainValues[row[ColorMapColumn]].MarkerIndex; // break; default: break; } if (sizeColumn > -1) { switch (pointScaleType) { case PointScaleTypes.Linear: pointSize = Single.Parse(row[sizeColumn]); break; case PointScaleTypes.Log: pointSize = (float)Math.Log(Single.Parse(row[sizeColumn])); break; case PointScaleTypes.Power: { double size = 0; try { pointSize = (float)double.Parse(row[altColumn]); } catch { pointSize = 0; } } break; case PointScaleTypes.StellarMagnitude: { double size = 0; try { size = double.Parse(row[sizeColumn]); if (!bufferIsFlat) { size = size - 5 * ((Util.LogN(distParces, 10) - 1)); pointSize = (float)(120000000 / Math.Pow(1.6, size)); } else { pointSize = (float)(40 / Math.Pow(1.6, size)); } } catch { pointSize = 0; } } break; case PointScaleTypes.Constant: pointSize = 1; break; default: break; } } else { pointSize = (float)1; } if (PlotType == PlotTypes.Point) { pointSize = (float)1; } if (astronomical & !bufferIsFlat) { // lastItem.PointSize *= 1000000000000000000000000000f; } if (startDateColumn > -1) { Date dateTime = new Date(row[startDateColumn]); pointStartTime = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate)); if (endDateColumn > -1) { dateTime = new Date(row[endDateColumn]); //dateTime = DateTime.Parse(row[endDateColumn]); pointEndTime = (float)(SpaceTimeController.UtcToJulian(dateTime) - SpaceTimeController.UtcToJulian(baseDate)); } else { pointEndTime = pointStartTime; } } pointList.AddPoint(position, pointColor, new Dates(pointStartTime, pointEndTime), pointSize); if (geometryColumn > -1) { ParseGeometry(row[geometryColumn], pointColor, pointColor, altitude, new Dates(pointStartTime, pointEndTime)); } //if (barChartBitmask != 0) //{ // MakeBarChart(device, row, Ycoord, Xcoord, pointSize, factor, Color.FromArgb(lastItem.Color), selected, new Dates(pointStartTime, pointEndTime)); //} currentIndex++; } } catch { } lines = false; } table.Unlock(); dataDirty = false; dirty = false; return(false); }