Game Development Community

Creating a nxn matrix

by gamer · in Torque Game Engine · 10/10/2006 (12:24 pm) · 4 replies

Is there a way to create a n x n matrix in torque script? MatrixCreate only takes two vector, one position and one rotation.
thanks

#1
10/10/2006 (1:27 pm)
In torque script, a "Matrix" actually means position and orientation,
and as you say is represented by two vectors and one scalar:
PosX, PosY, PosZ, AxisX, AxisY, AxisZ, Rotation.

so scale, skew, perspective, etc, are all unavailable in the "Matrix".

if you really need to work with actual matrices you'll need to do it in the C++ side.


.. but do you really need to work with an actual matrix ?
what are you trying to do, specifically ?

if you want to just dump the transformation in actual matrix format,
that's easy enough, just look at the SetTransform() console function and dump the matrix into a return buffer.
#2
10/10/2006 (1:49 pm)
Thanks Orion,
I have lots of characters in my game that I need to describe the relationship between them and also do some calculations. So i thought making a matrix to hold these data would be easier when i do the math.
maybe I'll implement my own matrix script functions.
#3
10/10/2006 (2:02 pm)
Hiya -

obviously i don't know your code,
but i would bet that most of the functionality you need is already supported in script.

eg:
string MatrixCreate (Vector3F pos, Vector3F rot)
string MatrixCreateFromEuler (Vector3F e)
string MatrixMultiply (Matrix4F left, Matrix4F right)
string MatrixMulVector (MatrixF xfrm, Point3F vector)
string MatrixMulPoint (MatrixF xfrm, Point3F pnt)

note that these all operate on the "Matrices" described above, not real 4x4 matrices,
but they'll probably do the job for you.

or,
yeah,
you could write your own set of actual matrix routines.
#4
10/10/2006 (8:03 pm)
The matrices that "gamer" need are not the 4x3 orthonormal space matrices used for object position and orientation, but probably a much higher-order matrix, where you can store things like "character A owes character Q 250 gold pieces." You'd have to write your own script functions for these, or fake them using script arrays.