PathShape and Rotation
by Alex (Stalker) Sakablukow · in Torque Game Engine · 05/31/2006 (5:10 am) · 7 replies
Http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4849
I have implement this ressource today, and have a small problem... the shapes move perfectly, but if i try to rotate shapes, its doesnt work.
getTransform shows that rotation isnt "0 0 0", but ingame the shapes still move without rotation.
I have tryed to rotate markers, but its dont work too...
(Actually i create/set shapes and pathes for each shape direct ingame)
I have implement this ressource today, and have a small problem... the shapes move perfectly, but if i try to rotate shapes, its doesnt work.
getTransform shows that rotation isnt "0 0 0", but ingame the shapes still move without rotation.
I have tryed to rotate markers, but its dont work too...
(Actually i create/set shapes and pathes for each shape direct ingame)
#2
how can i set a shape rotation to "movement direction" with this ressource? Or how can i get the rotation (x y z theta) if i have 2 xyz points?
05/31/2006 (6:56 am)
Its work now ^^ i figured out that xyz-rotation is not the rotation matrix ^^ oOhow can i set a shape rotation to "movement direction" with this ressource? Or how can i get the rotation (x y z theta) if i have 2 xyz points?
#3
But i cant find anything ^^^or simple face a shape into movement direction (a vector).
06/01/2006 (5:10 am)
They must be sury a simple function somevhere to get a matrix from 2 3D-Points?But i cant find anything ^^^or simple face a shape into movement direction (a vector).
#4
Once you have computed the bearing you want to face at each instant, you might want to use my rotateShape resource, "Script-based object rotation", which I think works pretty well for this type of thing.
It can also make things swing more smoothly to each new orientation rather instantly taking the new heading at a marker. And it overcomes some problems you will find if you just use a setTransform to rotate.
Checkthis out, it explains why.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9480
Hope this helps.
06/01/2006 (8:23 am)
function faceTarget(%shape, %target)
{
%shapeTr = %bot.getTransform();
%xp = getWord(%shapeTr, 0);
%yp = getWord(%shapeTr, 1);
%targetTr = %target.getTransform();
%x = getWord(%targetTr, 0);
%y = getWord(%targetTr, 1);
%dx = %x-%xp;
%dy = %y-%yp;
%bearing = mAtan(%dx, %dy);
rotateShape(%shape,%bearing);
}Once you have computed the bearing you want to face at each instant, you might want to use my rotateShape resource, "Script-based object rotation", which I think works pretty well for this type of thing.
It can also make things swing more smoothly to each new orientation rather instantly taking the new heading at a marker. And it overcomes some problems you will find if you just use a setTransform to rotate.
Checkthis out, it explains why.
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9480
Hope this helps.
#5
i will try to implement it today..
06/02/2006 (1:51 am)
Thx, but this ressource uses getTransform, and unfortunately PathShape has no setTransform-function ;)i will try to implement it today..
#6
I have tryed implement .setTransform() function from staticShape, but something get wrong in pack/unpack-routine..
And simple to rotate Path Markers from eacht to following seems not work.. the shape rotate not exactly how the markers.. so if i have to example a ship, that schould move vrom one point to another, AND be rotated in this direction, pathShape faild to manage this.
PS: I have figured out that there is a difference if i create a path manually with editor, and ingame "on the fly"... the path created with editor has green lines that bound any Marker with last/next.. but if i create a path dynamically ingame, i cant see these bindings... The Path works, but the rotation is then wrong.
Some idea about this?
06/07/2006 (2:00 am)
Can anyone explain how can i add rotation to pathShape?I have tryed implement .setTransform() function from staticShape, but something get wrong in pack/unpack-routine..
And simple to rotate Path Markers from eacht to following seems not work.. the shape rotate not exactly how the markers.. so if i have to example a ship, that schould move vrom one point to another, AND be rotated in this direction, pathShape faild to manage this.
PS: I have figured out that there is a difference if i create a path manually with editor, and ingame "on the fly"... the path created with editor has green lines that bound any Marker with last/next.. but if i create a path dynamically ingame, i cant see these bindings... The Path works, but the rotation is then wrong.
Some idea about this?
#7
Still have this problem..
Where is the difference between creating a path with the editor or per script ingame?
If i create the path with editor, i can see green bound lines between path markers, if i create a path per script, i cant see these lines.
Edit: Have figuret it out.. many older ressources use MissionCleanup.add() instead of MissionGroup.add().
06/12/2006 (12:01 am)
*bump*Still have this problem..
Where is the difference between creating a path with the editor or per script ingame?
If i create the path with editor, i can see green bound lines between path markers, if i create a path per script, i cant see these lines.
Edit: Have figuret it out.. many older ressources use MissionCleanup.add() instead of MissionGroup.add().
Torque 3D Owner Billy L
Atleast it does for me without any changes .