Table of Contents

Class MeshExtension

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll
public static class MeshExtension
Inheritance
object
MeshExtension

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

binding IndexBufferBinding

The bindings for this buffer

services IServiceRegistry

The service used to retrieve the buffer from disk/GPU if it wasn't found through other means

helper IndexBufferHelper

The helper class to interact with the loaded buffer

count int

The 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

binding VertexBufferBinding

The bindings for this buffer

services IServiceRegistry

The service used to retrieve the buffer from disk/GPU if it wasn't found through other means

helper VertexBufferHelper

The helper class to interact with the loaded buffer

count int

The 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

declaration VertexDeclaration
vertexElementUsage string
semanticIndex int
result VertexElementWithOffset

Returns

bool