當前位置: 首頁>>代碼示例>>C#>>正文


C# TerraViewer.RenderContext11類代碼示例

本文整理匯總了C#中TerraViewer.RenderContext11的典型用法代碼示例。如果您正苦於以下問題:C# RenderContext11類的具體用法?C# RenderContext11怎麽用?C# RenderContext11使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RenderContext11類屬於TerraViewer命名空間,在下文中一共展示了RenderContext11類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Draw3D

        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;
        }
開發者ID:ngonzalezromero,項目名稱:wwt-windows-client,代碼行數:34,代碼來源:SphericalTile.cs

示例2: DrawEllipse

        // Draw an ellipse with the specified semi-major axis and eccentricity. The orbit is drawn over a single period,
        // fading from full brightness at the given eccentric anomaly.
        //
        // In order to match exactly the position at which a planet is drawn, the planet's position at the current time
        // must be passed as a parameter. positionNow is in the current coordinate system of the render context, not the
        // translated and rotated system of the orbital plane.
        public static void DrawEllipse(RenderContext11 renderContext, double semiMajorAxis, double eccentricity, double eccentricAnomaly, Color color, Matrix3d worldMatrix, Vector3d positionNow)
        {
            if (ellipseShader == null)
            {
                ellipseShader = new EllipseShader11();
            }

            if (ellipseVertexBuffer == null)
            {
                ellipseVertexBuffer = CreateEllipseVertexBuffer( 500);
            }

            Matrix3d savedWorld = renderContext.World;
            renderContext.World = worldMatrix;

            renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineStrip;

            renderContext.SetVertexBuffer(ellipseVertexBuffer);

            ellipseShader.UseShader(renderContext, semiMajorAxis, eccentricity, eccentricAnomaly, new SharpDX.Color(color.R, color.G, color.B, color.A), savedWorld, positionNow);

            renderContext.devContext.Draw(ellipseVertexBuffer.Count, 0);

            renderContext.World = savedWorld;
        }
開發者ID:china-vo,項目名稱:wwt-windows-client,代碼行數:31,代碼來源:Orbit.cs

示例3: CreateGeometry

        public override bool CreateGeometry(RenderContext11 renderContext, bool uiThread)
        {
            InitializeStarDB();

            ReadyToRender = true;
            return true;
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:7,代碼來源:PlotTile.cs

示例4: Draw

        public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Matrix mat, bool triangleStrip)
        {
            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 = triangleStrip ? SharpDX.Direct3D.PrimitiveTopology.TriangleStrip : SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            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);
        }
開發者ID:china-vo,項目名稱:wwt-windows-client,代碼行數:29,代碼來源:Sprite2d.cs

示例5: Draw3D

        public void Draw3D(RenderContext11 renderContext, float transparancy)
        {
            ratio = 1116f / Earth3d.MainWindow.RenderWindow.ClientRectangle.Height;

            if (SingleSelectHandles == null)
            {
                SingleSelectHandles = Texture11.FromBitmap(RenderContext11.PrepDevice, Resources.Selhand);
            }

            if (MultiSelectHandles == null)
            {
                MultiSelectHandles = Texture11.FromBitmap(RenderContext11.PrepDevice, Resources.MultiSelhand);
            }

            if (FocusHandles == null)
            {
                FocusHandles = Texture11.FromBitmap(RenderContext11.PrepDevice, Resources.FocusHandles);
            }

            if (selectionSet.Count > 1)
            {
                foreach (var overlay in selectionSet)
                {
                    if (overlay == focus)
                    {

                        DrawSelectionHandles(renderContext, overlay, FocusHandles);
                    }
                    else
                    {

                        DrawSelectionHandles(renderContext, overlay, MultiSelectHandles);
                    }
                }
            }
            else
            {
                foreach (var overlay in selectionSet)
                {
                    DrawSelectionHandles(renderContext, overlay, SingleSelectHandles);
                }
            }
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:43,代碼來源:Selection.cs

示例6: CreateGeometry

        public override bool CreateGeometry(RenderContext11 renderContext, bool uiThread)
        {
            if (texture == null)
            {
                if (this.texture == null)
                {
                    if (TextureReady)
                    {

                        texture = BufferPool11.GetTexture(FileName);

                        double aspect = (double)texture.Width / (double)texture.Height;

                        if (aspect < 1.5)
                        {
                            domeMaster = true;
                        }

                    }
                    else
                    {
                        return false;
                    }
                }

                iTileBuildCount++;

                if (vertexBuffer == null)
                {
                    vertexBuffer = new VertexBuffer11(typeof(PositionNormalTexturedX2), VertexCount, RenderContext11.PrepDevice);
                    indexBuffer = new IndexBuffer11[4];

                    OnCreateVertexBuffer(vertexBuffer);
                    sphereRadius = 1;
                    sphereCenter = new Vector3d(0, 0, 0);
                }
            }
            ReadyToRender = true;
            return true;
        }
開發者ID:ngonzalezromero,項目名稱:wwt-windows-client,代碼行數:40,代碼來源:SphericalTile.cs

示例7: DrawSelectionHandles

        private void DrawSelectionHandles(RenderContext11 renderContext, Overlay overlay, Texture11 handleTexture)
        {
            var handles = MakeHandles(overlay);
            var angle = overlay.RotationAngle;

            var i = 0;
            var j = 0;
            foreach (var 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, PrimitiveTopology.TriangleList);
            }
            else
            {
                Sprite2d.Draw(renderContext, points, points.Length, handleTexture, PrimitiveTopology.TriangleList);
            }
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:52,代碼來源:Selection.cs

示例8: Draw

        public void Draw(RenderContext11 renderContext, float opacity, Color color)
        {
            if (glyphCache == null || glyphCache.Version > glyphVersion)
            {
                PrepareBatch();
            }

            Color col = Color.FromArgb((int)(color.A * opacity), (int)(color.R * opacity), (int)(color.G * opacity), (int)(color.B * opacity));

            SimpleGeometryShader11.Color = col;

            SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mat.Transpose();

            SimpleGeometryShader11.WVPMatrix = mat;

            renderContext.setRasterizerState(TriangleCullMode.CullCounterClockwise);

            BlendMode bm = renderContext.BlendMode;
            DepthStencilMode dm = renderContext.DepthStencilMode;
            //renderContext.DepthStencilMode = DepthStencilMode.ZReadOnly;
            renderContext.BlendMode = BlendMode.Alpha;

            SimpleGeometryShader11.Use(renderContext.devContext);

            renderContext.MainTexture = glyphCache.Texture;
            // Debug to get Glyhph textures and caches
            //        SharpDX.Direct3D11.Texture2D.ToFile(renderContext.devContext, glyphCache.Texture.Texture, SharpDX.Direct3D11.ImageFileFormat.Png, "c:\\temp\\texture2.png");

            renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;

            renderContext.SetVertexBuffer(vertexBuffer);

            renderContext.devContext.Draw(vertexBuffer.Count, 0);

            renderContext.DepthStencilMode = dm;

            renderContext.BlendMode = bm;

            //dump cache

              //          glyphCache.SaveToXML("c:\\temp\\glyphCache.xml");
        }
開發者ID:china-vo,項目名稱:wwt-windows-client,代碼行數:43,代碼來源:SkyText.cs

示例9: Draw

        public override bool Draw(RenderContext11 renderContext, float opacity, bool flat)
        {
            var matSaved = renderContext.World;
            renderContext.World = renderContext.WorldBaseNonRotating;

            foreach (var frame in frames)
            {
                if (frame.ShowOrbitPath)
                {
                    if (frame.Orbit == null)
                    {
                        frame.Orbit = new Orbit(frame.Elements, 360, Color, 1, (float)renderContext.NominalRadius);
                    }
                    frame.Orbit.Draw3D(renderContext, opacity * Opacity, new Vector3d(0, 0, 0));
                }
            }
            renderContext.World = matSaved;
            return true;
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:19,代碼來源:OrbitLayer.cs

示例10: DrawLabels

        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);
            var mvp = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mvp.Transpose();
            PointSpriteShader11.WVPMatrix = mvp;
            PointSpriteShader11.Color = SharpDX.Color.White;

            var adjustedScale = .01f; // (float)(1 / (Earth3d.MainWindow.ZoomFactor / 360));

            PointSpriteShader11.ViewportScale = new Vector2((2.0f / renderContext.ViewPort.Width) * adjustedScale, (2.0f / renderContext.ViewPort.Height) * adjustedScale);
            PointSpriteShader11.PointScaleFactors = new Vector3(0.0f, 0.0f, 10000.0f);
            PointSpriteShader11.Use(renderContext.Device.ImmediateContext);

            renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, texture.ResourceView);

            renderContext.devContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.PointList;
            renderContext.devContext.Draw(labelBuffer.Count, 0);

            renderContext.Device.ImmediateContext.GeometryShader.Set(null);
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:30,代碼來源:Label.cs

示例11: Draw

        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);
        }
開發者ID:ngonzalezromero,項目名稱:wwt-windows-client,代碼行數:11,代碼來源:Reticle.cs

示例12: RenderPart

        public override void RenderPart(RenderContext11 renderContext, int part, float opacity, bool combine)
        {
            if (dsm != null && dsm.DsmIndex != null)
            {
                renderContext.SetIndexBuffer(dsm.DsmIndex);
                renderContext.SetVertexBuffer(dsm.VertexBuffer);
                if (dsm.Subsets.Length > 4)
                {
                    switch (part)
                    {
                        case 0:
                            part = 2;
                            break;
                        case 1:
                            part = 3;
                          //  return;
                            break;
                        case 2:
                            part = 0;

                            break;
                        case 3:
                            part = 1;

                            break;
                    }

                    renderContext.devContext.DrawIndexed(dsm.Subsets[part + 1] - dsm.Subsets[part], dsm.Subsets[part], 0);
                }
                else
                {
                    if (dsm.Subsets.Length > 0)
                    {
                        renderContext.devContext.DrawIndexed(dsm.Subsets[0] , 0, 0);

                    }

                }
            }
            else
            {
                base.RenderPart(renderContext, part, opacity, combine);
            }
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:44,代碼來源:MercatorTile.cs

示例13: Draw2D

        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);
        }
開發者ID:china-vo,項目名稱:wwt-windows-client,代碼行數:26,代碼來源:Sprite2d.cs

示例14: Draw

        public void Draw(RenderContext11 renderContext, bool space3d)
        {
            var cam = Vector3d.TransformCoordinate(Earth3d.MainWindow.RenderContext11.CameraPosition, Matrix3d.Invert(Earth3d.WorldMatrix));

            if (!space3d)
            {
                if (Vector3d.Dot(cam, pos) < 0)
                {
                    return;
                }
            }
            var temp = pos;

            if (Earth3d.MainWindow.SolarSystemMode)
            {
                temp.Add( Earth3d.MainWindow.viewCamera.ViewTarget);
            }

            var wvp = renderContext.World * renderContext.View * renderContext.Projection;

            var screenPos = Vector3.Project(temp.Vector311, renderContext.ViewPort.TopLeftX, renderContext.ViewPort.TopLeftY,renderContext.ViewPort.Width,renderContext.ViewPort.Height, 0, 1, wvp.Matrix11);

            // Get the w component of the transformed object position; if it's negative the
            // object is behind the viewer.
            var w = wvp.M14 * temp.X + wvp.M24 * temp.Y + wvp.M34 * temp.Z + wvp.M44;
            if (w < 0.0 && Earth3d.MainWindow.SolarSystemMode)
            {
                // Don't show labels that are behind the viewer
                return;
            }

            screenPos = new Vector3((int)screenPos.X, (int)screenPos.Y, 1);

            Sprite2d.Draw2D(renderContext, texture, new SizeF(20, 20), new PointF(0, 0), 0, new PointF(screenPos.X, screenPos.Y), Color.White);

            if (Earth3d.MainWindow.SolarSystemMode || Style == LabelSytle.Telrad)
            {
                var worldMatrix = renderContext.World;
                var viewMatrix = renderContext.View;
                var projectionMatrix = renderContext.Projection;

                var labelScale = Earth3d.MainWindow.SolarSystemMode ? 8.0 : 30.0;
                renderContext.World =
                    Matrix3d.Scaling(labelScale, labelScale, 1.0) *
                    Matrix3d.Translation(screenPos.X + 10.0, -screenPos.Y, 0.0) *
                    Matrix3d.Translation(-renderContext.ViewPort.Width / 2, renderContext.ViewPort.Height / 2, 0);
                renderContext.View = Matrix3d.Identity;
                renderContext.Projection = Matrix3d.OrthoLH(renderContext.ViewPort.Width, renderContext.ViewPort.Height, 1, -1);

                renderContext.BlendMode = BlendMode.PremultipliedAlpha;
                textBatch.Draw(renderContext, 1, Color.White);

                renderContext.World = worldMatrix;
                renderContext.View = viewMatrix;
                renderContext.Projection = projectionMatrix;
            }
            else
            {
                renderContext.BlendMode = BlendMode.PremultipliedAlpha;
                textBatch.Draw(renderContext, 1, Color.White);
            }

            //todo11 Implement this
            //sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.SortTexture);

            //sprite.Draw(texture, rect, center, screenPos, Color.White);
            //Rectangle recttext = new Rectangle((int)(screenPos.X + 15), (int)(screenPos.Y - 8), 0, 0);
            //Earth3d.MainWindow.labelFont.DrawText(sprite, Text, recttext,
            //DrawTextFormat.NoClip, System.Drawing.Color.White);

            //sprite.End();
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:72,代碼來源:Label.cs

示例15: SkyLabel

        public SkyLabel(RenderContext11 renderContext, Vector3d point, string text, LabelSytle style)
        {
            Text = text;
            Style = style;

            if (texture == null)
            {
                texture = Texture11.FromBitmap(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
                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
            {
                // This will produce sky or orbit aligned text
                textBatch.Add(new Text3d(pos, new Vector3d(0,1,0), text, 20, .01));
            }
        }
開發者ID:bluephoton,項目名稱:wwt-windows-client,代碼行數:29,代碼來源:Label.cs


注:本文中的TerraViewer.RenderContext11類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。