Sprite3DBatch Class
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
A batcher for sprite in the 3D world.
public class Sprite3DBatch : BatchBase<Sprite3DBatch.Sprite3DDrawInfo>, IDisposable, IComponent, IReferencable, ICollectorHolder
Name | Description | |
---|---|---|
Constructors | ||
Sprite3DBatch(GraphicsDevice, Int32, Int32) | Creates a new instance of Sprite3DBatch. |
|
Methods | ||
Begin(GraphicsContext, Matrix, SpriteSortMode, Nullable<BlendStateDescription>, SamplerState, Nullable<DepthStencilStateDescription>, Nullable<RasterizerStateDescription>, EffectInstance, Int32) | 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. |
|
Draw(Texture, ref Matrix, ref RectangleF, ref Vector2, ref Color4, ImageOrientation, SwizzleMode, Nullable<Single>) | Draw a 3D sprite (or add it to the draw list depending on the sortMode). |
|
PrepareForRendering() | ||
UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo, IntPtr, IntPtr, Int32) |
Constructors
Sprite3DBatch(GraphicsDevice, Int32, Int32)
Creates a new instance of Sprite3DBatch.
public Sprite3DBatch(GraphicsDevice device, int bufferElementCount = 1024, int batchCapacity = 64)
Parameters
Type | Name | Description |
---|---|---|
GraphicsDevice | device | |
System.Int32 | bufferElementCount | The maximum number element that can be batched in one time. |
System.Int32 | batchCapacity | The batch capacity default to 64. |
Methods
Begin(GraphicsContext, Matrix, SpriteSortMode, Nullable<BlendStateDescription>, SamplerState, Nullable<DepthStencilStateDescription>, Nullable<RasterizerStateDescription>, EffectInstance, Int32)
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
Type | Name | Description |
---|---|---|
GraphicsContext | graphicsContext | The graphics context to use. |
Matrix | viewProjection | The view-projection matrix to use for the batch session |
SpriteSortMode | sortMode | The sprite drawing order to use for the batch session |
System.Nullable<BlendStateDescription> | blendState | The blending state to use for the batch session |
SamplerState | samplerState | The sampling state to use for the batch session |
System.Nullable<DepthStencilStateDescription> | depthStencilState | The depth stencil state to use for the batch session |
System.Nullable<RasterizerStateDescription> | rasterizerState | The rasterizer state to use for the batch session |
EffectInstance | effect | The effect to use for the batch session |
System.Int32 | stencilValue | The 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, Nullable<Single>)
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
Type | Name | Description |
---|---|---|
Texture | texture | The texture to use during the draw |
Matrix | worldMatrix | The world matrix of the element |
RectangleF | sourceRectangle | The rectangle indicating the source region of the texture to use |
Vector2 | elementSize | The size of the sprite in the object space |
Color4 | color | The color to apply to the texture image. |
ImageOrientation | imageOrientation | The rotation to apply on the image uv |
SwizzleMode | swizzle | Swizzle mode indicating the swizzle use when sampling the texture in the shader |
System.Nullable<System.Single> | depth | The depth of the element. If null, it is calculated using world and view-projection matrix. |
PrepareForRendering()
protected override void PrepareForRendering()
Overrides
UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo, IntPtr, IntPtr, Int32)
protected override void UpdateBufferValuesFromElementInfo(ref BatchBase<Sprite3DBatch.Sprite3DDrawInfo>.ElementInfo elementInfo, IntPtr vertexPointer, IntPtr indexPointer, int vexterStartOffset)
Parameters
Type | Name | Description |
---|---|---|
BatchBase.ElementInfo<> | elementInfo | |
System.IntPtr | vertexPointer | |
System.IntPtr | indexPointer | |
System.Int32 | vexterStartOffset |