本文整理汇总了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");
}