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


C# Device.DrawIndexedPrimitives方法代码示例

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


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

示例1: Render

        public int vertexStartIndex; // Start offset for VB

        #endregion Fields

        #region Methods

        public void Render(Effect effect, Device device, bool setMaterial)
        {
            // Set material
            if (setMaterial)
                material.ApplyMaterial(device);

            // Calculate number of primitives to draw.
            int primCount = 0;
            switch (Type)
            {
                case PrimitiveType.TriangleList:
                    primCount = nIndices / 3;
                    break;
                case PrimitiveType.TriangleFan:
                case PrimitiveType.TriangleStrip:
                    primCount = nIndices - 2;
                    break;
            }

            // Draw
            if (primCount > 0)
            {
                device.DrawIndexedPrimitives(Type, vertexStartIndex, lowestIndiceValue, nVerts, IndiceStartIndex, primCount);
            }
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:31,代码来源:DynamicItem.cs

示例2: DrawMeshes

        /// <summary>
        /// The draw meshes.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <remarks></remarks>
        public void DrawMeshes(ref Device device)
        {
            for (int i = 0; i < this.vb.Count; i++)
            {
                device.SetStreamSource(0, vb[i], 0);
                device.VertexFormat = CustomVertex.PositionColored.Format;
                device.Indices = ib[i];

                device.RenderState.AlphaBlendEnable = false;
                device.RenderState.AlphaTestEnable = false;

                device.Transform.World = Matrix.Identity;
                device.SetTexture(0, null);

                PrimitiveType pt;

                pt = PrimitiveType.TriangleList;
                device.DrawIndexedPrimitives(pt, 0, 0, this.verticeCount[i], 0, this.faceCount[i] / 3);
            }
        }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:25,代码来源:coll.cs

示例3: Draw

        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <remarks></remarks>
        public void Draw(ref Device device)
        {
            device.SetStreamSource(0, vb, 0);
            device.VertexFormat = CustomVertex.PositionColored.Format;
            device.Indices = ib;

            device.RenderState.AlphaBlendEnable = false;
            device.RenderState.AlphaTestEnable = false;

            device.SetTexture(0, null);

            PrimitiveType pt;

            pt = PrimitiveType.TriangleList;
            device.DrawIndexedPrimitives(pt, 0, 0, this.verticeCount, 0, this.faceCount / 3);
        }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:21,代码来源:coll.cs

示例4: Render

 public void Render(Device dev)
 {
     dev.SetStreamSource(0, vb, 0,CustomVertex.PositionTextured.StrideSize);
     dev.Indices = ib;
     dev.VertexFormat = CustomVertex.PositionTextured.Format;
     dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, 12);
 }
开发者ID:kensniper,项目名称:castle-butcher,代码行数:7,代码来源:SkyBox.cs

示例5: DrawColoredRectangle

		public static void DrawColoredRectangle(Device dev,RectangleF rect,Color color){
			VertexBuffer vb=null;
			IndexBuffer ib=null;
			try{
				int colorArgb=color.ToArgb();
				CustomVertex.PositionColored[] quadVerts=new CustomVertex.PositionColored[] {
						new CustomVertex.PositionColored(rect.Left,rect.Bottom,0,colorArgb),
						new CustomVertex.PositionColored(rect.Left,rect.Top,0,colorArgb),
						new CustomVertex.PositionColored(rect.Right,rect.Top,0,colorArgb),
						new CustomVertex.PositionColored(rect.Right,rect.Bottom,0,colorArgb),
					};
				vb=new VertexBuffer(typeof(CustomVertex.PositionColored),
					CustomVertex.PositionColored.StrideSize*quadVerts.Length,
					dev,Usage.WriteOnly,CustomVertex.PositionColored.Format,Pool.Managed);
				vb.SetData(quadVerts,0,LockFlags.None);
				int[] indicies=new int[] { 0,1,2,0,2,3 };
				ib=new IndexBuffer(typeof(int),indicies.Length,dev,Usage.None,Pool.Managed);
				ib.SetData(indicies,0,LockFlags.None);
				dev.VertexFormat=CustomVertex.PositionColored.Format;
				dev.SetStreamSource(0,vb,0);
				dev.Indices=ib;
				dev.DrawIndexedPrimitives(PrimitiveType.TriangleList,0,0,quadVerts.Length,0,indicies.Length/3);
			}finally{
				if(vb!=null){
					vb.Dispose();
					vb=null;
				}
				if(ib!=null){
					ib.Dispose();
					ib=null;
				}
			}
		}
开发者ID:mnisl,项目名称:OD,代码行数:33,代码来源:ToothChartDirectX.cs

示例6: Draw


//.........这里部分代码省略.........
                            {
                                device.RenderState.SpecularEnable = true;
                                device.RenderState.SpecularMaterialSource = ColorSource.Material;
                                device.TextureState[0].ColorOperation = TextureOperation.Modulate;
                                device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
                                device.TextureState[0].ColorArgument2 = TextureArgument.Specular;
                            }
                        }
                        else
                        {
                            device.RenderState.AlphaBlendEnable = true;
                            device.RenderState.AlphaTestEnable = true;
                            device.RenderState.ReferenceAlpha = 180;
                            device.RenderState.AlphaFunction = Compare.Greater;

                            device.RenderState.SourceBlend = Blend.SourceAlpha;
                            device.RenderState.DestinationBlend = Blend.One; // was Blend.InvSourceAlpha;

                            device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
                            device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
                            device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;

                            /*
                            device.TextureState[0].AlphaOperation = TextureOperation.Modulate; // BlendTextureAlpha;
                            device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
                            device.TextureState[0].AlphaArgument2 = TextureArgument.Current;
                            */
                        }

                        if (shad.BitmapTextures != null)
                        {
                            for (int xxx = 1; xxx <= shad.BitmapTextures.Length; xxx++)
                            {
                                device.SetTexture(xxx, shad.BitmapTextures[xxx - 1]);
                                if (shad.Alpha == ShaderInfo.AlphaType.None)
                                {
                                    // device.RenderState.AlphaBlendEnable = false;
                                    device.TextureState[xxx].AlphaOperation = TextureOperation.Disable;
                                    device.TextureState[xxx].AlphaArgument1 = TextureArgument.TextureColor;
                                    device.TextureState[xxx].AlphaArgument2 = TextureArgument.Current;

                                    device.TextureState[xxx].ColorOperation = TextureOperation.Disable;
                                    device.TextureState[xxx].ColorArgument1 = TextureArgument.TextureColor;
                                    device.TextureState[xxx].ColorArgument2 = TextureArgument.Current;
                                }
                                else
                                {
                                    // device.RenderState.AlphaBlendEnable = true;
                                    device.RenderState.SourceBlend = Blend.SourceColor;
                                    device.RenderState.DestinationBlend = Blend.InvSourceColor;

                                    /*
                                    device.TextureState[xxx].ColorOperation = TextureOperation.SelectArg1;
                                    device.TextureState[xxx].ColorArgument1 = TextureArgument.TextureColor;
                                    device.TextureState[xxx].ColorArgument2 = TextureArgument.Diffuse;
                                    */
                                    device.TextureState[xxx].AlphaOperation = TextureOperation.Modulate;
                                    device.TextureState[xxx].AlphaArgument1 = TextureArgument.TextureColor;
                                    device.TextureState[xxx].AlphaArgument2 = TextureArgument.Current;
                                }
                            }
                        }

                        PrimitiveType pt;
                        if (pm.RawDataMetaChunks[rawindex].FaceCount * 3 != pm.RawDataMetaChunks[rawindex].IndiceCount)
                        {
                            pt = PrimitiveType.TriangleStrip;

                            // The -2 is because it's a Triangle Strip, which has three vertices for trianlge 1 and one for
                            // each following traingle.
                            // So the total # of triangles are IndiceCount-2 (for the first two points)
                            // Thanks to Prey for pointing this out
                            try
                            {
                                device.DrawIndexedPrimitives(
                                    pt,
                                    0,
                                    0,
                                    pm.RawDataMetaChunks[rawindex].VerticeCount,
                                    pm.RawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceStart,
                                    pm.RawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount - 2);
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            pt = PrimitiveType.TriangleList;
                            device.DrawIndexedPrimitives(
                                pt,
                                0,
                                0,
                                pm.RawDataMetaChunks[rawindex].VerticeCount,
                                pm.RawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceStart,
                                pm.RawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount / 3);
                        }
                    }
                }
            }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:101,代码来源:ParsedModel.cs

示例7: Render

        public void Render(Device device)
        {
            if (Geometry.Clr != -1)
            {
                device.RenderState.Lighting = true;
                Microsoft.DirectX.Direct3D.Material mt = new Microsoft.DirectX.Direct3D.Material();
                mt.AmbientColor = ColorValue.FromArgb(Geometry.Clr);
                mt.DiffuseColor = ColorValue.FromArgb(Geometry.Clr);
                device.RenderState.DiffuseMaterialSource = ColorSource.Material;
                device.Material = mt;
                device.RenderState.AmbientColor = Geometry.Clr;
            }

            device.VertexFormat = vFormat;
            device.SetStreamSource(0, vBuffer, 0);
            if (matIBuffers != null)
            {
                for (int mat = 0; mat < MaterialIndices.Length; mat++)
                {
                    Microsoft.DirectX.Direct3D.Material oMat = device.Material;
                    if (MaterialIndices[mat].Material.Texture == null)
                    {
                        Microsoft.DirectX.Direct3D.Material material = new Microsoft.DirectX.Direct3D.Material();
                        material.AmbientColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Ambient.A,
                                                                                    MaterialIndices[mat].Material.Ambient.R,
                                                                                    MaterialIndices[mat].Material.Ambient.G,
                                                                                    MaterialIndices[mat].Material.Ambient.B));
                        material.DiffuseColor = ColorValue.FromColor(System.Drawing.Color.FromArgb(MaterialIndices[mat].Material.Diffuse.A,
                                                                                    MaterialIndices[mat].Material.Diffuse.R,
                                                                                    MaterialIndices[mat].Material.Diffuse.G,
                                                                                    MaterialIndices[mat].Material.Diffuse.B));
                        device.Material = material;
                    }
                    else
                        device.SetTexture(0, MaterialIndices[mat].Material.Texture);

                    device.Indices = matIBuffers[mat];
                    device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, MaterialIndices[mat].PrimCount);

                    device.Material = oMat;
                }
            }
            else if (iBuffer != null)
            {
                device.Indices = iBuffer;
                device.DrawIndexedPrimitives(Geometry.PrimType, 0, 0, Geometry.Vertices.Length, 0, numPrimitives);
            }
            else
            {
                device.Indices = null;
                device.DrawPrimitives(Geometry.PrimType, 0, numPrimitives);
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:53,代码来源:ABModel3D.cs

示例8: Render

        // Render this Item + all children
        public void Render(Effect effect, Device device, bool setMaterial)
        {
            if (!itemsOptimized && !DontOptimize)
            {
                List<uint> ind = new List<uint>(indices);
                int vertCount = nVerts;
                foreach (RenderItem item in items)
                {
                    ind.AddRange(item.indices);
                    vertCount += item.nVerts;
                }
                if (ind.Count == 0)
                {
                    // Abort
                    itemsOptimized = true;
                    return;
                }
                ib.SetIB<uint>(ind.ToArray(), ind.Count * sizeof(uint), Usage.WriteOnly, false);
                device.Indices = ib.IB;
                nIndices = ind.Count;
                nVerts = vertCount;
                itemsOptimized = true;
            }

            // Set material
            if (setMaterial)
                material.ApplyMaterial(device);

            int primCount = 0;
            switch (Type)
            {
                case PrimitiveType.TriangleList:
                    primCount = nIndices / 3;
                    break;
                case PrimitiveType.TriangleFan:
                case PrimitiveType.TriangleStrip:
                    primCount = nIndices - 2;
                    break;
            }

            if (primCount > 0)
            {
                // Draw
                device.DrawIndexedPrimitives(Type, vertexStartIndex, lowestIndiceValue, nVerts, IndiceStartIndex, primCount);
            }

            // Render children
            if (!itemsOptimized || DontOptimize)
            {
                foreach (RenderChildren children in items)
                {
                    children.Render(effect, device, false);
                }
            }
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:56,代码来源:RenderItem.cs

示例9: DrawCluster

            /// <summary>
            /// The draw cluster.
            /// </summary>
            /// <param name="rawindex">The rawindex.</param>
            /// <param name="outlinecolor">The outlinecolor.</param>
            /// <param name="device">The device.</param>
            /// <param name="bsp">The bsp.</param>
            /// <param name="Textured">The textured.</param>
            /// <param name="WireFrame">The wire frame.</param>
            /// <param name="cam">The cam.</param>
            /// <remarks></remarks>
            public static void DrawCluster(
                int rawindex, 
                Color outlinecolor, 
                ref Device device, 
                ref BSPModel bsp, 
                bool Textured, 
                bool WireFrame, 
                ref Camera2 cam)
            {
                

                if (bsp.BSPRawDataMetaChunks[rawindex].RawDataChunkInfo.Length == 0)
                {
                    return;
                }

                // Vector3 tempv = new Vector3();
                // tempv.X = bsp.Spawns.Spawn[x].X;
                // tempv.Y = bsp.Spawns.Spawn[x].Y;
                // tempv.Z = bsp.Spawns.Spawn[x].Z;
                // if (!cam.SphereInFrustum(tempv, 10f)) { continue; }
                device.SetStreamSource(0, bsp.Display.vertexBuffer[rawindex], 0);
                device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
                device.Indices = bsp.Display.indexBuffer[rawindex];
                for (int xx = 0; xx < bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo.Length; xx++)
                {
                    int tempshade = bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].ShaderNumber;

                    #region AlphaBlending

                    if (bsp.Shaders.Shader[tempshade].Alpha == ShaderInfo.AlphaType.AlphaBlend)
                    {
                        // MessageBox.Show("test");
                        device.RenderState.AlphaBlendEnable = true;
                        device.RenderState.AlphaTestEnable = false;
                    }
                    else if (bsp.Shaders.Shader[tempshade].Alpha == ShaderInfo.AlphaType.AlphaTest)
                    {
                        // MessageBox.Show("test2");
                        device.RenderState.AlphaBlendEnable = false;
                        device.RenderState.AlphaTestEnable = true;
                    }
                    else
                    {
                        device.RenderState.AlphaBlendEnable = false;
                        device.RenderState.AlphaTestEnable = false;
                    }

                    #endregion

                    #region ChooseTexture

                    if (Textured)
                    {
                        // device.TextureState[0] = device.TextureState[2];
                        device.SetTexture(0, bsp.Shaders.Shader[tempshade].MainTexture);
                    }
                    else
                    {
                        device.SetTexture(0, null);
                    }

                    #endregion

                    #region RenderToScene

                    PrimitiveType pt;
                    pt = PrimitiveType.TriangleList;
                    device.RenderState.FillMode = FillMode.Solid;
                    Material mm = new Material();
                    mm.Diffuse = Color.Black;
                    mm.Ambient = Color.Black;
                    device.Material = mm;
                    device.DrawIndexedPrimitives(
                        pt, 
                        0, 
                        0, 
                        bsp.BSPRawDataMetaChunks[rawindex].VerticeCount, 
                        bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceStart, 
                        bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount / 3);

                    #region WireFrame

                    if (WireFrame)
                    {
                        Material m = new Material();
                        m.Diffuse = outlinecolor;
                        m.Ambient = outlinecolor;
                        device.Material = m;
//.........这里部分代码省略.........
开发者ID:troymac1ure,项目名称:Entity,代码行数:101,代码来源:BSPModel.cs

示例10: Draw


//.........这里部分代码省略.........
                        {
                            // If not Textured
                            device.SetTexture(0, null);
                            device.SetTexture(1, null);

                            if (bsp.LightMapTexture != null)
                            {
                                if (bsp.LightMapTexture[x] != null && bsp.BSPRawDataMetaChunks[x].LightMapUVs.Count != 0 &&
                                    bsp.RenderBSPLighting)
                                {
                                    device.SetTexture(0, bsp.LightMapTexture[x]);
                                    device.TextureState[0].ColorOperation = TextureOperation.Modulate2X;
                                    device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
                                    device.TextureState[0].ColorArgument2 = TextureArgument.Current;
                                    device.TextureState[0].TextureCoordinateIndex = 2;
                                }
                            }
                        }

                        #endregion

                        PrimitiveType pt;
                        // if (bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount != (bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount/3)*3)
                        if (bsp.BSPRawDataMetaChunks[rawindex].FaceCount * 3 !=
                            bsp.BSPRawDataMetaChunks[rawindex].IndiceCount)
                        {
                            pt = PrimitiveType.TriangleStrip;
                            device.RenderState.FillMode = FillMode.Solid;
                            Material mm = new Material();
                            mm.Diffuse = Color.White;
                            mm.Ambient = Color.White;
                            // if (x == 1) { mm.Diffuse = System.Drawing.Color.Red; mm.Ambient = System.Drawing.Color.Red; }
                            device.Material = mm;
                            device.DrawIndexedPrimitives(
                                pt, 
                                0, 
                                0, 
                                bsp.BSPRawDataMetaChunks[rawindex].VerticeCount, 
                                bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceStart, 
                                bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount);
                        }
                        else
                        {
                            count++;
                            pt = PrimitiveType.TriangleList;

                            device.RenderState.FillMode = FillMode.Solid;
                            Material mm = new Material();
                            mm.Diffuse = Color.White;
                            mm.Ambient = Color.White;
                            // if (x == 1) { mm.Diffuse = System.Drawing.Color.Red; mm.Ambient = System.Drawing.Color.Red; }
                            device.Material = mm;

                            device.DrawIndexedPrimitives(
                                pt, 
                                0, 
                                0, 
                                bsp.BSPRawDataMetaChunks[rawindex].VerticeCount, 
                                bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceStart, 
                                bsp.BSPRawDataMetaChunks[rawindex].SubMeshInfo[xx].IndiceCount / 3);
                        }

                        #region RenderToScene

                        #region WireFrame
开发者ID:troymac1ure,项目名称:Entity,代码行数:66,代码来源:BSPModel.cs

示例11: DrawInstancedIndexedPrimitives

        private void DrawInstancedIndexedPrimitives(Device device, SlimDX.Direct3D9.Mesh mesh, VertexBuffer vertexBuffer, VertexBuffer instancedVertexData, VertexElement[] vertexElements, int nIndexedElements)
        {
            device.SetStreamSourceFrequency(0, nIndexedElements, StreamSource.IndexedData);
            device.SetStreamSource(0, vertexBuffer, 0, D3DX.GetDeclarationVertexSize(vertexElements, 0));

            device.SetStreamSourceFrequency(1, 1, StreamSource.InstanceData);
            device.SetStreamSource(1, instancedVertexData, 0, D3DX.GetDeclarationVertexSize(vertexElements, 1));

            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, mesh.VertexCount, 0, mesh.FaceCount);
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:10,代码来源:SortedTestRenderer.cs

示例12: draw

        public void draw(Device i_dev)
        {
            IndexBuffer old_Indices;
            Cull old_CullMode;
            old_CullMode = i_dev.RenderState.CullMode;
            old_Indices = i_dev.Indices;
            i_dev.RenderState.CullMode = Cull.Clockwise;
            i_dev.Indices = this._indexBuffer;

            #if NyartoolkitCS_FRAMEWORK_CFW
            // 頂点バッファをデバイスのデータストリームにバインド
            i_dev.SetStreamSource(0, this._vertexBuffer, 0);
            // レンダリング(描画)
            i_dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);
            i_dev.Indices = old_Indices;
            i_dev.RenderState.CullMode = old_CullMode;
            #else
            VertexFormats old_VertexFormat = i_dev.VertexFormat;
            // 頂点バッファをデバイスのデータストリームにバインド
            i_dev.SetStreamSource(0, this._vertexBuffer, 0);
            // 描画する頂点のフォーマットをセット
            i_dev.VertexFormat = CustomVertex.PositionColored.Format;
            i_dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);
            i_dev.VertexFormat = old_VertexFormat;
            #endif
            i_dev.Indices = old_Indices;
            i_dev.RenderState.CullMode = old_CullMode;
            return;
        }
开发者ID:walidBelfadel,项目名称:MARS_project,代码行数:29,代码来源:ColorCube.cs

示例13: RenderInstances

        private void RenderInstances(Device dev)
        {
            InstanceLoader.UpdateVisibility();
            if (Meshes.Count == 0 || Textures.Count == 0 || InstanceDataBuffer == null || numInstances == 0)
                return;

            mModelInfo.BoneAnimator.OnFrame();

            int counter = 0;
            var shdr = Video.ShaderCollection.MDXShader;
            dev.VertexDeclaration = InstanceDeclaration;
            dev.SetRenderState(RenderState.VertexBlend, VertexBlend.Weights3);

            foreach (VertexBuffer vb in Meshes)
            {
                dev.SetStreamSource(0, vb, 0, Marshal.SizeOf(typeof(Models.MDX.MdxVertex)));
                dev.SetStreamSourceFrequency(0, numInstances, StreamSource.IndexedData);

                dev.SetStreamSource(1, InstanceDataBuffer, 0, Marshal.SizeOf(typeof(Models.MDX.MdxInstanceData)));
                dev.SetStreamSourceFrequency(1, 1, StreamSource.InstanceData);

                setRenderValues(counter);

                dev.Indices = Indices[counter];

                shdr.SetTexture("MeshTexture", Textures[counter]);
                if (mModelInfo.Passes[counter].BoneMatrices.Length == 0 || mModelInfo.Passes[counter].BoneMatrices.Length > 50)
                {
                    shdr.SetValue("useAnimation", false);
                }
                else
                {
                    shdr.SetValue<Matrix>("BoneMatrices", mModelInfo.Passes[counter].BoneMatrices);
                    shdr.SetValue("useAnimation", mModelInfo.Passes[counter].BoneMatrices.Length > 0);
                }

                shdr.DoRender((device) =>
                    {
                        dev.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, NumTriangles[counter] * 3, 0, NumTriangles[counter]);
                    }
                );

                unsetRenderValues();

                ++counter;
            }
            dev.VertexDeclaration = null;

            dev.ResetStreamSourceFrequency(0);
            dev.ResetStreamSourceFrequency(1);
            dev.SetRenderState(RenderState.VertexBlend, VertexBlend.Disable);
        }
开发者ID:remixod,项目名称:sharpwow,代码行数:52,代码来源:M2BatchRenderer.cs


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