public RendererParams( Camera camera, UserActionInEditor userActionInEditor, Rectangle selectionRectangle, EntityCreation entityCreation, SnapPoint snapPoint ) { Camera = camera ; UserActionInEditor = userActionInEditor ; SelectionRectangle = selectionRectangle ; EntityCreation = entityCreation ; SnapPoint = snapPoint ; ItemsToRender=ItemsToRender.Everything; }
public static void Update( MouseState mouseState, Camera camera ) { _oldState = _currentState ; _currentState = mouseState ; adjustWorldPosition( camera ) ; }
static void adjustWorldPosition( Camera camera ) { _mouseWorldPos = Vector2.Transform( ScreenPosition, Matrix.Invert( camera.Matrix ) ) ; _mouseWorldPos = _mouseWorldPos.Round( ) ; }
public static void UpdateCamera( Camera camera ) { adjustWorldPosition( camera ); }
void drawWorldOrigin( Camera camera ) { _game.SpriteBatch.Begin( ) ; Vector2 worldOrigin = Vector2.Transform( Vector2.Zero, camera.Matrix ) ; _drawing.DrawLine( _game.SpriteBatch, worldOrigin + new Vector2( -20, 0 ), worldOrigin + new Vector2( +20, 0 ), Constants.Instance.WorldOriginColor, Constants.Instance.WorldOriginLineThickness ) ; _drawing.DrawLine( _game.SpriteBatch, worldOrigin + new Vector2( 0, -20 ), worldOrigin + new Vector2( 0, 20 ), Constants.Instance.WorldOriginColor, Constants.Instance.WorldOriginLineThickness ) ; _game.SpriteBatch.End( ) ; }
void drawGrid( Camera camera ) { _game.SpriteBatch.Begin( ) ; int max = Constants.Instance.GridNumberOfGridLines / 2 ; Color gridColor = Constants.Instance.GridColor ; int thickness = Constants.Instance.GridLineThickness ; for( int x = 0; x <= max; x++ ) { float gridSpacingX = Constants.Instance.GridSpacing.X ; Vector2 start = Vector2.Transform( new Vector2( x, -max ) * gridSpacingX, camera.Matrix ) ; Vector2 end = Vector2.Transform( new Vector2( x, max ) * gridSpacingX, camera.Matrix ) ; _drawing.DrawLine( _game.SpriteBatch, start, end, gridColor, thickness ) ; start = Vector2.Transform( new Vector2( -x, -max ) * gridSpacingX, camera.Matrix ) ; end = Vector2.Transform( new Vector2( -x, max ) * gridSpacingX, camera.Matrix ) ; _drawing.DrawLine( _game.SpriteBatch, start, end, gridColor, thickness ) ; } for( int y = 0; y <= max; y++ ) { float gridSpacingY = Constants.Instance.GridSpacing.Y ; Vector2 start = Vector2.Transform( new Vector2( -max, y ) * gridSpacingY, camera.Matrix ) ; Vector2 end = Vector2.Transform( new Vector2( max, y ) * gridSpacingY, camera.Matrix ) ; _drawing.DrawLine( _game.SpriteBatch, start, end, gridColor, thickness ) ; start = Vector2.Transform( new Vector2( -max, -y ) * gridSpacingY, camera.Matrix ) ; end = Vector2.Transform( new Vector2( max, -y ) * gridSpacingY, camera.Matrix ) ; _drawing.DrawLine( _game.SpriteBatch, start, end, gridColor, thickness ) ; } _game.SpriteBatch.End( ) ; }
void newModelLoaded( object sender, EventArgs e ) { Camera = new Camera( _mainForm.CanvasSize.Width, _mainForm.CanvasSize.Height ) { Position = getLevel( ).CameraPosition } ; }