Sign in to follow this  
KarlBurnett

DirectX and that horrible math thing...

Recommended Posts

Hi there,

I'm new to coding, currently studying game coding (C++) full time and we're currently doing the math section. This is where I'm struggling, trig, geo, hell, even algebra are messing with my head.

Right, my question is, although I'm doing my best to learn all this stuff, at the end of the day, will DirectX/Open GL etc handle stuff like rotation for me, rather than having to do everything manually myself? As in, is there a "rotate", or "scale" function? Doing the math just to find the distance from point a to b is mind boggling and time-consuming and I have used tools such as Unity and Gamesalad (don't get me started on that one) that do these things extremely quickly.

Sorry for the noob question, just wondering if stuff is gonna get easier. LOL.

Cheers!

Share this post


Link to post
Share on other sites
DirectX doesn't have a concept of scale/rotation/translation, or anything like that. The old fixed-function stuff (no shaders) in D3D9 and prior would use a single transformation matrix for those purposes, but all it did was take the matrix. It was up to the calling code to calculate the required matrix. When you're using shaders everything is handled in your shader code, and D3D doesn't know or care how you handle transformations.

The D3D SDK [i]does[/i] come with math libraries that have helper functions and classes for doing this stuff. So there's a function for generation a rotation matrix, or multiplying matrices, or calculating the length of a vector, etc. In fact there's actually two such libraries: D3DX, which is older, and XNAMath, which is newer. XNAMath is probably a bit more awkward to use, because it's designed to take better advantage of SIMD operations (SSE/SSE2 stuff).

Share this post


Link to post
Share on other sites
You can probably get by without knowing the linear algebra for a little while, maybe you can get some small game prototypes going. But unfortunately if you don't understand it, you're going to find yourself hitting the same wall over and over again, it will be very frustrating. Pretty much any advanced graphics techniques will require you to be familiar with the concepts of the different transforms, and if you don't have some understanding how it works you won't be able to debug your own code, and it will drive you nuts.

Share this post


Link to post
Share on other sites
Thanks for the speedy replies :) I'm struggling as I haven't done maths since school... 1991 - lol. But I'll get there. I'm amazed how far I've come in a few weeks, from knowing 0 about code to being able to write simple games etc. Pretty powerful. Guess I just keep my nose in the books!

Oh, and yeah, Kahn Academy is great... I have already started there... I just seem to have a brain that acts like a sieve when it comes to anything mathematical!

Share this post


Link to post
Share on other sites
[quote name='MantaNZ' timestamp='1302754987' post='4798260']
I'm struggling as I haven't done maths since school... 1991 - lol. But I'll get there. I'm amazed how far I've come in a few weeks, from knowing 0 about code to being able to write simple games etc. Pretty powerful. Guess I just keep my nose in the books!
[/quote]

Books about DirectX, about 3D graphics or even about game programming in general usually start with some chapters about basic vector and matrix / transformation math. At least all the books I have contain this (and it's starting to be boring for me :rolleyes:).

Share this post


Link to post
Share on other sites

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

Sign in to follow this