3DDemo is a simple demonstration of my understanding of 3D graphics. It'll start of with the basics: scaling, rotation and translation of vectors - as I continue my blog I'll be adding more advanced features as well as the usuals like gouraud shading and texturing.
What can I say? I'm never one to not take up a challenge so instead of taking the usual route of using three different matrices to manage rotation about each axis I decided to combined them into one all-singing-all-dancing matrix which could handle rotation about one, two or all three axes at once. Want to see what it looks like?
float temp_x = (x * ((cos(_y_axis) * cos(_z_axis)) + (-sin(_y_axis) * -sin(_x_axis) * -sin(_z_axis)))) +
(y * (cos(_x_axis) * -sin(_z_axis))) +
(z * ((sin(_y_axis) * cos(_z_axis)) + (cos(_y_axis) * -sin(_x_axis) * -sin(_z_axis))));
float temp_y = (x * ((cos(_y_axis) * sin(_z_axis)) + (-sin(_y_axis) * -sin(_x_axis) * cos(_z_axis)))) +
(y * (cos(_x_axis) * cos(_z_axis))) +
(z * ((sin(_y_axis) * sin(_z_axis)) + (cos(_y_axis) * -sin(_x_axis) * cos(_z_axis))));
float temp_z = (x * (-sin(_y_axis) * cos(_x_axis))) + (y * sin(_x_axis)) + (z * (cos(_y_axis) * cos(_x_axis)));
Pretty scary and I'm glad it actually works! I did get the matrix multiplacation wrong the first time but considering my calculations were spread all over a single sheet of A4 I'm not surprised! I'd like to see how much of a difference using the algorithm makes compared to three different calls (one for each axis) I'm guessing it'd be more useful when objects are in free-fall.
Oh dear - considering that this is probably the first project I started writing about since I began our new website, it hasn't had much attention has it?
No matter, I've decided to come back to it today with the sole intention of doing three things:
Well, I've written the code fo flat filling a polygon and for the most part all is well. The only thing I need to do is to implement code so that the routine doesn't over-compensate when filling sub-pixel gradients. At the mo it looks like the routine is throwing a wobbler out for a fraction of a second which isn't nice.