public RenderableMesh AllocateResourceFor(Mesh3V3N mesh) { var vertexBuffer = CreateVertexBuffer(mesh); var elementBuffer = CreateElementBuffer(mesh); //var vertexArrayObject = CreateAndSetupVertexArrayObject(vertexBuffer, elementBuffer); return(new RenderableMesh(vertexBuffer, elementBuffer, null, mesh.Faces.Length, this)); }
private VertexBufferObject <Vertex3V3N> CreateVertexBuffer(Mesh3V3N mesh) { var vertexBuffer = _resourceFactory.CreateVertexBufferObject <Vertex3V3N>(BufferTarget.ArrayBuffer); vertexBuffer.Bind(); vertexBuffer.Data(mesh.Vertices); vertexBuffer.Unbind(); return(vertexBuffer); }
private VertexBufferObject <uint> CreateElementBuffer(Mesh3V3N mesh) { //Todo pick index type depending on mesh size if (mesh.Vertices.LongLength > uint.MaxValue) { throw new NotImplementedException(); } var indices = mesh.Faces.SelectMany(x => new[] { (uint)x.V0, (uint)x.V1, (uint)x.V2 }).ToArray(); var elementBuffer = _resourceFactory.CreateVertexBufferObject <uint>(BufferTarget.ElementArrayBuffer, sizeof(uint)); elementBuffer.Bind(); elementBuffer.Data(indices); elementBuffer.Unbind(); return(elementBuffer); }
public void Update(Mesh3V3N mesh) { Mesh = mesh; IsDirty = true; }
public OceanComponent(Mesh3V3N mesh) { Mesh = mesh; }
public void Update(Mesh3V3N mesh) { _vertexBuffer.Bind(); _vertexBuffer.Data(mesh.Vertices, BufferUsageHint.StaticDraw); _vertexBuffer.Unbind(); }