Click or drag to resize
Ab4d.SharpEngine logo

MeshSetCustomVertexBuffer(GpuBuffer, VertexBufferDescription) Method

SetCustomVertexBuffer sets a custom GpuBuffer to be used as a VertexBuffer. See remarks for more info.

Namespace: Ab4d.SharpEngine.Meshes
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 3.0.9196+3eba290aba85a9aa739abf2459bc51e303a050d7
Syntax
C#
public void SetCustomVertexBuffer(
	GpuBuffer? vertexBuffer,
	VertexBufferDescription? customVertexBufferDescription = null
)

Parameters

vertexBuffer  GpuBuffer
vertexBuffer as GpuBuffer or null to disable using custom vertex buffer
customVertexBufferDescription  VertexBufferDescription  (Optional)
optional VertexBufferDescription; when null then the existing VertexBufferDescription is preserved
Remarks

SetCustomVertexBuffer sets a custom GpuBuffer to be used as a VertexBuffer.

This enabled reusing the GpuBuffer on different Scene objects that use the same GpuDevice.

When the specified vertexBuffer is null, then this removes the custom vertex buffer so user can regenerate the vertex buffer from vertices or other mesh data.

Note that the custom vertexBuffer will not be disposed when the meshes in the current Scene are disposed. You need to dispose it manually.

If this mesh is used in a MeshModelNode, then the NotifyChange(SceneNodeDirtyFlags) method must be called and MeshChanged must be passed as a parameter to inform the MeshModelNode about the change.

Note that after calling this method, you also need to update the values in the Vertices array in order for the hit testing code to work correctly. Otherwise, the old vertices will be used for hit testing. To change the Vertices array, call the SetCustomVertexBuffer method on TriangleMesh and pass the new vertices array.

See Also