Xna updating bounding box
This is how I fill the pixel Data array when a Game Object-Instance is created: Note that I found this code in another forum or blog, I cannot remember anymore, but it works just fine :). Whenever a Game Object is updated, we need to update its bounding box.
As I mentioned, I do this in two steps, so I will explain the algorithm in two steps.
For the given context, the necessary fields are:private Vector2 position; private Texture2D sprite; private Vector2 velocity; private Vector2 origin; private float rotation; private float scale; private Rectangle bounding Box; private Color[,] pixel Data; Nothing very special here, besides the fact that I use a 2D-Array to store the pixel data of a sprite.
However, none of the ones I found deals exactly with the problem I am going to describe right now.
Afterwards, I would like to share my solution with you and I hope that some of you might be able to apply it.
Bounding boxes are of type "Rectangle" which is defined by an origin (X and Y coordinates of the upper left corner) and a Width and a Height property.
That way, bounding boxes are always axes oriented so that the bounding box of the triangle object on the right side is described by the blue rectangle.