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


C# Mesh.DrawSubset方法代码示例

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


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

示例1: RenderMesh

 private void RenderMesh(Mesh mesh)
 {
     for (int i = 0; i < mesh.NumberAttributes; ++i) {
         mesh.DrawSubset(i);
     }
 }
开发者ID:henrikno,项目名称:assimp,代码行数:6,代码来源:AssimpView.cs

示例2: RenderSoftBodyTextured

        public void RenderSoftBodyTextured(SoftBody softBody)
        {
            if (!(softBody.UserObject is Array))
                return;

            object[] userObjArr = softBody.UserObject as object[];
            FloatArray vertexBuffer = userObjArr[0] as FloatArray;
            IntArray indexBuffer = userObjArr[1] as IntArray;

            int vertexCount = (vertexBuffer.Count / 8);

            if (vertexCount > 0)
            {
                int faceCount = indexBuffer.Count / 2;

                bool index32 = vertexCount > 65536;

                Mesh mesh = new Mesh(device, faceCount, vertexCount,
                    MeshFlags.SystemMemory | (index32 ? MeshFlags.Use32Bit : 0),
                    VertexFormat.Position | VertexFormat.Normal | VertexFormat.Texture1);

                DataStream indices = mesh.LockIndexBuffer(LockFlags.Discard);
                if (index32)
                {
                    foreach (int i in indexBuffer)
                        indices.Write(i);
                }
                else
                {
                    foreach (int i in indexBuffer)
                        indices.Write((short)i);
                }
                mesh.UnlockIndexBuffer();

                DataStream verts = mesh.LockVertexBuffer(LockFlags.Discard);
                foreach (float f in vertexBuffer)
                    verts.Write(f);
                mesh.UnlockVertexBuffer();

                mesh.ComputeNormals();
                mesh.DrawSubset(0);
                mesh.Dispose();
            }
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:44,代码来源:MeshFactory.cs

示例3: RenderStaticPlaneShape

 void RenderStaticPlaneShape(Mesh mesh)
 {
     Cull cullMode = device.GetRenderState<Cull>(RenderState.CullMode);
     device.SetRenderState(RenderState.CullMode, Cull.None);
     planeShader.Begin();
     Matrix matrix = device.GetTransform(TransformState.World);
     planeShader.SetValue("World", matrix);
     matrix = device.GetTransform(TransformState.View) * device.GetTransform(TransformState.Projection);
     planeShader.SetValue("ViewProjection", matrix);
     planeShader.BeginPass(0);
     mesh.DrawSubset(0);
     planeShader.EndPass();
     planeShader.End();
     device.SetRenderState(RenderState.CullMode, cullMode);
 }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:15,代码来源:MeshFactory.cs

示例4: DrawMesh

 private void DrawMesh(Mesh mesh, Vector3 loc, bool wireframe = false)
 {
     if (wireframe)
         D3D.Device.SetRenderState(RenderState.FillMode, FillMode.Wireframe);
     SetTarget(loc);
     mesh.DrawSubset(0);
     if (wireframe)
         D3D.Device.SetRenderState(RenderState.FillMode, FillMode.Solid);
 }
开发者ID:alex-v-odesk,项目名称:IceFlake,代码行数:9,代码来源:RenderingScripts.cs

示例5: DrawMesh

 /// <summary>
 /// Draws the specified mesh using the supplied material and texture Arrays.  Arrays should contain one element for each subset in the mesh (although not every must be filled), or be 'null' for no materials/textures.
 /// </summary>
 /// <param name="mesh">The Mesh to be drawn.</param>
 /// <param name="materials"></param>
 /// <param name="textures"></param>
 /// <param name="transform">The Mmatrix used as the world transform before drawing the mesh.  Pass 'null' for no change.</param>
 public static void DrawMesh(Mesh mesh, Material[] materials, Texture[] textures, Matrix transform)
 {
     if (transform != null)
         mesh.Device.Transform.World = transform;
     if (materials != null && materials.Length > 0)
     {
         for (int i = 0; i < materials.Length; i++)
             if (textures.Length > 3)
             {
                 mesh.Device.Material = materials[i];
                 mesh.Device.SetTexture(0, textures[i]);
                 mesh.DrawSubset(i);
             }
     }
     else
     {
         int numSubsets = mesh.GetAttributeTable().Length;
         for (int i = 0; i < numSubsets; i++)
             mesh.DrawSubset(i);
     }
 }
开发者ID:tenshino,项目名称:RainstormStudios,代码行数:28,代码来源:Graphics3D.cs

示例6: RenderMultiSphereShape

 public void RenderMultiSphereShape(MultiSphereShape shape, Mesh mesh)
 {
     int count = shape.SphereCount;
     for (int i = 0; i < count; i++)
         mesh.DrawSubset(i);
 }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:6,代码来源:GraphicObjectFactory.cs

示例7: DrawMesh

 private void DrawMesh(Mesh mesh, Material[] meshmaterials, Texture[] meshtextures)
 {
     for (int i = 0; i < meshmaterials.Length; i++)
     {
         m_device.Material = meshmaterials[i];
         m_device.SetTexture(0, meshtextures[i]);
         mesh.DrawSubset(i);
     }
 }
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-skyLab,代码行数:9,代码来源:GameObject.cs

示例8: RenderCapsuleShape

 public void RenderCapsuleShape(Mesh mesh)
 {
     mesh.DrawSubset(0);
     mesh.DrawSubset(1);
     mesh.DrawSubset(2);
 }
开发者ID:rhynodegreat,项目名称:BulletSharp,代码行数:6,代码来源:GraphicObjectFactory.cs

示例9: DrawMesh

 private void DrawMesh(Mesh mesh, Material[] materials, Texture[] textures)
 {
     for (int i = 0; i < materials.Length; i++)
     {
         //commonObjects.D3DDevice.Material = materials[i];
         mesh.DrawSubset(i);
     }
 }
开发者ID:mansehr,项目名称:Race,代码行数:8,代码来源:GameEngine.cs

示例10: render

        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Pongo el fondo negro
            d3dDevice.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);

            //Obtener valores de Modifiers
            float vAngleX = (float)GuiController.Instance.Modifiers["angleX"];
            float vAngleY = (float)GuiController.Instance.Modifiers["angleY"];
            float vAngleZ = (float)GuiController.Instance.Modifiers["angleZ"];

            //Rotar la luz en base los ángulos especificados
            angleX += vAngleX;
            angleY += vAngleY;
            angleZ += vAngleZ;

            //Posicionar la luz a una distancia y rotarla segun los parametros
            Matrix LightRotationMatrix = Matrix.Identity;
            LightRotationMatrix *= Matrix.Translation(lightDistance,0,0);
            LightRotationMatrix *= Matrix.RotationYawPitchRoll(angleX, angleY,angleZ);
            d3dDevice.Lights[0].Position = Vector3.TransformCoordinate(new Vector3(0,0,0),LightRotationMatrix );
            lightVectorToCenter = d3dDevice.Lights[0].Position;
            d3dDevice.Lights[0].Direction = -d3dDevice.Lights[0].Position;
            d3dDevice.Lights[0].Direction.Normalize();
            d3dDevice.Lights[0].Update();

            //Poner el vertex buffer de la linea que muestra la direccion de la luz.
            lightVectorVB[0].Position = lightVectorToCenter;
            lightVectorVB[0].Color = Color.White.ToArgb();
            lightVectorVB[1].Position = new Vector3(0,0,0);
            lightVectorVB[1].Color = Color.Blue.ToArgb();

            //Variar el color del material
            material.Ambient = (Color)GuiController.Instance.Modifiers["Ambient"];
            material.Diffuse = (Color)GuiController.Instance.Modifiers["Diffuse"];
            material.Specular = (Color)GuiController.Instance.Modifiers["Specular"];

            material.SpecularSharpness = (float)GuiController.Instance.Modifiers["SpecularSharpness"];

            d3dDevice.Material = material;

            switch ((string)GuiController.Instance.Modifiers["ShaderMode"] )
            {
                case "Gouraud":
                    d3dDevice.RenderState.ShadeMode = ShadeMode.Gouraud;
                    break;
                case "Flat":
                    d3dDevice.RenderState.ShadeMode = ShadeMode.Flat;
                    break;
            }

            d3dDevice.RenderState.SpecularEnable = (bool)GuiController.Instance.Modifiers["SpecularEnabled"];

            d3dDevice.RenderState.ColorVertex = true;

            //Habilito o deshabilito el backface culling.
            if ((bool)GuiController.Instance.Modifiers["BackFaceCull"])
            {
                d3dDevice.RenderState.CullMode = Cull.CounterClockwise;
            }
            else
            {
                d3dDevice.RenderState.CullMode = Cull.None;
            }

            //Selecciono el mesh y el vertex buffer del modelo.
            switch ((string)GuiController.Instance.Modifiers["SelectedMesh"])
            {
                case "Teapot":
                    SelectedMesh = teapotMesh;
                    selectedNormalVB = teapotMeshNormalsVB;
                    break;
                case "Face":
                    SelectedMesh = faceMesh;
                    selectedNormalVB = null;
                    break;
            }

            d3dDevice.RenderState.Lighting = true;
            d3dDevice.Transform.World = Matrix.Identity;

            //Renderizar malla
            SelectedMesh.DrawSubset(0);

            //Para dibujar el wireframe se desabilita la luz y se pone el fill mode en modo wireframe.
            if ((bool)GuiController.Instance.Modifiers["Wireframe"])
            {
                d3dDevice.RenderState.FillMode = FillMode.WireFrame;
                d3dDevice.RenderState.Lighting = false;

                SelectedMesh.DrawSubset(0);

                d3dDevice.RenderState.FillMode = FillMode.Solid;
                d3dDevice.RenderState.Lighting = true;
            }

            d3dDevice.Transform.World = Matrix.Identity;

            d3dDevice.RenderState.Lighting = false;
//.........这里部分代码省略.........
开发者ID:JesusHerrera,项目名称:tgc-viewer,代码行数:101,代码来源:Lighting.cs

示例11: draw

 public void draw(Device dev, Mesh box, Vector3 origin)
 {
     dev.Transform.World = Matrix.Translation(
         origin + position + new Vector3(0.5f, 0.5f, 0.5f));
     if (isAlpha)
     {
         //dev.RenderState.DiffuseMaterialSource = ColorSource.Material;
         dev.RenderState.AlphaBlendEnable = true;
         dev.RenderState.SourceBlend = Blend.SourceColor;
         dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
     }
     else
     {
         dev.RenderState.AlphaBlendEnable = false;
     }
     dev.Material = this.mtrl;
     box.DrawSubset(0);
 }
开发者ID:edward9145,项目名称:BuildBrickBuilding,代码行数:18,代码来源:Block.cs

示例12: drawBlock

        public void drawBlock(Device dev, Mesh box, float angle)
        {
            if (isAlpha)
            {
                //dev.RenderState.DiffuseMaterialSource = ColorSource.Material;
                dev.RenderState.AlphaBlendEnable = true;
                dev.RenderState.SourceBlend = Blend.SourceColor;
                dev.RenderState.DestinationBlend = Blend.InvSourceAlpha;
            }
            else
            {
                dev.RenderState.AlphaBlendEnable = false;
            }

            dev.Transform.World =
                Matrix.Translation(position) * Matrix.RotationY(angle);

            dev.Material = this.mtrl;
            box.DrawSubset(0);
        }
开发者ID:edward9145,项目名称:BuildBrickBuilding,代码行数:20,代码来源:Block.cs


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