Rotation in player file changed into Radions
by Katrina Rose · in Torque Game Engine · 11/22/2004 (11:56 am) · 4 replies
Hi,
in mission1.mis:
239.752 -30.1547 100.01 0 0 -1 1.5708
As you can see the 1.5708 Radions is actually 90 degrees.
If I add in Player.cs:
His rotation is changed to 90 degrees and everything is fine.
I don't know where in the C++ code the change needs to be made.
Thanks for your time,
Marrion
in mission1.mis:
new Player() {
position = "239.752 -30.1547 100.01";
rotation = "0 0 -1 90";
scale = "1 1 1";
dataBlock = "grunt";
};When the above grunt comes into the mission from the mission file his rotation is changed into radions by the engine and is facing the wrong direction. When the grunt comes in he has a transform of:239.752 -30.1547 100.01 0 0 -1 1.5708
As you can see the 1.5708 Radions is actually 90 degrees.
If I add in Player.cs:
function grunt::onAdd(%this, %obj)
{
echo("----------------------------------CREATING GRUNT-----------------------------------");
echo(%obj.getTransform());
%rot = getWord(%obj.getTransform(),6);
echo(mRadToDeg(%rot));
%newPos = setWord(%obj.getTransform(),6,mRadToDeg(%rot));
%obj.setTransform(%newPos);
}His rotation is changed to 90 degrees and everything is fine.
I don't know where in the C++ code the change needs to be made.
Thanks for your time,
Marrion
About the author
#2
11/23/2004 (3:00 am)
@ brett - If it's always handled in radians then why in the editor and get/set transform is it in degrees?
#3
11/23/2004 (3:35 am)
@Katrina because most humans don't understand radians, but trig and other 3-d/spatial math work much better with radians, so they run internally for performance, and change it where it matters--when humans see it. You could just convert prior to saving to degrees, and back to radians on load, but it's not a bug or anything.
#4
I finally got this working correctly. The player data is converted from Degrees to Radians and saved in the mission file. When you load the mission the Degrees is converted back to Radians and passed into the onAdd function. For some reason if you convert the Radians back to Degrees and set the players transform to the Degrees rotation it does some strange conversion to it, and it's way off. What I have to do is capture the Rotation in Radians and pass that value to the players rotation when the player is being created. What I don't understand is why the rotation does not come through in the onAdd correctly. It's almost as if the rotation is being added to mine. Whatever is happening I have got around it. If anyone has any questions please ask.
Marrion
11/23/2004 (5:48 am)
As an update:I finally got this working correctly. The player data is converted from Degrees to Radians and saved in the mission file. When you load the mission the Degrees is converted back to Radians and passed into the onAdd function. For some reason if you convert the Radians back to Degrees and set the players transform to the Degrees rotation it does some strange conversion to it, and it's way off. What I have to do is capture the Rotation in Radians and pass that value to the players rotation when the player is being created. What I don't understand is why the rotation does not come through in the onAdd correctly. It's almost as if the rotation is being added to mine. Whatever is happening I have got around it. If anyone has any questions please ask.
Marrion
Torque Owner Brett Fattori
- Brett