PDA

View Full Version : 3D math source code?


Savant
01-01-2006, 08:31 AM
This is going to sound insane but I swear I can't find this anywhere on the net.

What do you guys use for 3D math routines, like matrices? All I want is a simple class that includes functions to translate, rotate and scale the matrix and then transform a 3D point with it. That's it.

You'd think that would be out there but I'll be damned if I can find it. Lots of equations, lots of graphics, lots of talking, but no simple download links to a usable class.

I used to use the Direct3DX but since I'm using OpenGL/SDL at the moment I can't do that anymore.

Anyone?

PoV
01-01-2006, 09:35 AM
OpenGL has a few functions for appending those transformations to the current matrix (glTranslate3f, glRotate3f, ...), thus allowing you to draw your object at a new position and orientation. Honestly, I think the best advice on this front is to study the math and C++ classes (operators, conversions, etc...) and roll your own.

The *other* option is buy a book. Several books on 3D math or physics ship with some pre built library.

mahlzeit
01-01-2006, 09:43 AM
Here you go. The "dox" files are Doxygen documentation. 217

Note: I took these files from a project of mine. There may be references to files that aren't included. You can remove these.

Savant
01-01-2006, 09:46 AM
Thanks all!

I got it working by using OpenGL to handle the translating/rotating/scaling in it's modelview matrix, pulling the results down and then doing the transform myself after studying an article or two.

Blah. :)

And thanks, mahlzeit, I'll definitely keep your code in a safe deposit box somewhere...

Savant.

impossible
01-01-2006, 07:37 PM
This code has been written 100 times in 100 places. You don't have to buy a book, any opensource 3D engine or tech demo code will have math libraries. The framework on www.humus.ca (this is the guy that writes ATIs tech demos :)) has matrix code and a lot of other good stuff. http://www.geometrictools.com has a lot of math and 3D code. I'm sure you can find a ton of example on www.flipcode.com. Using OpenGL to multiple your matrices and then extracting them is fine, but it's not very straight forward.

Savant
01-02-2006, 03:24 AM
This code has been written 100 times in 100 places. You don't have to buy a book, any opensource 3D engine or tech demo code will have math libraries.
Mmm hmm, one would think so. However an hour of searching yesterday was fairly fruitless. You get hits but they're generally so tied to the authors data structures as to be useless or the coding standard (variable names, etc) is so horrifying that you can't even read it well enough to customize to what you need.

I did eventually find a useful article (http://www.gamedev.net/reference/articles/article877.asp) on matrices that aligned with OpenGL's coordinate system so, armed with that, I used mahlzeit's code to construct my own matrix class and I'm using that now.

So, problem solved but it's not as easy as you might think to find a simple, straightforward matrix class out there on the intarweb if you don't already know enough to write your own (and, in that case, why would you be looking?)

ekampf
01-13-2006, 03:59 PM
If you're using .NET you can use Sharp3D.Math (http://www.ekampf.com/Sharp3D.Math/)

Regards,
Eram Kampf
http://www.developerzen.com

Savant
01-13-2006, 04:02 PM
Hey, that looks neat! Thanks...

Diragor
01-13-2006, 08:56 PM
A while back Mark Sibly posted the math routines from Blitz3D and said "do whatever you want with it".

http://www.blitzmax.com/Community/posts.php?topic=42657

Savant
01-14-2006, 01:37 AM
Yeah, I took a look at that code. So, moving on... :)

Diragor
01-14-2006, 11:33 AM
Not being a 3D math guru myself, what's wrong with it? Seemed to work fine in Blitz3d and looks easy to use.

Savant
01-14-2006, 01:37 PM
See my above posts. I didn't like the way the code was structured, it was hard to adapt to my needs, etc.

Sharkbait
01-16-2006, 07:46 AM
You might want to have a look at some open source 3d engines out there.. they usually have their own math stuff.. matrices, vectors etc. I also have my own vector and matrix classes that I wrote on my own for 'fun' and 'intellectual growth' that I can pass on if you want them... :)


Re.. reply below.. should have gone through the thread more carefully.. my bad!

Savant
01-16-2006, 07:53 AM
Yeah, I've explored all of those options. I'm good guys, really, problem solved (http://forums.indiegamer.com/showpost.php?p=74032&postcount=6).

Thanks all!