Rotation issues
by Berserk · in Torque Game Engine · 07/20/2005 (11:37 am) · 11 replies
Hi there, I notify here there's a problem with rotation calculation in TGE.
I found that the rotation data of the player uses radians as measure unit, so the values of its rotations should be:
But they are instead:
Using then the vectororthobasis function should produce results as this:
because looking a static DTS or a DIF interior with rotation = 0, 0, 0 I can see the axis going this way:
So, starting from the origin and going forward by 1 unit the resulting absolute coordinates should be those I wrote earlyer.
Instead, I get these values:
The values seems rotated 90 deg clockwise belong the expected values. But subtracting a quarted radian (1,57) I get the following results:
Please tell me where and how I have to mod if GG is busy to fix this (and I know they are because I'm not the only one who wish to see TSE complete, as well as the docs and T2D and a pile of other stuff cooking on the grill. Too much meat on the fire, huh?) ;-)
I'll be glad to fix by myself but please help.
Bye, Thc.
.
I found that the rotation data of the player uses radians as measure unit, so the values of its rotations should be:
0
5 1
4 2
3
EDIT: these are the radians values, in wich 0 and 2pi are shared points.But they are instead:
0
-1 1
4 2
3
EDIT: In TGE's rotation scheme 5 is now -1, there's no more 2pi sharing its point with 0.Using then the vectororthobasis function should produce results as this:
-1, 1 0, 1 1, 1 -1, 0 0, 0 1, 0 -1,-1 0,-1 1,-1 X = first value Y = second value EDIT: These values are determined with in mind the position of the player, wich is 0,0, while the other values are its rotation along the Z axis. This means, in example, the first value (upper left in grid) is the position in wich the player is looking when turned on its Z axis by 45 degrees counterclockwise. So, -1 on the X because the origin is 1 unit right, while 1 on the Y because the origin is just 1 unit below. These values are not determined as you can see here, just because rotating a single unit around the origin would produce a circle, while this is a square but the values are rounded (for calculation comfort).
because looking a static DTS or a DIF interior with rotation = 0, 0, 0 I can see the axis going this way:
/|\ Y | +---> X
So, starting from the origin and going forward by 1 unit the resulting absolute coordinates should be those I wrote earlyer.
Instead, I get these values:
1,1 1,0 1,-1 0,1 0,0 0,-1 -1,1 -1,0 -1,-1 X = first value Y = second value EDIT: This is the same thing I wrote below the preceding value-grid.
The values seems rotated 90 deg clockwise belong the expected values. But subtracting a quarted radian (1,57) I get the following results:
1,-1 1, 0 1, 1 1, 0 0, 0 1, 0 -1,-1 0,-1 1,-1 X = first value Y = second value EDIT: And same again.
Please tell me where and how I have to mod if GG is busy to fix this (and I know they are because I'm not the only one who wish to see TSE complete, as well as the docs and T2D and a pile of other stuff cooking on the grill. Too much meat on the fire, huh?) ;-)
I'll be glad to fix by myself but please help.
Bye, Thc.
.
About the author
#2
Bear in mind that there are many ways of representing the same rotation.
07/22/2005 (2:37 pm)
I'm a little unclear what code you're looking at here, or what your test code is, or even how the numbers relate. Can you give a little more detail, or maybe an example of where this is breaking in the engine?Bear in mind that there are many ways of representing the same rotation.
#3
Well, I'm using Andrew Pidcock's hand 2 hand resource, but I modded it as follows:
Thanks.
Bye, Thc.
07/23/2005 (7:06 am)
First of all, thanks for your reply: is encouraging. (Thought I were alone).Well, I'm using Andrew Pidcock's hand 2 hand resource, but I modded it as follows:
function Player::attack(%obj,%slot,%damage) // %slot is not used for now, but is keeped for compatibility
{
//alright.. so I'm going to try and cast a box from a point from your monster's
//current heading/position
%attackDistance = 0.1;
%destroyDistance = 0.1;
%eye = %obj.getTransform();
//echo("eye=" @ %eye);
%xx = getWord(%eye, 0);
%yy = getWord(%eye, 1);
%zz = getWord(%eye, 2);
%rotindex = getword(%eye, 5);
%rotz = getword(%eye, 6) * %rotindex;
%vec = (%xx SPC %yy SPC %zz);
//echo("vec=" @ %vec);
echo("rotz=" @ %rotz);
%rv = vectororthobasis("0 0 " @ %rotindex SPC %rotz);
%xx = getWord(%rv, 0);
%yy = getWord(%rv, 1);
%zz = getWord(%rv, 2);
%rotvector = (%xx SPC %yy SPC %zz);
%rotvector = VectorNormalize(%rotvector); //normalize
// %rotvector = vectorscale(%rotvector, 0.95);
echo("rotvector=" @ %rotvector);
//%found = ContainerFindFirst(mask,
%searchPos = VectorAdd(%vec,%rotvector);
//echo("searchPos=" @ %searchPos);
//check for other players - do damage to them!
InitContainerRadiusSearch(%searchPos, %attackdistance, $TypeMasks::PlayerObjectType);
while ((%targetObject = containerSearchNext()) != 0)
{
echo("found=" @ %targetObject );
if(%targetObject != %obj )
{
//hey it's not us!
%targetObject.applyDamage(%damage); //20 pts damage? // this is for the main player, while the guard AI bot uses the line below
//Armor::damage(%this, %targetobject, %obj, %searchpos, %damage, "Hand to Hand");
}//endif
}//endwhile
}//endF
Having a better look at the values, I noticed the axis seems as follows:
/|\ Y
X |
<----+Thanks.
Bye, Thc.
#4
07/23/2005 (1:29 pm)
Wow. I suspect there's a much simpler way to do the same thing. Have you tried using getForwardVector() or getEyeVector() instead of all that complex matrix manipulation?
#5
That's about the only advice I can surmise, heheh.
07/23/2005 (1:37 pm)
If nothing is wrong with the code itself (beats me!), check to see if the axes of the exported player character were set up correctly. That's about the only advice I can surmise, heheh.
#6
I already checked the model axis. It was the first thought I made, because I know the mesh has to look in positive-y axis. I also know about some axis change by 3dsm in regard to other modeling package, so I were still suspicious. By the way, adam goes forward very well, so I think it's all right by this side.
@ Ben:
Ouch! I don't knew about this getforwardvector!!! OK, I'll try it and let know. Thanks.
While I'm here: I'm using AIGuard resource and everything is fine, except the animations. If I use setactionthread the animations won't play. Why?
Neither for just a frame...
The codebase is about the same, the only change is I'm using AIGuard class instead of player.
Bye, Thc.
.
EDIT: Just to be louder, the "standard" animations are fine, just the punch and kick animations aren't.
I'm using %obj.setactionthread("animation"); inside the AI "think" loop, but noticed if I use the same in player the player won't play too.
I'm afraid that using %this.setactionthread instead the action would apply to all AI bots in the mission. Wouldn't it?
.
07/24/2005 (3:44 am)
@ Matt:I already checked the model axis. It was the first thought I made, because I know the mesh has to look in positive-y axis. I also know about some axis change by 3dsm in regard to other modeling package, so I were still suspicious. By the way, adam goes forward very well, so I think it's all right by this side.
@ Ben:
Ouch! I don't knew about this getforwardvector!!! OK, I'll try it and let know. Thanks.
While I'm here: I'm using AIGuard resource and everything is fine, except the animations. If I use setactionthread the animations won't play. Why?
Neither for just a frame...
The codebase is about the same, the only change is I'm using AIGuard class instead of player.
Bye, Thc.
.
EDIT: Just to be louder, the "standard" animations are fine, just the punch and kick animations aren't.
I'm using %obj.setactionthread("animation"); inside the AI "think" loop, but noticed if I use the same in player the player won't play too.
I'm afraid that using %this.setactionthread instead the action would apply to all AI bots in the mission. Wouldn't it?
.
#7
AIGuard author? GG staff? Any documentation points?
If I knew something about this, I wouldn't ask, don't you think so?
As far as I know, setactionthread is used to start animations, why it doesn't work with pointers? (I think %obj is a pointer to a specific AIGuard instance)
Anyhow, what is setactionthread suitable to work with?
Thanks in advance for replyes (if any).
Bye, Thc.
EDIT: By the way, thank you very much Ben for your suggestion about getforwardvector!!! It works flawlessly and made me make good impression on my skeptics colleagues.
07/27/2005 (12:54 am)
???AIGuard author? GG staff? Any documentation points?
If I knew something about this, I wouldn't ask, don't you think so?
As far as I know, setactionthread is used to start animations, why it doesn't work with pointers? (I think %obj is a pointer to a specific AIGuard instance)
Anyhow, what is setactionthread suitable to work with?
Thanks in advance for replyes (if any).
Bye, Thc.
EDIT: By the way, thank you very much Ben for your suggestion about getforwardvector!!! It works flawlessly and made me make good impression on my skeptics colleagues.
#8
07/27/2005 (2:24 am)
I don't know exactly what's wrong; setActionThread controls one of the animation threads in the Player code, and it can be overridden in a variety of cases. Whenever I use it in a non-trivial way I end up having to step through the code a lot to be 100% sure I've got it right; I imagine you'll have to do the same.
#9
If you know, could you tell me wich object are suitable to be used with setactionthread?
Or, could you tell me how the animation priority is calculated in blending?
Thanks.
Bye, Thc.
07/27/2005 (1:44 pm)
Ouch!!! Do I really have to look at the code? No, please.If you know, could you tell me wich object are suitable to be used with setactionthread?
Or, could you tell me how the animation priority is calculated in blending?
Thanks.
Bye, Thc.
#10
Calling dump() on an object will tell you what methods it has. In general if it has setActionThread, setActionThread will work.
07/27/2005 (6:17 pm)
Sometimes you have to read the code to know exactly how something works. Or experiment. :)Calling dump() on an object will tell you what methods it has. In general if it has setActionThread, setActionThread will work.
#11
So, I have to open up the console and type echo($aiplayerguard.dump()); (where $aiplayerdump is object2id(%obj) called in AIGuard)
right?
Bye, Thc.
07/29/2005 (6:28 am)
Thanks.So, I have to open up the console and type echo($aiplayerguard.dump()); (where $aiplayerdump is object2id(%obj) called in AIGuard)
right?
Bye, Thc.
Torque Owner Berserk
I can't understand such a large codebase, neither in 2 years. Please, somebody that inderstood the source help me.
Bye, Thc.
.