Game Development Community

Matrix math functions from torquescript?

by Alex Rice · in Torque Game Builder · 04/20/2006 (6:06 pm) · 9 replies

On the features page of TGB, it says: "Torque Core: Math library, Vector, Matrix, Quaternion, etc."

OK so for my game AI want to do some matrix math (add/multiply etc) of large-ish matrices. What Torquescript functions are available for this? I googled the gg site a bit, and browsed through TDN but didn't see anything.

thanks in advance

#1
04/20/2006 (9:56 pm)
OK i found the matrix*() and vector*() functions thanks to the Codeweaver built-in function referernce. Now I guess it's trial and error to figure out how they work :-) Although it looks like the fishdemo and spacescroller use some vector*() tricks.
#2
04/20/2006 (10:00 pm)
DumpConsoleFunctions(); baby!
#3
04/20/2006 (10:10 pm)
Yeah- I'm browsing that now. The comments for the functions are very brief though. Do you know what these designations mean, for the function parameters?

t2dVector == "float float" , i.e. "1.1 3.14" (2D so only 2 floats)
Vector3F == "float float float" i.e. "1.1 2.0 3.14"
AngAxisF ?
Matrix4F left, Matrix4F right == how is a vector [edit: MATRIX] represented in a single string/parameter. is there a vector [edit: matrix] class or data type?
Point3F == "1.1 2.0 3.14"

So my reading of this is that the torquescript functions cannot manipulate larger than 3x3 or 4x4 matrices?
#4
04/21/2006 (12:47 am)
Sorry Alex, I'm not entirely sure what you are asking. I'll take a shot, but I may be off course. :-)

There is no vector "class". The t2dVector commands, as documented at the end of Melv's reference manual list the functions that do vector math. I use t2dVectorDistance in my game, for example. It takes two vectors and returns the distance between.

Torque does not provide a general nxn matrix class. 4x4 is all they need to have implemented. With 4x4 matricies, you can represent any possible 3D transformation.

If you need additional help, please let me know how I can assist, and I will do what I can.
#5
04/21/2006 (12:52 am)
Thanks Jason- I found a lightweight matrix library that looks good for nxn matrices
sourceforge.net/projects/linalg
Time to dig up my old c++ book I guess
#6
04/21/2006 (8:47 am)
Just out of curiousity, why do you need nxn matricies?
#7
04/21/2006 (12:51 pm)
Because my game has a N- dimensional space time continuum. just kidding...

I am going to attempt to implement some game AI logic using FCMs (Fuzzy Cognitive Maps) which entails using large matrices to represent the causative relationships between parts of the ontology (events, sprites, game state,etc).
#8
04/21/2006 (5:03 pm)
Ooooh... sounds "smart". Good luck.
#9
04/21/2006 (5:07 pm)
Yes wish me luck :-) notice I said "attempt to implement" as in- I'm really not sure what I'm doing or if my math skills are strong enough.