public void RebuildPrimitive() { if (Primitive != null && Primitive.VertexBuffer != null ) { Primitive.VertexBuffer.Dispose(); } Primitive = new BatchBillboardPrimitive(graphicsDevice, SpriteSheet, Width, Height, Frame, 1.0f, 1.0f, false, LocalTransforms, Tints); }
public void RemoveTransform(int index) { if (index >= 0 && index < LocalTransforms.Count) { LocalTransforms.RemoveAt(index); Rotations.RemoveAt(index); Tints.RemoveAt(index); } Primitive = new BatchBillboardPrimitive(graphicsDevice, SpriteSheet, Width, Height, Frame, 1.0f, 1.0f, false, LocalTransforms, Tints); }
public override void Render(GameTime gameTime, Camera camera, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, Effect effect) { if (Primitive == null) { Primitive = new BatchBillboardPrimitive(graphicsDevice, SpriteSheet, Width, Height, Frame, 1.0f, 1.0f, false, LocalTransforms, Tints); } effect.Parameters["xTint"].SetValue(new Vector4(1, 1, 1, 1)); if (IsVisible && (camera.Position - GlobalTransform.Translation).LengthSquared() < CullDistance) { Texture2D originalText = effect.Parameters["xTexture"].GetValueTexture2D(); RasterizerState r = graphicsDevice.RasterizerState; graphicsDevice.RasterizerState = rasterState; effect.Parameters["xTexture"].SetValue(SpriteSheet); DepthStencilState origDepthStencil = graphicsDevice.DepthStencilState; DepthStencilState newDepthStencil = DepthStencilState.DepthRead; graphicsDevice.DepthStencilState = newDepthStencil; Matrix oldWorld = effect.Parameters["xWorld"].GetValueMatrix(); effect.Parameters["xWorld"].SetValue(GlobalTransform); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); Primitive.Render(graphicsDevice); } effect.Parameters["xWorld"].SetValue(oldWorld); effect.Parameters["xTexture"].SetValue(originalText); if (origDepthStencil != null) { graphicsDevice.DepthStencilState = origDepthStencil; } if (r != null) { graphicsDevice.RasterizerState = r; } } }