So thanks to many of the replies from this board, I have a much better understanding of some of what's under the hood but I just need this little bit more to get a firm understanding. So I am reading through part of Riemer's tutorials here:
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Coll_Detection_Matrices.php
I'll use the carriage example as it's fairly simple.
So the series of transformations for the carriage is this:
1: Matrix.Identity;
2: Matrix.CreateTranslation(xPos, yPos, 0)
3: Matrix.CreateScale(playerScaling)
4: Matrix.CreateTranslation(0, -carriage.Height, 0)
So my questions are these:
Riemer states:
1: If we would render the image just like it is (or: with the Identity transformation), it would be rendered in its original size in the top-left corner of the screen.
- I don't get in what context this is applicable. Is he just referring to the fact that before the draw, all images start at the world origin of 0,0? Or is he saying that when these transformations take effect, the origin of the object will now be placed at the upper-left and translated back to the world origin?
2: First, the carriage image is moved so its top-left point is at the position specified as second argument in the SpriteBatch.Draw method.
- Ok, so is he saying this is what happens under the hood for what happens during the draw method or that he is just passing the same parameter as what you send to the draw method?
4: Finally, and this is the most challenging step: the image is moved over the Y axis, since in our SpriteBatch.Draw method we’ve specified (0, carriageTexture.Height) as origin. Very important: it is moved over its own Y axis, which has been scaled down. So instead of being moved over 39 screen pixels, the carriages will be moved vertically over 39*0.4=16 pixels pixels (since carriageTexture.Height = 39 and playerScaling = 0.4).
Ok, so we've been positioning things using these matrices in our world/screen space. When you scale something down, I don't get why it will now start moving in accordance to the object's local space. For example, our first translation matrix moved according to the world/screen space but now he states "it is moved over its own Y axis".
Why is the identity matrix optional?
Thus, I am having trouble connecting back the draw method with these matrix multiplications, what the deal with the object going to the world origin is and why the create translation shifted its behavior.