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


C# DynamicVertexBuffer.Update方法代码示例

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


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

示例1: Grid

        public Grid(float size, int width, int height)
        {
            Size = size;
            Width = width;
            Height = height;

            if (Root.Instance.UserInterface == null)
                return;

            fieldcount = width * height;
            vertexcount = fieldcount * 4;
            data = new VertexP3C4[vertexcount];
            int i = 0;
            material = Material.CreateSimpleMaterial(null);
            material.DepthTest = true;
            material.DepthWrite = true;
            material.Additive = true;

            //float cy = 1.0f / (float)height * size;
            //float cy = 1.0f / (float)width * size;
            indices = new IndexBuffer();
            indices.buffer = new int[fieldcount * 6];

            for (int y = 0; y < height; ++y)
            {
                float yp = (float)y * size -(size * height / 2);
                for (int x = 0; x < width; ++x)
                {
                    float xp = (float)x * size -(size * width / 2);
                    Color4f color = new Color4f(VecRandom.Instance.NextFloat(), VecRandom.Instance.NextFloat(), VecRandom.Instance.NextFloat(),1);

                    data[i].Color = color;
                    data[i].Position = new Vector3(xp, 0, yp);
                    data[i + 1].Color = color;
                    data[i + 1].Position = new Vector3(xp + size, 0, yp);

                    data[i + 2].Color = color;
                    data[i + 2].Position = new Vector3(xp, 0, yp + size);
                    data[i + 3].Color = color;
                    data[i + 3].Position = new Vector3(xp+size, 0, yp+size);

                    int idx = i / 4 * 6;
                    indices.buffer[idx] = i;
                    indices.buffer[idx+1] = i+1;
                    indices.buffer[idx+2] = i+2;
                    indices.buffer[idx+3] = i+1;
                    indices.buffer[idx+4] = i+3;
                    indices.buffer[idx+5] = i+2;

                    i += 4;
                }
            }
            buffersize=vertexcount * (3+4) * 4;
            vertices = Root.Instance.UserInterface.Renderer.CreateDynamicVertexBuffer(buffersize);
            vertices.Format = VertexFormat.VF_P3C4;
            vertices.Update(data, buffersize);

            shader = Root.Instance.ResourceManager.LoadShader("simple3d.shader");
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:59,代码来源:effects.cs


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