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


C# VertexPositionTexture.GetType方法代码示例

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


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

示例1: Start

        public override void Start()
        {
            base.Start();
            filter = (MeshFilter)GetComponent(typeof(MeshFilter));
            if (filter.meshToRender != null)
            {
                bounds = filter.meshToRender.bounds;

                if (material != null)
                {
                    // Determine what vertex buffer to create
                    Mesh m = filter.meshToRender;
                    bool hasTexture = (material.mainTexture != null && material.shader.supportsTextures);
                    bool hasVertexColor = (m.colors.HasElements() && material.shader.supportsVertexColor);
                    bool hasLights = (Light.HasLights && m.normals.HasElements() && material.shader.supportsLights);

                    if (hasTexture)
                    {
                        if (hasVertexColor)
                        {
                            // NOTE: Here, lights are not supported
                            VertexPositionColorTexture[] data = new VertexPositionColorTexture[m.vertexCount];
                            for (int i = 0; i < m.vertexCount; i++)
                            {
                                data[i] = new VertexPositionColorTexture(
                                    m.vertices[i],
                                    m.colors[i],
                                    m.uv[i]
                                );
                            }
                            vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
                            vBuffer.SetData(data);
                        }
                        else
                        {
                            if (hasLights)
                            {
                                VertexPositionNormalTexture[] data = new VertexPositionNormalTexture[m.vertexCount];
                                for (int i = 0; i < m.vertexCount; i++)
                                {
                                    data[i] = new VertexPositionNormalTexture(
                                        m.vertices[i],
                                        m.normals[i],
                                        m.uv[i]
                                    );
                                }
                                vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
                                vBuffer.SetData(data);
                            }
                            else
                            {
                                VertexPositionTexture[] data = new VertexPositionTexture[m.vertexCount];
                                for (int i = 0; i < m.vertexCount; i++)
                                {
                                    data[i] = new VertexPositionTexture(
                                        m.vertices[i],
                                        m.uv[i]
                                    );
                                }
                                vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
                                vBuffer.SetData(data);
                            }
                        }
                    }
                    else
                    {
                        if (hasVertexColor)
                        {
                            VertexPositionColor[] data = new VertexPositionColor[m.vertexCount];
                            for (int i = 0; i < m.vertexCount; i++)
                            {
                                data[i] = new VertexPositionColor(
                                    m.vertices[i],
                                    m.colors[i]
                                );
                            }
                            vBuffer = new VertexBuffer(Camera.Device, data.GetType().GetElementType(), data.Length, BufferUsage.WriteOnly);
                            vBuffer.SetData(data);
                        }
                        else
                        {
                            // Not supported yet
                        }
                    }

                }

            }
        }
开发者ID:CodeHelix,项目名称:FFWD,代码行数:89,代码来源:MeshRenderer.cs


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