Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Object rotation craziness...

Author
Message
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd May 2017 14:57
Apologies if this has been posted about before... I took a look and couldn't see anything about it, but surely someone else has hit this.....

If I run the following code, it works perfectly. The object rotates slowly around the Y axis and its angle is printed accurately in the top-left. The angle is even automatically wrapped, which is nice.



But if I try and do this for X axis rotation, the rotation locks up just before 90 degrees and I get gymbal jitter, which is reflected in the printed value.



Things get even more weird if I do this on the Z axis. Check out what the printed value does when running this:



There's either something very intrinsically wrong here or I'm missing something obvious...
I work full-time making games in AGK2 and DBpro. Living the dream!
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd May 2017 15:10
Woww it gets even crazier when you only rotate on one axis, but monitor the other two axes as well. Run this code and see what I mean.

I work full-time making games in AGK2 and DBpro. Living the dream!
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd May 2017 16:17
Discussing a solution for this with Paul. Once I've figured something out I'll post here.
I work full-time making games in AGK2 and DBpro. Living the dream!
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 3rd May 2017 17:29
Interesting.
Keep us up-to-date please
PSY LABS Games
Coders don't die, they just gosub without return
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 4th May 2017 03:42
From Paul

Quote: "Unfortunately it is a consequence of Euler angles, there are multiple combinations of X, Y, and Z that can rotate an object to a particular orientation. For example pitching on X by 180 degrees is the same result as turning on Y by 180 and rolling on Z by 180 degrees. So X=180, Y=0, Z=0 is the same as X=0, Y=180, Z=180. Since AppGameKit uses quaternions for object orientations it must translate these into Euler angles when you request the X,Y,Z angles. As such it could pick any of these valid interpretations when the object is in one of these orientations."


So the rotations themselves are happening just fine. The problem lies in reading BACK the rotational information.

In my code above, I set the new rotation by using the GetObjectAngleX command, and then adding 1 to it. Because I'm reading it in, the angle data will be skewed because of the eular bias.

If you're wanting to keep track of the angular data of an object in order to reference it later, you may need to write your own tracking code that keeps a record of the rotational data, and update it each time you update the rotational angle of the object.
I work full-time making games in AGK2 and DBpro. Living the dream!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th May 2017 04:11
why not rotate it to 0,0,0 and then rotate it to the angle you want
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 4th May 2017 10:05
The issue is that once rotated past certain values, calling one of the GetObjectAngle commands returns incorrect data.
I work full-time making games in AGK2 and DBpro. Living the dream!
Jeff Miller
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 4th May 2017 11:22
Paul's explanation when Cattlerustler asked the question years ago (concerning DBP) was a bit more complete, namely that the values returned have nothing to do with a prior position:
https://forum.thegamecreators.com/thread/99412
I think you are expecting angles which describe the angular position rather than the Euker angles which individually have no significance but which collectively describe how to get to the position when the values are used to rotate the object from initial position in a certain order.
DBP had an alternate way of getting to a position using yaw, pitch and roll (which it called turn, pitch and roll), and if you tracked the values you set in side variables and displayed them then you would get the angles I think you are expecting.
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 4th May 2017 13:34
Yep. That's what I described as the solution I came to in my post earlier.
I work full-time making games in AGK2 and DBpro. Living the dream!

Login to post a reply

Server time is: 2024-11-24 16:42:08
Your offset time is: 2024-11-24 16:42:08