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
deviceGraphicsDevicebufferElementCountintThe maximum number element that can be batched in one time.
batchCapacityintThe 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
graphicsContextGraphicsContextThe graphics context to use.
viewProjectionMatrixThe view-projection matrix to use for the batch session
sortModeSpriteSortModeThe sprite drawing order to use for the batch session
blendStateBlendStateDescription?The blending state to use for the batch session
samplerStateSamplerStateThe sampling state to use for the batch session
depthStencilStateDepthStencilStateDescription?The depth stencil state to use for the batch session
rasterizerStateRasterizerStateDescription?The rasterizer state to use for the batch session
effectEffectInstanceThe effect to use for the batch session
stencilValueintThe 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
textureTextureThe texture to use during the draw
worldMatrixMatrixThe world matrix of the element
sourceRectangleRectangleFThe rectangle indicating the source region of the texture to use
elementSizeVector2The size of the sprite in the object space
colorColor4The color to apply to the texture image.
imageOrientationImageOrientationThe rotation to apply on the image uv
swizzleSwizzleModeSwizzle mode indicating the swizzle use when sampling the texture in the shader
depthfloat?The depth of the element. If null, it is calculated using world and view-projection matrix.
PrepareForRendering()
protected override void PrepareForRendering()
UpdateBufferValuesFromElementInfo(ref ElementInfo, IntPtr, IntPtr, int)
Update the mapped vertex and index buffer values using the provided element info.
protected override void UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo elementInfo, IntPtr vertexPointer, IntPtr indexPointer, int vexterStartOffset)
Parameters
elementInfoBatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfoThe structure containing the information about the element to draw.
vertexPointerIntPtrThe pointer to the vertex array buffer to update.
indexPointerIntPtrThe pointer to the index array buffer to update. This value is null if the index buffer used is static.
vexterStartOffsetintThe offset in the vertex buffer where the vertex of the element starts