Class MeshExtension
public static class MeshExtension
- Inheritance
-
objectMeshExtension
Methods
AsReadable(IndexBufferBinding, IServiceRegistry, out IndexBufferHelper, out int)
Fetch this buffer and create a helper to read from it.
public static void AsReadable(this IndexBufferBinding binding, IServiceRegistry services, out IndexBufferHelper helper, out int count)
Parameters
bindingIndexBufferBindingThe bindings for this buffer
servicesIServiceRegistryThe service used to retrieve the buffer from disk/GPU if it wasn't found through other means
helperIndexBufferHelperThe helper class to interact with the loaded buffer
countintThe amount of indices this buffer holds
Examples
Reading the indices of a mesh:
Model.Meshes[0].Draw.IndexBuffer.AsReadable(Services, out IndexBufferHelper helper, out int count)
var indices = helper.To32Bit();
Remarks
This operation loads the buffer from disk, or directly from the gpu. It is very slow, avoid calling this too often if at all possible.
AsReadable(VertexBufferBinding, IServiceRegistry, out VertexBufferHelper, out int)
Fetch this buffer and create a helper to read from it.
public static void AsReadable(this VertexBufferBinding binding, IServiceRegistry services, out VertexBufferHelper helper, out int count)
Parameters
bindingVertexBufferBindingThe bindings for this buffer
servicesIServiceRegistryThe service used to retrieve the buffer from disk/GPU if it wasn't found through other means
helperVertexBufferHelperThe helper class to interact with the loaded buffer
countintThe amount of vertices this buffer holds
Examples
Reading the vertex positions of a mesh:
Model.Meshes[0].Draw.VertexBuffers[0].AsReadable(Services, out VertexBufferHelper helper, out int count);
var vertexPositions = new Vector3[count];
helper.Copy<PositionSemantic, Vector3>(vertexPositions);
Remarks
This operation loads the buffer from disk, or directly from the gpu. It is very slow, avoid calling this too often if at all possible.
TryGetElement(VertexDeclaration, string, int, out VertexElementWithOffset)
Given a semantic and its index, returns its offset and size in the given vertex buffer. Similar to EnumerateWithOffsets()
public static bool TryGetElement(this VertexDeclaration declaration, string vertexElementUsage, int semanticIndex, out VertexElementWithOffset result)
Parameters
declarationVertexDeclarationvertexElementUsagestringsemanticIndexintresultVertexElementWithOffset