Item setTransform
by Ben Woodhead · in Torque Game Engine · 06/01/2004 (4:51 am) · 6 replies
Hello Everybody,
I was just reading Chapter 3 in the 3d game programmers all in one book and I ran into something that I don't quite understand.
In the rotation section they have something like this
%shape.setTransform(%x, %y, %z, %rx, %ry, %rz, %angle);
My question is what axis are they rotating on. I started guessing that items.setTransform will only rotate around the z axis. Is this the case. I looked in items.h and items.cpp and I was unable to find the consoleMethod(item, setTransform, **** );
Thanks,
Ben
I was just reading Chapter 3 in the 3d game programmers all in one book and I ran into something that I don't quite understand.
In the rotation section they have something like this
%shape.setTransform(%x, %y, %z, %rx, %ry, %rz, %angle);
My question is what axis are they rotating on. I started guessing that items.setTransform will only rotate around the z axis. Is this the case. I looked in items.h and items.cpp and I was unable to find the consoleMethod(item, setTransform, **** );
Thanks,
Ben
About the author
#2
- Brett
06/01/2004 (5:27 am)
Angle Axis is something to google for. My understanding of this is that the X,Y, and Z values are like a percentage (between 0 and 1) of the angle. So when you do as Ian suggested, above, you only get rotation on the Z axis.- Brett
#3
Thanks for the answers guys, it basically works the same way as gl. However that does not explain how this example works.
// Game programming all in one
function TurnShape(%shape, %angle) {
%xfrm = %shape.getTransform();
%lx = getword(%xfrm, 0);
%ly = getword(%xfrm, 1);
%lz = getword(%xfrm, 2);
%rx = getword(%xfrm, 3);
%ry = getword(%xfrm, 4);
%rz = getword(%xfrm, 5);
%angle += 1.0;
%rd = %angle;
%shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
}
if rx, ry and rz are a value between 0 and 1 so you know what axis to rotate around then why are we getting the value from the shape.
Again thanks for your help.
Ben
06/01/2004 (6:09 am)
Hello, Thanks for the answers guys, it basically works the same way as gl. However that does not explain how this example works.
// Game programming all in one
function TurnShape(%shape, %angle) {
%xfrm = %shape.getTransform();
%lx = getword(%xfrm, 0);
%ly = getword(%xfrm, 1);
%lz = getword(%xfrm, 2);
%rx = getword(%xfrm, 3);
%ry = getword(%xfrm, 4);
%rz = getword(%xfrm, 5);
%angle += 1.0;
%rd = %angle;
%shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
}
if rx, ry and rz are a value between 0 and 1 so you know what axis to rotate around then why are we getting the value from the shape.
Again thanks for your help.
Ben
#4
In p. 108, when you create the new item, it sets the rotation to "0 0 1 0".
The function ensures some portability since each shape will carry it's own rotation axis.
Therefore you read it before applying the rotation.
BTW, in the documentation forum I started a thread asking the guys at GG to create a special area for this book.
06/01/2004 (6:38 am)
Because the shape already has it's rotation axis set.In p. 108, when you create the new item, it sets the rotation to "0 0 1 0".
The function ensures some portability since each shape will carry it's own rotation axis.
Therefore you read it before applying the rotation.
BTW, in the documentation forum I started a thread asking the guys at GG to create a special area for this book.
#6
The area for the book would be great. The book is great for learning Torque and having a forum here would be a great complement to that.
Ben
06/01/2004 (6:49 am)
Hello,The area for the book would be great. The book is great for learning Torque and having a forum here would be a great complement to that.
Ben
Associate Ian Omroth Hardingham
Mode 7 Games
Ian