Class Sprite3DBatch
A batcher for sprite in the 3D world.
public class Sprite3DBatch : BatchBase<Sprite3DBatch.Sprite3DDrawInfo>, IDisposable, IComponent, IReferencable, ICollectorHolder
- Inheritance
-
Sprite3DBatch
- Implements
- Inherited Members
- Extension Methods
Constructors
Sprite3DBatch(GraphicsDevice, int, int)
Creates a new instance of Sprite3DBatch.
public Sprite3DBatch(GraphicsDevice device, int bufferElementCount = 1024, int batchCapacity = 64)
Parameters
device
GraphicsDevicebufferElementCount
intThe maximum number element that can be batched in one time.
batchCapacity
intThe batch capacity default to 64.
Methods
Begin(GraphicsContext, Matrix, SpriteSortMode, BlendStateDescription?, SamplerState, DepthStencilStateDescription?, RasterizerStateDescription?, EffectInstance, int)
Begins a 3D sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil, rasterizer state objects, plus a custom effect and a view-projection matrix. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.Default, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.
public void Begin(GraphicsContext graphicsContext, Matrix viewProjection, SpriteSortMode sortMode = SpriteSortMode.Deferred, BlendStateDescription? blendState = null, SamplerState samplerState = null, DepthStencilStateDescription? depthStencilState = null, RasterizerStateDescription? rasterizerState = null, EffectInstance effect = null, int stencilValue = 0)
Parameters
graphicsContext
GraphicsContextThe graphics context to use.
viewProjection
MatrixThe view-projection matrix to use for the batch session
sortMode
SpriteSortModeThe sprite drawing order to use for the batch session
blendState
BlendStateDescription?The blending state to use for the batch session
samplerState
SamplerStateThe sampling state to use for the batch session
depthStencilState
DepthStencilStateDescription?The depth stencil state to use for the batch session
rasterizerState
RasterizerStateDescription?The rasterizer state to use for the batch session
effect
EffectInstanceThe effect to use for the batch session
stencilValue
intThe value of the stencil buffer to take as reference for the batch session
Draw(Texture, ref Matrix, ref RectangleF, ref Vector2, ref Color4, ImageOrientation, SwizzleMode, float?)
Draw a 3D sprite (or add it to the draw list depending on the sortMode).
public void Draw(Texture texture, ref Matrix worldMatrix, ref RectangleF sourceRectangle, ref Vector2 elementSize, ref Color4 color, ImageOrientation imageOrientation = ImageOrientation.AsIs, SwizzleMode swizzle = SwizzleMode.None, float? depth = null)
Parameters
texture
TextureThe texture to use during the draw
worldMatrix
MatrixThe world matrix of the element
sourceRectangle
RectangleFThe rectangle indicating the source region of the texture to use
elementSize
Vector2The size of the sprite in the object space
color
Color4The color to apply to the texture image.
imageOrientation
ImageOrientationThe rotation to apply on the image uv
swizzle
SwizzleModeSwizzle mode indicating the swizzle use when sampling the texture in the shader
depth
float?The depth of the element. If null, it is calculated using world and view-projection matrix.
PrepareForRendering()
protected override void PrepareForRendering()
UpdateBufferValuesFromElementInfo(ref ElementInfo, nint, nint, int)
Update the mapped vertex and index buffer values using the provided element info.
protected override void UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo elementInfo, nint vertexPointer, nint indexPointer, int vexterStartOffset)
Parameters
elementInfo
BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfoThe structure containing the information about the element to draw.
vertexPointer
nintThe pointer to the vertex array buffer to update.
indexPointer
nintThe pointer to the index array buffer to update. This value is null if the index buffer used is static.
vexterStartOffset
intThe offset in the vertex buffer where the vertex of the element starts