public SkyLabel(RenderContext11 renderContext, double ra, double dec, string text, LabelSytle style, double distance) { RA = ra; Dec = dec; Text = text; Style = style; Distance = distance; if (texture == null) { texture = Texture11.FromBitmap(Resources.circle, 0); } var up = new Vector3d(); var textPos = new Vector3d(); if (Earth3d.MainWindow.SolarSystemMode) { pos = Coordinates.RADecTo3d(ra, -dec, distance); up = Coordinates.RADecTo3d(ra, -dec + 90, distance); pos.RotateX(Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI); pos.Add(Planets.GetPlanet3dLocation(SolarSystemObjects.Earth)); up.RotateX(Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) / 180.0 * Math.PI); up.Add(Planets.GetPlanet3dLocation(SolarSystemObjects.Earth)); } else { pos = Coordinates.RADecTo3d(ra+12, dec, distance); textPos = Coordinates.RADecTo3d(ra + 12, dec + 2, distance); up = Coordinates.RADecTo3d(ra+12, dec + 92, distance); } center = new Vector3(9, 9, 0); textBatch = new Text3dBatch(24); if (style == LabelSytle.Telrad) { // Telrad-style labels are always screen-aligned var t3 = new Text3d(new Vector3d(0, 0, 0.1), new Vector3d(0, 1, 0), text, 20, .01); t3.alignment = Text3d.Alignment.Left; textBatch.Add(t3); } else { up.Normalize(); textPos.Normalize(); textBatch.Add(new Text3d(textPos, up, text, 20, .0005)); } }
void InitLineBuffer() { if (lineBuffers.Count == 0) { int count = linePoints.Count; TimeSeriesLineVertexBuffer11 lineBuffer = null; TimeSeriesLineVertex[] linePointList = null; localCenter = new Vector3d(); if (DepthBuffered) { // compute the local center.. foreach (Vector3d point in linePoints) { localCenter.Add(point); } localCenter.X /= count; localCenter.Y /= count; localCenter.Z /= count; } int countLeft = count; int index = 0; int counter = 0; Vector3d temp; foreach (Vector3d point in linePoints) { if (counter >= 100000 || linePointList == null) { if (lineBuffer != null) { lineBuffer.Unlock(); } int thisCount = Math.Min(100000, countLeft); countLeft -= thisCount; lineBuffer = new TimeSeriesLineVertexBuffer11(thisCount, RenderContext11.PrepDevice); linePointList = (TimeSeriesLineVertex[])lineBuffer.Lock(0, 0); // Lock the buffer (which will return our structs) lineBuffers.Add(lineBuffer); lineBufferCounts.Add(thisCount); counter = 0; } temp = point - localCenter; linePointList[counter].Position = temp.Vector311; linePointList[counter].Normal = point.Vector311; linePointList[counter].Tu = (float)lineDates[index / 2].StartDate; linePointList[counter].Tv = (float)lineDates[index / 2].EndDate; linePointList[counter].Color = lineColors[index / 2]; index++; counter++; } lineBuffer.Unlock(); } }
void InitLineBuffer() { if (lineBuffers.Count == 0) { int count = linePoints.Count; PositionVertexBuffer11 lineBuffer = null; SharpDX.Vector3[] linePointList = null; localCenter = new Vector3d(); if (DepthBuffered) { // compute the local center.. foreach (Vector3d point in linePoints) { localCenter.Add(point); } localCenter.X /= count; localCenter.Y /= count; localCenter.Z /= count; } int countLeft = count; int index = 0; int counter = 0; Vector3d temp; foreach (Vector3d point in linePoints) { if (counter >= 100000 || linePointList == null) { if (lineBuffer != null) { lineBuffer.Unlock(); } int thisCount = Math.Min(100000, countLeft); countLeft -= thisCount; lineBuffer = new PositionVertexBuffer11(thisCount, RenderContext11.PrepDevice); linePointList = (SharpDX.Vector3[])lineBuffer.Lock(0, 0); // Lock the buffer (which will return our structs) lineBuffers.Add(lineBuffer); lineBufferCounts.Add(thisCount); counter = 0; } temp = point - localCenter; linePointList[counter] = temp.Vector311; index++; counter++; } lineBuffer.Unlock(); } }
public virtual bool CreateGeometry(RenderContext11 renderContext, bool uiThread) { if (uiThread && !ReadyToRender) { return false; } if (texture == null) { if (PreCreateGeometry(renderContext)) { ReadyToRender = true; TextureReady = true; blendMode = false; if (DemEnabled && DemReady && DemData == null) { if (!LoadDemData()) { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Tile:CreateGeometry:Loading Dem Failed"); } return false; } } return true; } blendMode = (dataset.DataSetType == ImageSetType.Sky || dataset.DataSetType == ImageSetType.Panorama) && !Settings.DomeView; //blendMode = false; if (this.texture == null) { if (TextureReady) { iTileBuildCount++; string localFilename = FileName; if (GrayscaleStyle) { localFilename = UiTools.MakeGrayScaleImage(localFilename); } if (FileExists) { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Tile:CreateGeometry:Loading Texture"); } texture = BufferPool11.GetTexture(localFilename); if (texture == null) { try { // bad texture TextureReady = false; File.Delete(localFilename); } catch { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Tile:CreateGeometry:Loading Texture: Exception"); } errored = true; } return false; } } else { return false; } TexturesLoaded++; } else { return false; } } if (DemEnabled && DemReady && DemData == null) { if (!LoadDemData()) { if (Earth3d.Logging) { Earth3d.WriteLogMessage("Tile:CreateGeometry:Loading Dem Failed"); } return false; } } if (DemEnabled && DemData == null) { return false; } } if (vertexBuffer == null) { vertexBuffer = BufferPool11.GetPNTX2VertexBuffer(VertexCount); vertexBuffer.ComputeSphereOnUnlock = true; indexBuffer = new IndexBuffer11[4]; if (vertexBuffer != null) { this.OnCreateVertexBuffer(vertexBuffer); sphereRadius = vertexBuffer.SphereRadius; sphereCenter = vertexBuffer.SphereCenter; sphereCenter.Add(localCenter); } } ReadyToRender = true; return true; }