Matrices In Motion

How to Move Things in the 3D World (or Getting better acquainted with Matrices)

It's been about a little over a year since I created this site and I'm just now getting around to the second tutorial. I thought I was never going to produce another XNA tutorial after word came out that XNA was dead, but for various reasons I've kept on with XNA and have been putting together several new tutorials for XNA.

With this tutorial, I realized that a deeper understanding of matrices was in order. You may have already looked at the Matrices pre-tutorial in the Fundamentals section. There I basically said that you don't need to really know anything more about matrices other than what I presented there. Basically, I was saying that "if you know how to use matrices then you don't need to know what goes on inside of them or what they really are".

Well, over the past year I've become much more enamored with matrices as I get more experience. Really, it was working with shaders that really did it to me. Everything that is drawn on the screen is drawn with a shader. And all shaders must have the world, view, and projection matrix submitted to draw anything on the screen. So, ultimately you have to submit all the information about how to place your object into the scene by sending a world matrix to the shader.

So, I've basically reached the conclusion that, often it's best to maintain all position, orientation, and scaling information about all of the objects in your 3D world in their world matrices. Because ultimately these objects have to be drawn on the screen, and the info to do that has to be submitted as a world matrix. So, why keep that information anywhere else if you don't have to.

Besides showing how you can use matrices to do all of your movement in your program, I also wanted to demonstrate rotations.

Rotations are notoriously difficult for beginners. It's an extremely common problem to see beginners asking why their rotations don't work. I wanted to write a tutorial to show not only how to rotate objects, but also how to have one object orbit another object.

In this tutorial, I'll bring in 3 models that I created in Blender as .fbx models, a green plane, a yellow cube (which I create two separate instances of), and a blue sphere.

Concepts

Some of the concepts that you’ll learn from this tutorial are:

Part One

Part Two

Files

Complete Project for XNA 4.0 Visual C# 2010 Express edition as a Compressed Zip file

Complete Project for MonoGame 3.4 in Visual Studio 2013 Community Edition as a compressed Zip file.

 







Using Matrices

Matrices In Motion

We continue our exploration of the 3D world, by showing another technique for models using Blender, .fbx, files and vertex painting. We also explore matrices and how they can be used to store all of the information regarding your object's position, orientation, and scaling in the scene. And we look at how to attach a camera to an object so that it follows it regardless of how it twists or turns.

The picture shown is a screen shot from the end result of this tutorial. Again, there's not much to be impressed with here, but it shows a completely different technique that you could potentially use to paint your models. More importantly, it show how you should probably be thinking regarding matrices and how to use them in your program.

XNA Source Code

 

 





Tutorials

The Holodeck

Subsites

Blog

Files


Future Use