Jump to content
  • entries
  • comments
  • views

Started loading models. Matrices and shaders.

Sign in to follow this  


We use Milkshape3D for modeling, so it makes sense to support loading .ms3d model files. I implemented basic loading code this morning, but it needs a lot of work. In its current state, it will only load a single triangle out of the model, and materials and animation are not taken into account. After I get some other parts of the rendering side of things finished, I plan on getting it to correctly load and display a cool looking 3D model that GreyKnight created.

The rest of the day was spent in getting the camera and the projection matrix working.

Something you should look out for when using a vertex shader to transform vertices: When the matrix is stored in the constant registers, by default each register represents a column of the matrix, not a row. This is called "column-major", and makes sense from an optimization point of view; if you are using row vectors, then the columns of the matrices will need to be accessed to perform transformations, and the rows will rarely be directly accessed (one exception would be in matrix multiplication). You can account for this by transposing your matrices before you place them in the registers.

To make the code more readable (and easier to write), I have created four specialized derivations of the generic matrix: RotateX, RotateY, RotateZ, and Translate. The names are pretty self-explanatory; RotateX represents a rotation about the x-axis, etc. and Translate represents a translation. This allows me to create a rotation or translation matrix by providing only a single argument (an angle or a vector, depending on the matrix).

On the subject of matrices, I have decided to use mOut = Transpose(mIn); rather than mOut = mIn.Transpose(); The latter implies that the matrix being transposed is being altered, which isn't the case (a copy of it is created and transposed). I don't much like mOut = Multiply(mL, mR); though, as this is a bit too messy in my opinion. For multiplication and similar operations, I have decided to use this format: mOut = mL*mR;

[size="1"]Reposted from http://invisiblegdev.blogspot.com/
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!