当前位置: 首页>>代码示例>>C#>>正文


C# Device.DrawUserPrimitives方法代码示例

本文整理汇总了C#中Device.DrawUserPrimitives方法的典型用法代码示例。如果您正苦于以下问题:C# Device.DrawUserPrimitives方法的具体用法?C# Device.DrawUserPrimitives怎么用?C# Device.DrawUserPrimitives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device.DrawUserPrimitives方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawBox

        public static void DrawBox(int ulx, int uly, int width, int height, float z, int color, Device device)
        {
            CustomVertex.TransformedColored[] verts = new CustomVertex.TransformedColored[4];
            verts[0].X = (float) ulx;
            verts[0].Y = (float) uly;
            verts[0].Z = z;
            verts[0].Color = color;

            verts[1].X = (float) ulx;
            verts[1].Y = (float) uly + height;
            verts[1].Z = z;
            verts[1].Color = color;

            verts[2].X = (float) ulx + width;
            verts[2].Y = (float) uly;
            verts[2].Z = z;
            verts[2].Color = color;

            verts[3].X = (float) ulx + width;
            verts[3].Y = (float) uly + height;
            verts[3].Z = z;
            verts[3].Color = color;

            device.VertexFormat = CustomVertex.TransformedColored.Format;
            device.TextureState[0].ColorOperation = TextureOperation.Disable;
            device.DrawUserPrimitives(PrimitiveType.TriangleStrip, verts.Length - 2, verts);
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:27,代码来源:WidgetUtil.cs

示例2: Render

 public override void Render(Device device)
 {
     device.VertexFormat = CustomVertex.PositionTextured.Format;
     device.RenderState.Lighting = false;
     device.RenderState.FillMode = FillMode.Solid;
     device.RenderState.CullMode = Cull.None;
     foreach(CustomVertex.PositionTextured[] list in RawTriangles)
         device.DrawUserPrimitives(PrimitiveType.TriangleList, list.Length / 3, list);
 }
开发者ID:tirnoney,项目名称:DAIToolsWV,代码行数:9,代码来源:MeshRenderObject.cs

示例3: Draw

 public override void Draw(ref Device device)
 {
     device.SetTexture(0, texture);
       Matrix world = device.Transform.World;
       device.Transform.World = worldMatrix;
       device.VertexFormat = CustomVertex.PositionColoredTextured.Format;
       device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices);
       device.Transform.World = world;
 }
开发者ID:stevenandrewcarter,项目名称:Bombard,代码行数:9,代码来源:MousePointer.cs

示例4: Draw

 /// <summary>
 /// 剛体の描画
 /// </summary>
 /// <param name="device">SlimDXデバイス</param>
 public void Draw(Device device)
 {
     device.VertexFormat = PDDVertex.FVF;
     Viewport viewport = device.Viewport;
     float aspectRatio = (float)viewport.Width / (float)viewport.Height;
     Matrix view, proj;
     SlimMMDXCore.Instance.Camera.GetCameraParam(aspectRatio, out view, out proj);
     device.SetTransform(TransformState.World, Matrix.Identity);
     device.SetTransform(TransformState.View, view);
     device.SetTransform(TransformState.Projection, proj);
     device.DrawUserPrimitives(PrimitiveType.LineList, primitiveCount, lines);
     primitiveCount = 0;
 }
开发者ID:himapo,项目名称:ccm,代码行数:17,代码来源:PhysicsDebugDraw.cs

示例5: OnRenderFrame

        public override void OnRenderFrame(Device device, float elapsedTime)
        {
            base.OnRenderFrame(device, elapsedTime);

            // Set render states
            device.SetRenderState(RenderStates.ZBufferWriteEnable, false);
            device.SetRenderState(RenderStates.ZEnable, false);
            device.SetRenderState(RenderStates.Lighting, false);
            device.SetRenderState(RenderStates.AlphaBlendEnable, true);

            device.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
            device.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);

            device.VertexFormat = CustomVertex.TransformedColored.Format;
            device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, verts);
        }
开发者ID:kensniper,项目名称:castle-butcher,代码行数:16,代码来源:BeginGameLayer.cs

示例6: Paint

        public override void Paint(Device device)
        {
            Cull cull = device.RenderState.CullMode;
            //bool alphaEnable = device.RenderState.AlphaBlendEnable;

            device.RenderState.CullMode = Cull.None;
            //device.RenderState.AlphaBlendEnable = true;
            //    device.RenderState.SourceBlend = Blend.BothSourceAlpha;
            //    device.RenderState.DestinationBlend = Blend.DestinationColor;

                //device.SetStreamSource(0, m_roiVB, 0);
                device.VertexFormat = CustomVertex.TransformedColored.Format;
                //device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
                device.DrawUserPrimitives(PrimitiveType.LineList, 1, verts);
            //device.RenderState.AlphaBlendEnable = alphaEnable;
            device.RenderState.CullMode = cull;
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:17,代码来源:LineTrackingService.cs

示例7: DrawLine

        public static void DrawLine(Vector2[] linePoints, int color, Device device)
        {
            CustomVertex.TransformedColored[] lineVerts = new CustomVertex.TransformedColored[linePoints.Length];

            for (int i = 0; i < linePoints.Length; i++) {
                lineVerts[i].X = linePoints[i].X;
                lineVerts[i].Y = linePoints[i].Y;
                lineVerts[i].Z = 0.0f;

                lineVerts[i].Color = color;
            }

            device.TextureState[0].ColorOperation = TextureOperation.Disable;
            device.VertexFormat = CustomVertex.TransformedColored.Format;

            device.DrawUserPrimitives(PrimitiveType.LineStrip, lineVerts.Length - 1, lineVerts);
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:17,代码来源:WidgetUtil.cs

示例8: DrawMesh

 public void DrawMesh(Device device, int lod)
 {
     try
     {
         device.VertexFormat = CustomVertex.PositionTextured.Format;
         device.RenderState.Lighting = false;
         device.RenderState.FillMode = FillMode.Solid;
         device.RenderState.CullMode = Cull.None;
         if(DirectXSections[lod].Length > 2)
             device.DrawUserPrimitives(PrimitiveType.TriangleList, DirectXSections[lod].Length / 3, DirectXSections[lod]);
         device.RenderState.FillMode = FillMode.WireFrame;
         device.RenderState.Lighting = true;
         if (DirectXSections[lod].Length > 2)
             device.DrawUserPrimitives(PrimitiveType.TriangleList, DirectXSections[lod].Length / 3, DirectXSections[lod]);
     }
     catch (Direct3DXException)
     {
     }
 }
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:19,代码来源:SkeletalMesh.cs

示例9: Render

        public override void Render(Device p_dDevice, Control p_cRenderWindow)
        {
            if (m_Base3DModel.IsModelChanged)
            {
                //ClInformationSender.SendInformation("Creating render object ("+m_Base3DModel.ModelPointsCount+" points)...", ClInformationSender.eInformationType.eTextExternal);
                m_lRenderModelVertex.Clear();
                m_lRenderLines.Clear();
                m_Base3DModel.ResetVisitedPoints();
                Cl3DModel.Cl3DModelPointIterator iterator = m_Base3DModel.GetIterator();
                List<KeyValuePair<string, Cl3DModel.Cl3DModelPointIterator>> specificPoints = m_Base3DModel.GetAllSpecificPoints();
                float meanX = 0;
                float meanY = 0;
                float meanZ = 0;
                if (iterator.IsValid())
                {
                    do
                    {
                        meanX += -iterator.X;
                        meanY += iterator.Y;
                        meanZ += iterator.Z;
                        Color pointColor = new Color();
                        bool isSpecificPoint = false;
                        foreach (KeyValuePair<string, Cl3DModel.Cl3DModelPointIterator> specificPoint in specificPoints)
                        {
                            if (iterator.PointID == specificPoint.Value.PointID)
                            {
                                isSpecificPoint = true;
                                break;
                            }
                        }
                        if (!isSpecificPoint)
                            pointColor = iterator.Color;
                        else
                            pointColor = Color.Red;

                        m_lRenderModelVertex.Add(new CustomVertex.PositionColored(-iterator.X, iterator.Y, iterator.Z, pointColor.ToArgb()));

                        List<Cl3DModel.Cl3DModelPointIterator> neighbors = iterator.GetListOfNeighbors();
                        foreach (Cl3DModel.Cl3DModelPointIterator neighbor in neighbors)
                        {
                            if (!neighbor.AlreadyVisited)
                            {
                                m_lRenderLines.Add(new CustomVertex.PositionColored(-iterator.X, iterator.Y, iterator.Z, pointColor.ToArgb()));
                                m_lRenderLines.Add(new CustomVertex.PositionColored(-neighbor.X, neighbor.Y, neighbor.Z, neighbor.Color.ToArgb()));
                            }
                        }
                        iterator.AlreadyVisited = true;
                    }
                    while (iterator.MoveToNext());
                }

                m_Base3DModel.IsModelChanged = false;
                m_Base3DModel.ResetVisitedPoints();
                #if RENDER_1
                ClCamera camera = ClRender.getInstance().getCamera();
                if (camera != null)
                {
                    meanX /= m_lRenderModelVertex.Count;
                    meanY /= m_lRenderModelVertex.Count;
                    meanZ /= m_lRenderModelVertex.Count;
                    camera.MoveCameraLookAt(meanX, meanY, meanZ);
                //    ClRender.getInstance().AddRenderObj(new ClCoordinateSystem(meanX,meanY,meanZ));
                }
                #endif
            }

            if (m_lRenderModelVertex.Count != 0)
            {
                p_dDevice.VertexFormat = CustomVertex.PositionColored.Format;
                if (m_lRenderLines.Count != 0)
                    p_dDevice.DrawUserPrimitives(PrimitiveType.LineList, m_lRenderLines.Count / 2, m_lRenderLines.ToArray());

                p_dDevice.DrawUserPrimitives(PrimitiveType.PointList, m_lRenderModelVertex.Count, m_lRenderModelVertex.ToArray());
            }
        }
开发者ID:hporange,项目名称:3d-face-models-preprocessing-tool,代码行数:75,代码来源:Cl3DRenderObject.cs

示例10: Render

 public void Render(Device device)
 {
     device.RenderState.Lighting = false;
     device.Transform.World = MyMatrix;
     device.VertexFormat = CustomVertex.PositionColored.Format;
     if (points.Length != 0 && !isSelected)
         device.DrawUserPrimitives(PrimitiveType.LineList, points.Length / 2, points);
     if (points_sel.Length != 0 && isSelected)
         device.DrawUserPrimitives(PrimitiveType.LineList, points_sel.Length / 2, points_sel);
 }
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:10,代码来源:TargetPoint.cs

示例11: RenderCoordsystem

 public static void RenderCoordsystem(Device device)
 {
     device.RenderState.FillMode = FillMode.WireFrame;
     device.VertexFormat = CustomVertex.PositionColored.Format;
     device.RenderState.Ambient = Color.Black;
     device.DrawUserPrimitives(PrimitiveType.LineList, 3, lines);
     device.RenderState.Ambient = Color.LightGray;
 }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:8,代码来源:Renderer.cs

示例12: DrawMesh

        public void DrawMesh(Device device)
        {
            device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
            device.RenderState.Lighting = false;
            if(DirectXGlobal.DrawWireFrame)
                device.RenderState.FillMode = FillMode.WireFrame;
            else
                device.RenderState.FillMode = FillMode.Solid;
            if (Mesh.Mat.Lods != null) 
            for (int i = 0; i < Mesh.Mat.Lods[0].SectionCount; i++)
            {
                Section sec = Mesh.Mat.Lods[0].Sections[i];
                if (DirectXGlobal.Tex_Default != null)
                    device.SetTexture(0, DirectXGlobal.Tex_Default);
                else
                    DirectXGlobal.Tex_Default = TextureLoader.FromFile(device, Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\Default.bmp");
                if (sec.RawTriangles == null)
                {
                    sec.RawTriangles = new CustomVertex.PositionNormalTextured[sec.NumFaces1 * 3];
                    if (Mesh.IdxBuf.Indexes.Count() != 0)
                        for (int j = 0; j < sec.NumFaces1; j++)
                        {
                            int Idx = Mesh.IdxBuf.Indexes[sec.FirstIdx1 + j * 3];
                            Vector3 pos = Mesh.Vertices.Points[Idx];
                            Vector2 UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0,0,0), UV.X, UV.Y);
                            Idx = Mesh.IdxBuf.Indexes[sec.FirstIdx1 + j * 3 + 1];
                            pos = Mesh.Vertices.Points[Idx];
                            UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3 + 1] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0, 0, 0), UV.X, UV.Y);
                            Idx = Mesh.IdxBuf.Indexes[sec.FirstIdx1 + j * 3 + 2];
                            pos = Mesh.Vertices.Points[Idx];
                            UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3 + 2] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0, 0, 0), UV.X, UV.Y);
                        }
                    else
                        for (int j = 0; j < sec.NumFaces1; j++)
                        {
                            int Idx = Mesh.RawTris.RawTriangles[sec.FirstIdx1 / 3 + j].v0;
                            Vector3 pos = Mesh.Vertices.Points[Idx];
                            Vector2 UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0, 0, 0), UV.X, UV.Y);
                            Idx = Mesh.RawTris.RawTriangles[sec.FirstIdx1 / 3 + j].v1;
                            pos = Mesh.Vertices.Points[Idx];
                            UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3 + 1] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0, 0, 0), UV.X, UV.Y);
                            Idx = Mesh.RawTris.RawTriangles[sec.FirstIdx1 / 3 + j].v2;
                            pos = Mesh.Vertices.Points[Idx];
                            UV = Mesh.Edges.UVSet[Idx].UVs[0];
                            sec.RawTriangles[j * 3 + 2] = new CustomVertex.PositionNormalTextured(pos, new Vector3(0, 0, 0), UV.X, UV.Y);
                        }
                    for (int j = 0; j < sec.RawTriangles.Length; j+=3)
                    {
                        Vector3 p0 = sec.RawTriangles[j].Position - sec.RawTriangles[j + 1].Position;
                        Vector3 p1 = sec.RawTriangles[j].Position - sec.RawTriangles[j + 2].Position;
                        p0.Normalize();
                        p1.Normalize();
                        Vector3 n = Vector3.Cross(p0, p1);
                        sec.RawTriangles[j].Normal = n;
                        sec.RawTriangles[j + 1].Normal = n;
                        sec.RawTriangles[j + 2].Normal = n;
                    }

                }
                device.DrawUserPrimitives(PrimitiveType.TriangleList, sec.NumFaces1, sec.RawTriangles);
            }
        }
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:67,代码来源:StaticMesh.cs

示例13: RenderDatabaseTree

        public static TextureMatrixLayer[] RenderDatabaseTree(RasterDatabase.RasterDatabase db, Device device)
        {
            // setup device
            device.RenderState.ZBufferEnable = false;
            device.Indices = null;
            device.VertexFormat = CustomVertex.TransformedTextured.Format;
            //device.Transform.World = Matrix.Identity;
            Surface rt0 = device.GetRenderTarget(0);

            // setup template quad
            CustomVertex.TransformedTextured[] tQuad = new CustomVertex.TransformedTextured[4];

            foreach(DataLayer layer in db.Layers)
            {
                RectangleGroupQuadTree tree = db.ProduceLayerMipMap(layer, 2048);
                Texture[][] textures = new Texture[tree.Depth][];
                for (int i = 1; i <= tree.Depth; i++)
                {
                    RectangleGroupQuadTree.GroupNode[] nodes;
                    tree.GetNodes(i, out nodes);
                    textures[i] = new Texture[nodes.Length];

                    // render each node to texture
                    int texIdx = 0;
                    foreach (RectangleGroupQuadTree.GroupNode node in nodes)
                    {
                        Texture texture = textures[i][texIdx++] = new Texture(device, node.NodeArea.Width,
                                                                              node.NodeArea.Height, 0,
                                                                              Usage.WriteOnly, Format.X8R8G8B8,
                                                                              Pool.Managed);
                        device.SetRenderTarget(0, texture.GetSurfaceLevel(0));

                        device.Clear(ClearFlags.Target, Color.Black, 1, 0);
                        device.BeginScene();

                        // draw each rectangle quad
                        foreach (DataArea area in node.Rectangles)
                        {
                            // setup quad
                            tQuad[0] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Top, 1, 1,
                                                                            area.TexCoords.Left, area.TexCoords.Top);
                            tQuad[1] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Top, 1, 1,
                                                                            area.TexCoords.Right, area.TexCoords.Top);
                            tQuad[2] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Bottom, 1, 1,
                                                                            area.TexCoords.Left, area.TexCoords.Bottom);
                            tQuad[3] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Bottom, 1, 1,
                                                                            area.TexCoords.Right, area.TexCoords.Bottom);

                            // render quad
                            device.SetTexture(0, (Texture)area.Data);
                            device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, tQuad);
                        }
                        device.EndScene();
                    }
                }
            }

            device.SetRenderTarget(0, rt0);
            device.RenderState.ZBufferEnable = true;

            return null;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:62,代码来源:RasterDatabaseRenderer.cs

示例14: DrawMesh

 public void DrawMesh(Device device)
 {
     try
     {                
         device.SetTexture(0, DirectXGlobal.Tex_Default);
         device.VertexFormat = CustomVertex.PositionTextured.Format;
         device.RenderState.Lighting = false;
         device.RenderState.FillMode = FillMode.Solid;
         device.RenderState.CullMode = Cull.None;
         foreach (CustomVertex.PositionTextured[] list in DirectXSections)
             if (list.Length != 0)
                 device.DrawUserPrimitives(PrimitiveType.TriangleList, list.Length / 3, list);
         device.SetTexture(0, null);
         device.VertexFormat = CustomVertex.PositionTextured.Format;
         device.RenderState.Lighting = true;
         device.RenderState.FillMode = FillMode.WireFrame;
         foreach (CustomVertex.PositionTextured[] list in DirectXSections)
             if (list.Length != 0)
                 device.DrawUserPrimitives(PrimitiveType.TriangleList, list.Length / 3, list);
         
     }
     catch (Exception e)
     {
     }
 }
开发者ID:ME3Explorer,项目名称:ME3Explorer,代码行数:25,代码来源:SkeletalMeshOld.cs

示例15: PaintPoint

        public void PaintPoint(Device device, Vector3 screenPosition)
        {
            Cull cull = device.RenderState.CullMode;
            bool alphaEnable = device.RenderState.AlphaBlendEnable;

            device.RenderState.CullMode = Cull.None;
            device.RenderState.AlphaBlendEnable = true;

            device.RenderState.SourceBlend = Blend.BothSourceAlpha;
            device.RenderState.DestinationBlend = Blend.DestinationColor;

            pointVerts[0].X = screenPosition.X;
            pointVerts[0].Y = screenPosition.Y;
            pointVerts[0].Color = Color.Red.ToArgb();

            device.VertexFormat = CustomVertex.TransformedColored.Format;
            device.DrawUserPrimitives(PrimitiveType.PointList, 1, pointVerts);

            device.RenderState.AlphaBlendEnable = alphaEnable;
            device.RenderState.CullMode = cull;
        }
开发者ID:rforsbach,项目名称:Treu-Structure,代码行数:21,代码来源:HoverPainter.cs


注:本文中的Device.DrawUserPrimitives方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。