public override bool Draw(RenderContext11 renderContext, float opacity, bool flat) { if (object3d == null && issmodel == null) { if (!loading) { Matrix3d worldView = renderContext.World * renderContext.View; Vector3d v = worldView.Transform(Vector3d.Empty); double scaleFactor = Math.Sqrt(worldView.M11 * worldView.M11 + worldView.M22 * worldView.M22 + worldView.M33 * worldView.M33) / 1; double dist = v.Length(); double radius = scaleFactor; // Calculate pixelsPerUnit which is the number of pixels covered // by an object 1 AU at the distance of the planet center from // the camera. This calculation works regardless of the projection // type. int viewportHeight = (int)renderContext.ViewPort.Height; double p11 = renderContext.Projection.M11; double p34 = renderContext.Projection.M34; double p44 = renderContext.Projection.M44; double w = Math.Abs(p34) * dist + p44; float pixelsPerUnit = (float)(p11 / w) * viewportHeight; float radiusInPixels = (float)(radius * pixelsPerUnit); if (radiusInPixels > 0.5f) { BackInitDelegate initBackground = LoadBackground; initBackground.BeginInvoke(null, null); } } } object3d = issmodel; return(base.Draw(renderContext, opacity, flat)); }
private void ComputeFixedSherical(RenderContext11 renderContext) { if (ObservingLocation) { Lat = SpaceTimeController.Location.Lat; Lng = SpaceTimeController.Location.Lng; Altitude = SpaceTimeController.Altitude; } WorldMatrix = Matrix3d.Identity; WorldMatrix.Translate(Translation); double localScale = (1 / renderContext.NominalRadius) * Scale * MeanRadius; WorldMatrix.Scale(new Vector3d(localScale, localScale, localScale)); //WorldMatrix.Scale(new Vector3d(1000, 1000, 1000)); WorldMatrix.Rotate(Quaternion.RotationYawPitchRoll((float)((Heading) / 180.0 * Math.PI), (float)(Pitch / 180.0 * Math.PI), (float)(Roll / 180.0 * Math.PI))); WorldMatrix.Multiply(Matrix3d.RotationZ(-90.0 / 180.0 * Math.PI)); if (RotationalPeriod != 0) { double rotationCurrent = (((SpaceTimeController.JNow - this.ZeroRotationDate) / RotationalPeriod) * Math.PI * 2) % (Math.PI * 2); WorldMatrix.Multiply(Matrix3d.RotationX(-rotationCurrent)); } WorldMatrix.Translate(new Vector3d(1 + (Altitude / renderContext.NominalRadius), 0, 0)); WorldMatrix.Multiply(Matrix3d.RotationZ(Lat / 180 * Math.PI)); WorldMatrix.Multiply(Matrix3d.RotationY(-(Lng) / 180 * Math.PI)); }
public void Draw(RenderContext11 renderContext, int count, Texture11 texture, float opacity) { setupShader(renderContext, texture, opacity); count = Math.Min(this.count, count); switch (renderStrategy) { case RenderStrategy.GeometryShader: renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.PointList; renderContext.SetVertexBuffer(0, vertexBuffer); renderContext.devContext.Draw(count, 0); renderContext.Device.ImmediateContext.GeometryShader.Set(null); break; case RenderStrategy.Instanced: renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; renderContext.SetVertexBuffer(0, spriteCornerVertexBuffer); renderContext.SetVertexBuffer(1, vertexBuffer); renderContext.SetIndexBuffer(indexBuffer); renderContext.devContext.DrawIndexedInstanced(6, count, 0, 0, 0); break; case RenderStrategy.Fallback: renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; renderContext.SetVertexBuffer(0, fallbackVertexBuffer); renderContext.SetIndexBuffer(indexBuffer); renderContext.devContext.DrawIndexed(count * 6, 0, 0); break; } }
public override bool PreDraw(RenderContext11 renderContext, float opacity) { Overlay.color = Color.FromArgb((int)(this.Opacity * opacity * Color.A), Color); Earth3d.MainWindow.KmlMarkers.AddGroundOverlay(Overlay); return(true); }
public void Draw(RenderContext11 renderContext, float Opacity, Color drawColor) { if (glyphCache == null || glyphCache.Version > glyphVersion) { PrepareBatch(); } //todo11 Use Shader renderContext.SetupBasicEffect(BasicEffect.TextureColorOpacity, Opacity, drawColor); renderContext.MainTexture = glyphCache.Texture; renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; renderContext.PreDraw(); if (layout == null) { layout = new SharpDX.Direct3D11.InputLayout(renderContext.Device, renderContext.Shader.InputSignature, new[] { new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0), new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 12, 0), }); } renderContext.Device.ImmediateContext.InputAssembler.InputLayout = layout; renderContext.SetVertexBuffer(vertexBuffer); renderContext.devContext.Draw(vertexBuffer.Count, 0); }
public virtual bool Draw3D(RenderContext11 renderContext, bool showOnlySelected, float opacity, string focusConsteallation, bool reverse) { constToDraw = focusConsteallation; Lineset lsSelected = null; foreach (Lineset ls in this.lines) { bool enabled = boundry ? Settings.Active.ConstellationBoundariesFilter.IsSet(ls.Name) : Settings.Active.ConstellationFiguresFilter.IsSet(ls.Name); if (enabled) { if (constToDraw == ls.Name && boundry) { lsSelected = ls; } else if (!showOnlySelected || !boundry) { DrawSingleConstellation(renderContext, ls, opacity, reverse, true); } } } if (lsSelected != null) { DrawSingleConstellation(renderContext, lsSelected, opacity, reverse, true); } renderContext.setRasterizerState(TriangleCullMode.Off, true); return(true); }
public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Texture11 texture, SharpDX.Direct3D.PrimitiveTopology primitiveType, float opacity = 1.0f) { if (VertexBuffer == null) { VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0])); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0); } renderContext.devContext.InputAssembler.PrimitiveTopology = primitiveType; renderContext.BlendMode = BlendMode.Alpha; renderContext.setRasterizerState(TriangleCullMode.Off); SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11; mat.Transpose(); WarpOutputShader.MatWVP = mat; WarpOutputShader.Use(renderContext.devContext, texture != null, opacity); renderContext.SetVertexBuffer(VertexBufferBinding); DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None); Utilities.Write(box.DataPointer, points, 0, count); renderContext.devContext.UnmapSubresource(VertexBuffer, 0); if (texture != null) { renderContext.devContext.PixelShader.SetShaderResource(0, texture.ResourceView); } else { renderContext.devContext.PixelShader.SetShaderResource(0, null); } renderContext.devContext.Draw(count, 0); }
// This version of DrawEllipse works without a 'head' point public static void DrawEllipse(RenderContext11 renderContext, double semiMajorAxis, double eccentricity, double eccentricAnomaly, Color color, Matrix3d worldMatrix) { if (ellipseShader == null) { ellipseShader = new EllipseShader11(); } if (ellipseWithoutStartPointVertexBuffer == null) { ellipseWithoutStartPointVertexBuffer = CreateEllipseVertexBufferWithoutStartPoint(360); } Matrix3d savedWorld = renderContext.World; renderContext.World = worldMatrix; renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineStrip; renderContext.SetVertexBuffer(ellipseWithoutStartPointVertexBuffer); ellipseShader.UseShader(renderContext, semiMajorAxis, eccentricity, eccentricAnomaly, new SharpDX.Color(color.R, color.G, color.B, color.A), savedWorld, new Vector3d(0.0, 0.0, 0.0)); renderContext.devContext.Draw(ellipseWithoutStartPointVertexBuffer.Count, 0); renderContext.World = savedWorld; }
public override bool Draw3D(RenderContext11 renderContext, float transparancy, Tile parent) { RenderedGeneration = CurrentRenderGeneration; TilesTouched++; InViewFrustum = true; if (!ReadyToRender) { TileCache.AddTileToQueue(this); return(false); } TilesInView++; if (!CreateGeometry(renderContext, true)) { return(false); } renderContext.SetVertexBuffer(vertexBuffer); renderContext.MainTexture = texture; renderContext.SetIndexBuffer(indexBuffer[0]); int partCount = this.TriangleCount; TrianglesRendered += partCount; renderContext.devContext.DrawIndexed(indexBuffer[0].Count, 0, 0); return(true); }
public static void DrawLines(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Matrix mat, bool strip) { if (VertexBuffer == null) { VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0])); VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0); } renderContext.devContext.InputAssembler.PrimitiveTopology = strip ? SharpDX.Direct3D.PrimitiveTopology.LineStrip : SharpDX.Direct3D.PrimitiveTopology.LineList; renderContext.BlendMode = BlendMode.Alpha; renderContext.setRasterizerState(TriangleCullMode.Off); mat.Transpose(); WarpOutputShader.MatWVP = mat; WarpOutputShader.Use(renderContext.devContext, false); renderContext.SetVertexBuffer(VertexBufferBinding); DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None); Utilities.Write(box.DataPointer, points, 0, count); renderContext.devContext.UnmapSubresource(VertexBuffer, 0); renderContext.devContext.PixelShader.SetShaderResource(0, null); renderContext.devContext.Draw(count, 0); }
public SkyLabel(RenderContext11 renderContext, Vector3d point, string text, LabelSytle style) { Text = text; Style = style; if (texture == null) { texture = Texture11.FromBitmap(Properties.Resources.circle, 0); } pos = point; center = new Vector3(9, 9, 0); textBatch = new Text3dBatch(80); if (style == LabelSytle.Telrad) { // Telrad-style labels are always screen-aligned Text3d 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 { // This will produce sky or orbit aligned text textBatch.Add(new Text3d(pos, new Vector3d(0, 1, 0), text, 20, .01)); } }
public void DrawLabels(RenderContext11 renderContext) { if (positions.Count < 1) { return; } InitLabelBuffer(); renderContext.SetVertexBuffer(labelBuffer); renderContext.BlendMode = BlendMode.Alpha; renderContext.DepthStencilMode = DepthStencilMode.Off; renderContext.setRasterizerState(TriangleCullMode.Off); SharpDX.Matrix mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11; mvp.Transpose(); PointSpriteShader11.WVPMatrix = mvp; PointSpriteShader11.Color = SharpDX.Color.White; float adjustedScale = .01f; // (float)(1 / (Earth3d.MainWindow.ZoomFactor / 360)); PointSpriteShader11.ViewportScale = new SharpDX.Vector2((2.0f / renderContext.ViewPort.Width) * adjustedScale, (2.0f / renderContext.ViewPort.Height) * adjustedScale); PointSpriteShader11.PointScaleFactors = new SharpDX.Vector3(0.0f, 0.0f, 10000.0f); PointSpriteShader11.Use(renderContext.Device.ImmediateContext); renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, texture.ResourceView); renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.PointList; renderContext.devContext.Draw(labelBuffer.Count, 0); renderContext.Device.ImmediateContext.GeometryShader.Set(null); }
public static void Draw2D(RenderContext11 renderContext, Texture11 srcTexture, SizeF size, PointF rotationCenter, float rotationAngle, PointF position, System.Drawing.Color color) { cornerPoints[0].Position = MakePosition(position.X, position.Y, -size.Width / 2, -size.Height / 2, rotationAngle).Vector4; cornerPoints[0].Tu = 0; cornerPoints[0].Tv = 0; cornerPoints[0].Color = color; cornerPoints[1].Position = MakePosition(position.X, position.Y, size.Width / 2, -size.Height / 2, rotationAngle).Vector4; cornerPoints[1].Tu = 1; cornerPoints[1].Tv = 0; cornerPoints[1].Color = color; cornerPoints[2].Position = MakePosition(position.X, position.Y, -size.Width / 2, size.Height / 2, rotationAngle).Vector4; cornerPoints[2].Tu = 0; cornerPoints[2].Tv = 1; cornerPoints[2].Color = color; cornerPoints[3].Position = MakePosition(position.X, position.Y, size.Width / 2, size.Height / 2, rotationAngle).Vector4; cornerPoints[3].Tu = 1; cornerPoints[3].Tv = 1; cornerPoints[3].Color = color; renderContext.setRasterizerState(TriangleCullMode.Off); renderContext.DepthStencilMode = DepthStencilMode.Off; DrawForScreen(renderContext, cornerPoints, 4, srcTexture, SharpDX.Direct3D.PrimitiveTopology.TriangleStrip); }
public void ComputeFrame(RenderContext11 renderContext) { if (this.Reference == ReferenceFrames.Sandbox) { WorldMatrix = Matrix3d.Identity; return; } switch (ReferenceFrameType) { case ReferenceFrameTypes.Orbital: ComputeOrbital(renderContext); break; case ReferenceFrameTypes.FixedSherical: ComputeFixedSherical(renderContext); break; case ReferenceFrameTypes.Trajectory: ComputeFrameTrajectory(renderContext); break; case ReferenceFrameTypes.Synodic: ComputeFrameSynodic(renderContext); break; //case ReferenceFrameTypes.FixedRectangular: // ComputeFixedRectangular(renderContext); // break; default: break; } }
protected override void setupShader(RenderContext11 renderContext, Texture11 texture, float opacity) { SharpDX.Matrix mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11; mvp.Transpose(); float aspectRatio = renderContext.ViewPort.Width / renderContext.ViewPort.Height; Color4 color = new Color4(TintColor.Red, TintColor.Green, TintColor.Blue, TintColor.Alpha * opacity); // Set up the shader if (renderStrategy == RenderStrategy.GeometryShader) { PointSpriteShader11.WVPMatrix = mvp; PointSpriteShader11.Color = color; PointSpriteShader11.ViewportScale = new SharpDX.Vector2(1.0f, aspectRatio) * 0.001f; PointSpriteShader11.MinPointSize = MinPointSize; PointSpriteShader11.PointScaleFactors = PointScaleFactors; PointSpriteShader11.Use(renderContext.Device.ImmediateContext); } else { CompatibilityPointSpriteShader.WVPMatrix = mvp; CompatibilityPointSpriteShader.Color = color; CompatibilityPointSpriteShader.ViewportScale = new SharpDX.Vector2(1.0f, aspectRatio) * 0.001f; CompatibilityPointSpriteShader.PointScaleFactors = PointScaleFactors; CompatibilityPointSpriteShader.MinPointSize = MinPointSize; bool useInstancing = renderStrategy == RenderStrategy.Instanced; CompatibilityPointSpriteShader.Use(renderContext.Device.ImmediateContext, useInstancing); } // Set shader resources renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, texture == null ? null : texture.ResourceView); }
public static void DrawConstellationNames(RenderContext11 renderContext, float opacity, Color drawColor) { if (NamesBatch == null) { InitializeConstellationNames(); } NamesBatch.Draw(renderContext, opacity, drawColor); }
private void ComputeFixedRectangular(RenderContext11 renderContext) { WorldMatrix = Matrix3d.Identity; WorldMatrix.Translate(Translation); WorldMatrix.Rotate(Quaternion.RotationYawPitchRoll((float)((Heading) / 180.0 * Math.PI), (float)(Pitch / 180.0 * Math.PI), (float)(Roll / 180.0 * Math.PI))); WorldMatrix.Scale(new Vector3d(Scale, Scale, Scale)); WorldMatrix.Rotate(Quaternion.RotationYawPitchRoll((float)(Coordinates.MstFromUTC2(SpaceTimeController.Now, 0) / 180 * Math.PI), (float)0, (float)0)); }
public override bool CreateGeometry(RenderContext11 renderContext, bool uiThread) { InitializeStarDB(); ReadyToRender = true; return(true); }
private void InitializeRoute(RenderContext11 renderContext) { triangleList = new TriangleList(); triangleList.Decay = 1000; triangleList.Sky = this.Astronomical; triangleList.TimeSeries = true; triangleList.DepthBuffered = false; triangleList.AutoTime = false; int steps = 500; Vector3d start = Coordinates.GeoTo3dDouble(latStart, lngStart); Vector3d end = Coordinates.GeoTo3dDouble(latEnd, lngEnd); Vector3d dir = end - start; dir.Normalize(); Vector3d startNormal = start; startNormal.Normalize(); Vector3d left = Vector3d.Cross(startNormal, dir); Vector3d right = Vector3d.Cross(dir, startNormal); left.Normalize(); right.Normalize(); left.Multiply(.001 * width); right.Multiply(.001 * width); Vector3d lastLeft = new Vector3d(); Vector3d lastRight = new Vector3d(); bool firstTime = true; for (int i = 0; i <= steps; i++) { Vector3d v = Vector3d.Lerp(start, end, i / (float)steps); v.Normalize(); Vector3d cl = v; Vector3d cr = v; cl.Add(left); cr.Add(right); if (!firstTime) { triangleList.AddQuad(lastRight, lastLeft, cr, cl, Color, new Dates(i / (float)steps, 2)); } else { firstTime = false; } lastLeft = cl; lastRight = cr; } }
private void DrawSelectionHandles(RenderContext11 renderContext, Overlay overlay, Texture11 handleTexture) { RectangleF[] handles = MakeHandles(overlay); float angle = overlay.RotationAngle; int i = 0; int j = 0; foreach (RectangleF handle in handles) { points[i + 0].Position = overlay.MakePosition(centerX, centerY, handle.Left - centerX, handle.Top - centerY, angle).Vector4; points[i + 0].Tu = j * (1f / 9f); points[i + 0].Tv = 0; points[i + 0].Color = Color.White; points[i + 1].Position = overlay.MakePosition(centerX, centerY, handle.Right - centerX, handle.Top - centerY, angle).Vector4; points[i + 1].Tu = (j + 1) * (1f / 9f); points[i + 1].Tv = 0; points[i + 1].Color = Color.White; points[i + 2].Position = overlay.MakePosition(centerX, centerY, handle.Left - centerX, handle.Bottom - centerY, angle).Vector4; points[i + 2].Tu = j * (1f / 9f); points[i + 2].Tv = 1; points[i + 2].Color = Color.White; points[i + 3].Position = overlay.MakePosition(centerX, centerY, handle.Right - centerX, handle.Top - centerY, angle).Vector4; points[i + 3].Tu = (j + 1) * (1f / 9f); points[i + 3].Tv = 0; points[i + 3].Color = Color.White; points[i + 4].Position = overlay.MakePosition(centerX, centerY, handle.Right - centerX, handle.Bottom - centerY, angle).Vector4; points[i + 4].Tu = (j + 1) * (1f / 9f); points[i + 4].Tv = 1; points[i + 4].Color = Color.White; points[i + 5].Position = overlay.MakePosition(centerX, centerY, handle.Left - centerX, handle.Bottom - centerY, angle).Vector4; points[i + 5].Tu = j * (1f / 9f); points[i + 5].Tv = 1; points[i + 5].Color = Color.White; i += 6; j++; } if (MultiSelect) { Sprite2d.Draw(renderContext, points, points.Length - 6, handleTexture, SharpDX.Direct3D.PrimitiveTopology.TriangleList); } else { Sprite2d.Draw(renderContext, points, points.Length, handleTexture, SharpDX.Direct3D.PrimitiveTopology.TriangleList); } }
internal static void DrawAll(RenderContext11 rendercontext) { foreach (Reticle reticle in Reticles.Values) { if (reticle.Visible.State) { reticle.Draw(rendercontext); } } }
public override bool Draw(RenderContext11 renderContext, float opacity, bool flat) { renderContext.WorldBase = renderContext.World; renderContext.ViewBase = renderContext.View; Earth3d.MainWindow.MakeFrustum(); renderContext.MakeFrustum(); Earth3d.MainWindow.PaintLayerFullTint11(imageSet, this.Opacity * opacity * 100, Color); return(true); }
public virtual bool Draw3D(RenderContext11 renderContext, float opacity, double ra, double dec) { if (this.Camera == null || Telescope == null) { return(false); } DrawFOV(renderContext, opacity, ra, dec); return(true); }
private void DrawSingleConstellation(RenderContext11 renderContext, Lineset ls, float opacity, bool reverse, bool drawAllSky) { if (!constellationVertexBuffers.ContainsKey(ls.Name)) { int count = ls.Points.Count; SimpleLineList11 linelist = new SimpleLineList11(); linelist.DepthBuffered = false; constellationVertexBuffers[ls.Name] = linelist; Vector3d currentPoint = new Vector3d(); Vector3d temp; for (int i = 0; i < count; i++) { if (ls.Points[i].PointType == PointType.Move || i == 0) { currentPoint = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA); } else { temp = RaDecTo3d(ls.Points[i].Dec, ls.Points[i].RA); linelist.AddLine(currentPoint, temp); currentPoint = temp; } } if (boundry) { temp = RaDecTo3d(ls.Points[0].Dec, ls.Points[0].RA); linelist.AddLine(currentPoint, temp); } } Color col; if (boundry) { if (constToDraw != ls.Name) { col = Properties.Settings.Default.ConstellationBoundryColor; } else { col = Properties.Settings.Default.ConstellationSelectionColor; } } else { col = Properties.Settings.Default.ConstellationFigureColor; } constellationVertexBuffers[ls.Name].DrawLines(renderContext, opacity, col); }
internal void Draw(RenderContext11 renderContext) { if (reticleImage == null) { reticleImage = Texture11.FromBitmap(Properties.Resources.Reticle); } ComputePoints(); Sprite2d.Draw(renderContext, points, 4, reticleImage, SharpDX.Direct3D.PrimitiveTopology.TriangleStrip); }
// Set up render context state required for drawing ground overlays when shaders // are enabled. public void SetupGroundOverlays(RenderContext11 renderContext) { // A shader should be set up already if (renderContext.Shader == null) { renderContext.SetupBasicEffect(BasicEffect.TextureOnly, 1.0f, Color.White); } // Count the number of overlays so that we can choose the appropriate shader int overlayCount = 0; foreach (KmlGroundOverlay overlay in GroundOverlays) { if (overlay.Icon.Texture != null) { ++overlayCount; } } overlayCount = Math.Min(PlanetShader11.MaxOverlayTextures, overlayCount); if (overlayCount == 0) { // No work to do return; } // Get a shader identical to the one currently in use, but which supports // the required number of overlays. PlanetShaderKey key = renderContext.Shader.Key; key.overlayTextureCount = overlayCount; PlanetShader11 overlayShader = PlanetShader11.GetPlanetShader(renderContext.Device, key); renderContext.Shader = overlayShader; renderContext.Shader.DiffuseColor = new SharpDX.Vector4(1.0f, 1.0f, 1.0f, 1.0f); SharpDX.Direct3D11.DeviceContext devContext = renderContext.Device.ImmediateContext; int overlayIndex = 0; foreach (KmlGroundOverlay overlay in GroundOverlays) { Texture11 texture = overlay.Icon.Texture; if (texture != null) { if (overlayIndex < PlanetShader11.MaxOverlayTextures) { renderContext.Shader.SetOverlayTextureMatrix(overlayIndex, overlay.GetMatrix().Matrix11); renderContext.Shader.SetOverlayTextureColor(overlayIndex, overlay.color); renderContext.Shader.SetOverlayTexture(overlayIndex, texture.ResourceView); } ++overlayIndex; } } }
public override bool Draw(RenderContext11 renderContext, float opacity, bool flat) { if (triangleList == null) { InitializeRoute(renderContext); } triangleList.JNow = percentComplete / 100; triangleList.Draw(renderContext, opacity * this.Opacity, TriangleList.CullMode.CounterClockwise); return(true); }
public void SetupGroundOverlays(RenderContext11 renderContext) { foreach (KmlGroundOverlay overlay in GroundOverlays) { if (Earth3d.MainWindow.KmlMarkers != null) { if (overlay.ShouldDisplay()) { Earth3d.MainWindow.KmlMarkers.AddGroundOverlay(overlay); } } } }
public override bool Draw(RenderContext11 renderContext, float opacity, bool flat) { if (ShowEditUi && UiLines != null) { UiLines.DrawLines(renderContext, 1); } else { UiLines = null; } ShowEditUi = false; return(true); }
private void DrawFOV(RenderContext11 renderContext, float opacity, double ra, double dec) { Color color = Color.FromArgb((int)(opacity * 255f), Properties.Settings.Default.FovColor); foreach (Imager chip in Camera.Chips) { double halfWidth = (Math.Atan(chip.Width / (2 * Telescope.FocalLength))) / RC; double halfHeight = (Math.Atan(chip.Height / (2 * Telescope.FocalLength))) / RC; double centerOffsetY = 2 * (Math.Atan(chip.CenterY / (2 * Telescope.FocalLength))) / RC; double centerOffsetX = 2 * (Math.Atan(chip.CenterX / (2 * Telescope.FocalLength))) / RC; SharpDX.Matrix mat = SharpDX.Matrix.RotationX((float)(((chip.Rotation + angle)) / 180f * Math.PI)); mat = SharpDX.Matrix.Multiply(mat, SharpDX.Matrix.RotationZ((float)((dec) / 180f * Math.PI))); mat = SharpDX.Matrix.Multiply(mat, SharpDX.Matrix.RotationY((float)(((24 - (ra + 12))) / 12f * Math.PI))); int count = 4; points = new PositionColoredTextured[count + 1]; int index = 0; points[index].Position = RaDecTo3d(-halfWidth + centerOffsetX, -halfHeight + centerOffsetY).Vector4; points[index].Color = color; index++; points[index].Position = RaDecTo3d(halfWidth + centerOffsetX, -halfHeight + centerOffsetY).Vector4; points[index].Color = color; index++; points[index].Position = RaDecTo3d(halfWidth + centerOffsetX, halfHeight + centerOffsetY).Vector4; points[index].Color = color; index++; points[index].Position = RaDecTo3d(-halfWidth + centerOffsetX, halfHeight + centerOffsetY).Vector4; points[index].Color = color; index++; points[index].Position = RaDecTo3d(-halfWidth + centerOffsetX, -halfHeight + centerOffsetY).Vector4; points[index].Color = color; for (int i = 0; i < points.Length; i++) { points[i].Pos3 = SharpDX.Vector3.TransformCoordinate(points[i].Pos3, mat); } SharpDX.Matrix matV = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11; Sprite2d.DrawLines(renderContext, points, 5, matV, true); } }
public override bool Draw(RenderContext11 renderContext, float opacity, bool flat) { Grids.DrawPlanetGrid(renderContext, opacity * Opacity, Color); Grids.DrawPlanetGridText(renderContext, opacity * Opacity, Color); return true; }