public Matrix GetViewTransformationMatrix() { if (_isViewTransformationDirty) { _camTranslationVector.X = -_position.X; _camTranslationVector.Y = -_position.Y; Matrix.CreateTranslation(ref _camTranslationVector, out _camTranslationMatrix); Matrix.CreateRotationZ(_rotation, out _camRotationMatrix); _camScaleVector.X = _zoom; _camScaleVector.Y = _zoom; _camScaleVector.Z = 1; Matrix.CreateScale(ref _camScaleVector, out _camScaleMatrix); _resTranslationVector.X = ResolutionIndependentRenderer.GetVirtualRes().X * 0.5f; _resTranslationVector.Y = ResolutionIndependentRenderer.GetVirtualRes().Y * 0.5f; _resTranslationVector.Z = 0; Matrix.CreateTranslation(ref _resTranslationVector, out _resTranslationMatrix); _transform = _camTranslationMatrix * _camRotationMatrix * _camScaleMatrix * _resTranslationMatrix * ResolutionIndependentRenderer.getTransformationMatrix(); _isViewTransformationDirty = false; } return(_transform); }
public static void DrawGrid_Effect(int RowsCount, int ColumnsCount, Vector2 Position, Point Spacing, int Thickness = 2) { RowsCount = Math.Clamp(RowsCount, 1, 100); ColumnsCount = Math.Clamp(ColumnsCount, 1, 100); Thickness = Math.Clamp(Thickness, 2, 50); Spacing.X = Math.Clamp(Spacing.X, 1, 100); Spacing.Y = Math.Clamp(Spacing.Y, 1, 100); Position += ResolutionIndependentRenderer.GetVirtualRes() * 0.5f; for (int i = 0; i <= RowsCount; i++) { DrawLine_Effect(new Vector2(Position.X, Position.Y + i * Spacing.Y), new Vector2(Position.X + Spacing.X * ColumnsCount, Position.Y + i * Spacing.Y)); } for (int i = 0; i <= ColumnsCount; i++) { DrawLine_Effect(new Vector2(Position.X + i * Spacing.X, Position.Y), new Vector2(Position.X + i * Spacing.X, Position.Y + Spacing.Y * RowsCount)); } }
public void ShowUI(SpriteBatch spriteBatch) { // Drawing ImGUI Stuff Setup.GraphicsDevice.SetRenderTarget(null); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, null); spriteBatch.Draw(ImGUI_RenderTarget, Vector2.Zero, new Rectangle(0, 0, (int)ResolutionIndependentRenderer.GetVirtualRes().X, (int)ResolutionIndependentRenderer.GetVirtualRes().Y), Color.White); spriteBatch.End(); }