MatrixF::getColumn Method... does it work?
by Dave Calabrese · in Torque Game Engine · 02/02/2005 (7:57 am) · 9 replies
Hey guys...
I'm reading the SDK Docs and I'm looking at this snippet of code here:
void MatrixF::setColumn ( S32 col,const Point3F & cptr ) [inline]
VERY handy sounding method for MatrixF, but when I go to use it, I get the error that the method does not exist. Here is the code I am using:
There something really basic I'm missing in there?
Also, when I hunt through the engine source, I always find that the variable (where I entered 'transformColumn') is never declared. What's up with that? When I try to do this without declaring the variable, I get an error.
Thanks as always!
-Dave C.
I'm reading the SDK Docs and I'm looking at this snippet of code here:
void MatrixF::setColumn ( S32 col,const Point3F & cptr ) [inline]
VERY handy sounding method for MatrixF, but when I go to use it, I get the error that the method does not exist. Here is the code I am using:
MatrixF getObjectRotation; Point3F transformColumn; getObjectRotation.getColumn(1,transformColumn);
There something really basic I'm missing in there?
Also, when I hunt through the engine source, I always find that the variable (where I entered 'transformColumn') is never declared. What's up with that? When I try to do this without declaring the variable, I get an error.
Thanks as always!
-Dave C.
About the author
Recent Threads
#2
Next question: How do I get the transform (preferably just the rotation) of an object through the engine? Looking around, it seems to be 'getRenderTransform()', but whenever I use it I just get the error that it is undeclared and I can't seem to find what library declares it. Is that the correct function to be using to acquire the rotation? I'm thinking once I do have the transform in the matrix, I can just grab the 2'nd and third columns to get the rotational transform and the degrees (in radians, of course). That sound right?
02/02/2005 (8:33 am)
Oh! Of course, that works fine now. =) I missed the & in the docs.Next question: How do I get the transform (preferably just the rotation) of an object through the engine? Looking around, it seems to be 'getRenderTransform()', but whenever I use it I just get the error that it is undeclared and I can't seem to find what library declares it. Is that the correct function to be using to acquire the rotation? I'm thinking once I do have the transform in the matrix, I can just grab the 2'nd and third columns to get the rotational transform and the degrees (in radians, of course). That sound right?
#3
02/02/2005 (9:55 am)
Double post.
#4
How are you calling getRenderTransform? It works in my code... :)
02/02/2005 (9:52 pm)
FYI, I think you mean "header file" when you say "library."How are you calling getRenderTransform? It works in my code... :)
#5
I got this to work, actually, only it's not giving me the rotation in a number I want. It's giving it to me in (quad's?) another form when I need to get it in the usual matrix form (x y z rx ry rz r).
For that, it looks like I can use object->getTransform(), but then I need something like getWord and setWord to modify what's in there. I see getUnit and setUnit does this, but can't get those to work just yet.
02/03/2005 (6:23 am)
Right, header file.. =)I got this to work, actually, only it's not giving me the rotation in a number I want. It's giving it to me in (quad's?) another form when I need to get it in the usual matrix form (x y z rx ry rz r).
For that, it looks like I can use object->getTransform(), but then I need something like getWord and setWord to modify what's in there. I see getUnit and setUnit does this, but can't get those to work just yet.
#6
Instead of figuring out how to convert it to a string for manipulation, your time would be better spent learning how to manipulate the transform in it's native form--it's much more powerful!
That being said, if you really want to figure out how to convert the information into a single string, look at the console methods for getTransform() and setTransform(), since they convert back and forth from a string to the appropriate native structure.
02/03/2005 (6:40 am)
Keep in mind that the "usual form" you are talking about for Transform information is only that way due to the need to send string variables only back to the script interpreter, not because it's easier to use or anything. If you are working in C++ (as you obviously are), a "string version" of transform information is the least useful form--you want to keep it as a matrix to be able to do all the interesting things you want to do with it.Instead of figuring out how to convert it to a string for manipulation, your time would be better spent learning how to manipulate the transform in it's native form--it's much more powerful!
That being said, if you really want to figure out how to convert the information into a single string, look at the console methods for getTransform() and setTransform(), since they convert back and forth from a string to the appropriate native structure.
#7
02/03/2005 (6:54 am)
Actually, I've got nothing wrong keeping it in a matrix, just didn't know that the engine only used the string on the console side. Obviously I'm a bit new to Torque engine coding... still trying to wrap my head around a lot of this. =)
#8
And this is what the console is spitting out:
Got to A.
TransformColumA is: 0.865482 0.500941 0.000000
TransformColumB is: -0.500941 0.865482 0.000000
TransformColumC is: 0.000000 0.000000 1.000000
TransformColumC is: 43.400002 -501.882996 145.000000
TransformColumC is: 0.500941 0.000000 0.000000
TransformColumC is: 0.865482 0.000000 0.000000
Got to B.
That's all well and good.... if I wanted to modify the position. But the only thing I am interested here is the rotation, and that dosen't look anything like the rotation I'm used to...
02/03/2005 (8:05 am)
Just to make it a little more clear what I'm doing, here is the code:ConsoleMethod(StaticShape,ControlledRotation, F32, 3, 3, "()")
{
Con::printf("Got to A.");
// F32 test = argv[2];
MatrixF getObjectRotation;
Point3F transformColumnA;
Point3F transformColumnB;
Point3F transformColumnC;
Point3F transformColumnD;
Point3F transformColumnE;
Point3F transformColumnF;
getObjectRotation = object->getTransform();
getObjectRotation.getColumn(0,&transformColumnA);
getObjectRotation.getColumn(1,&transformColumnB);
getObjectRotation.getColumn(2,&transformColumnC);
getObjectRotation.getColumn(3,&transformColumnD);
getObjectRotation.getColumn(4,&transformColumnE);
getObjectRotation.getColumn(5,&transformColumnF);
object->ControlledRotation(transformColumnA,transformColumnB,transformColumnC,transformColumnD,transformColumnE,transformColumnF);
Con::printf("Got to B.");
}
void StaticShape::ControlledRotation(Point3F transformColumnA, Point3F transformColumnB,Point3F transformColumnC,Point3F transformColumnD,Point3F transformColumnE,Point3F transformColumnF)
{
Con::printf("TransformColumA is: %f %f %f",transformColumnA.x,transformColumnA.y,transformColumnA.z);
Con::printf("TransformColumB is: %f %f %f",transformColumnB.x,transformColumnB.y,transformColumnB.z);
Con::printf("TransformColumC is: %f %f %f",transformColumnC.x,transformColumnC.y,transformColumnC.z);
Con::printf("TransformColumC is: %f %f %f",transformColumnD.x,transformColumnD.y,transformColumnD.z);
Con::printf("TransformColumC is: %f %f %f",transformColumnE.x,transformColumnE.y,transformColumnE.z);
Con::printf("TransformColumC is: %f %f %f",transformColumnF.x,transformColumnF.y,transformColumnF.z);
}And this is what the console is spitting out:
Got to A.
TransformColumA is: 0.865482 0.500941 0.000000
TransformColumB is: -0.500941 0.865482 0.000000
TransformColumC is: 0.000000 0.000000 1.000000
TransformColumC is: 43.400002 -501.882996 145.000000
TransformColumC is: 0.500941 0.000000 0.000000
TransformColumC is: 0.865482 0.000000 0.000000
Got to B.
That's all well and good.... if I wanted to modify the position. But the only thing I am interested here is the rotation, and that dosen't look anything like the rotation I'm used to...
#9
02/03/2005 (11:59 am)
Ok, we need to stop multi-posting across threads...one place is enough! I myself answered in the other thread since it was first in my list.
Associate Anthony Rosenbaum
also that function is the setColumn not getColumn()
in any case to get the column do this