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 / [BUG] GetObjectAngleX() reporting incorrect value

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2019 03:01 Edited at: 4th Mar 2019 05:37
I have two orbiting spheres. The angle reported by the sphere orbiting around the x-Axis is not correct.
Am i missing something here or is this a bug?

So it flips the y-Axis when the x-azis hits 90 degrees. Why does it do that?

Even though it reports that it has flipped the object along the y-axis i cannot see that it actually has (When i use a non-symetrical object)

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 4th Mar 2019 11:42
Its not really a bug..... more just a consequence of the way conversions between euler angles and quaternions occurs in AGK.

Quote: "So it flips the y-Axis when the x-axis hits 90 degrees. Why does it do that?"


It flips both the Y and Z to 180 as the x axis passes 90 degrees. This is because if you rotate by 180 in Y AND Z then it actually exactly the same as just rotating 180 in X.

It mentions this phenomenon in the documentation for SetObjectRotation()
Quote: " Each 3D rotation can be represented by 2 Euler angle combinations, Y,X,Z and Y-180,X-180,Z-180 "


No matter which set is used...Everything ends up in the right rotation and direction... but you just get there by different means.

Consider flying an aircraft.....and you want to turn around 180 degrees.... you could use your rudder to turn the aircraft 180 left slowly.
Alternatively... you could pull up and do half a loop till your upside down then bank the aircraft left until your level again....You never use the rudder at all and yet your flying in the opposite direction. (An Immelmann turn)

So its the same change of direction using different axis to do it.


Anyway...if you do want the x angle without the others changing you could store the rotation value yourself

or you could use the following function

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2019 20:32
Thanks you bengismo. Very enlightening.
I am trying to create a gimbal. Are there any examples of a gimbal out there that you know of? I have searched without any luck
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 4th Mar 2019 22:45 Edited at: 4th Mar 2019 22:48
Not sure what you mean to be honest?

Do you mean one of these (a 3 axis 3d gimbal)?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2019 22:49 Edited at: 4th Mar 2019 22:50
Yes. Only in code. To manage a camera orbiting an object using the mouse. Like in a 3D proggy

I have a circle drawn on the screen. If you drag within the circle then ;
Drag mouse right/left rotates around the y-Axis
Up/Down around the x-Axis

Outside the circle uses camera roll to roll around the z-axis

My problem is when it hits those "flip" angles it goes haywire

I want it to "Reset" when the mouse is released. So the co-ordinate system is set back to zero when the mouse is released
puzzler2018
User Banned
Posted: 4th Mar 2019 22:55
Giz a sec
Tier 1 Developer
puzzler2018
User Banned
Posted: 4th Mar 2019 22:58
I think your overthinking really hard - it just works perfectly - stop trying to perfect something that already is perfection..

Tier 1 Developer
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 4th Mar 2019 22:59 Edited at: 4th Mar 2019 23:01
Well...to draw a 3d gimbal is easy



but i think what you want is nothing to do with drawing a 3d gimbal?

Sounds more like you simply want to rotate your camera around an object and also set roll values too instead??

Edit...
lol..looks like puzler is here to sort you out so I'll let him figure it out for you
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 4th Mar 2019 22:59 Edited at: 4th Mar 2019 23:10
Are you just wanting the camera orbit controlled by the mouse movement or you want an interractable gizmo in 3d space to manipilate?

Nevermind, i missed the part about dragging in/out of the circle.

Orbiting in the XY is easy enough in most cases for a 3rd person camera, but the Z roll complicates things a bit and that's not something I've really worked on before
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2019 23:01
Quote: "Are you just wanting the camera orbit controlled by the mouse movement "

Yes
Quote: "Sounds more like you simply want to rotate your camera around an object and also set roll values too instead?? "

Yes
Quote: "I think your overthinking really hard - it just works perfectly - stop trying to perfect something that already is perfection.."

Try it. You will see what i mean
puzzler2018
User Banned
Posted: 4th Mar 2019 23:04 Edited at: 4th Mar 2019 23:06
Ill back off - cause i dont have a clue + tired lol

Let me know what the results are - mouse movements etc cause confused me with that one - cause no mouse movement code in the original snippet


Please show us your final fix result lol
Tier 1 Developer
puzzler2018
User Banned
Posted: 4th Mar 2019 23:15
Is it because X Axis is going between -90 and 90 instead of 0 - 360?
Tier 1 Developer
puzzler2018
User Banned
Posted: 4th Mar 2019 23:26
Just stick +90 on the X Axis value to keep in the boundary of 0-360

God knows what you trying to acheive really.

Ill stick to my own bloody projects..
Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Mar 2019 23:37
What i am trying to achieve is the same as a camera in a 3D modelling program.
In it's simplest form. What i have so far.
Click and drag right-left to rotate around the y-axis
Click and drag up-down to rotate around the x-axis
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 21:33 Edited at: 5th Mar 2019 21:33
My major problem is when the camera crosses an axis it flips.
How do i stop it from flipping flipping?
puzzler2018
User Banned
Posted: 5th Mar 2019 21:34
Lets have another quick luck - im forgetful these days.
Tier 1 Developer
puzzler2018
User Banned
Posted: 5th Mar 2019 21:38
ok - i can see what its doing...., so.... Do you wish to in essence:-

- If move mouse up and down - to move the red cube object all the way around its Y axis around the whole circumference of white cube

- if move mouse left to right - to move the red cube object all the way around the X axis of the whole circumference of the white cube

Is that what your after?
Tier 1 Developer
puzzler2018
User Banned
Posted: 5th Mar 2019 21:49 Edited at: 5th Mar 2019 21:50
The flipping word seems to be really upsetting me, what is actually flipping.. between -90 and 90 rather than 0 - 360 degress .. I think i know what you want to acheive, just respond with a yeah or neigh and then can work from that.

Sorry for been thick
Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 22:07
Quote: "If move mouse up and down - to move the red cube object all the way around its Y axis around the whole circumference of white cube"

I'm not moving the red cube i'm moving the camera


To explain the "flipping". I've changed the code to ONLY rotate the camera around the x-ais.
If you click and drag down the camera will rotate in the opposite direction around the a-axis
when the camera is directly above the red cube it will rotate 180 degrees around it's y-axis and z axis and even though it's continuing to go around the correct direction it will appear as though it has reversed direction.

So just try it. Run the app, click and drag down and you will see it flip when you are above the red cube



puzzler2018
User Banned
Posted: 5th Mar 2019 22:18
Are you serisouly winding me up with this little challenge

When you left and drag the moue up and down - your moving the red cube rotating around the white one.

I think your been really silly now... Stop confusing me


Show us a video of what you want to acheive, cause my understanding of what you want to acheive still is zilch....

No offsence but I cannot fathom out what you want to acheive..

Your original post of spheres orbiting around a central sphere looked perfect to me and will always say it will.... is it the Normals (lighting) thats the cause of the issue raised
to bring this to our attention or something lol
Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 22:21
Quote: "When you left and drag the moue up and down - your moving the red cube rotating around the white one."


Show me the code where it's moving the red cube
puzzler2018
User Banned
Posted: 5th Mar 2019 22:30
Ill do a quick vid - two mins
Tier 1 Developer
puzzler2018
User Banned
Posted: 5th Mar 2019 22:37
See - red cube moving around the white one..

Is the red one the camera and white one the object - or visa versa
Tier 1 Developer

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 22:42 Edited at: 5th Mar 2019 22:42
The red cube is not moving at all. The camera is moving.
Thanks for the effort. I appreciate you having a go at this
puzzler2018
User Banned
Posted: 5th Mar 2019 22:46
Its ok - Sure I understand a bit more now.. The object is fixobjecttoobject to the camera.. The white cube is the one the rotates - making the red one move about..

Dammmm.

Cool. let us try and figure it out

Do you want the camera - and things attahached to it move in a full circle.

Maybe you just got your X and Z the wrong way round. depending on how your looking at it.

Start the camera at 0,0,0 place the camera at 0,0,0

Translations can be a bloody nightmare for tranistioning



Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 22:50
Quote: "Do you want the camera - and things attahached to it move in a full circle."

Yes. Imagine a sphere around the point that it is looking at

I think i know what the problem is. The setcameralookat() function is flipping the camera so i think i will have to manually rotate the camera
puzzler2018
User Banned
Posted: 5th Mar 2019 22:52
Go find a You Tube clip on what you like to acheive too. That would be helpful - i hate book reading. I learn more visually


Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 22:56 Edited at: 5th Mar 2019 22:56
Download the AGE3D editor
Run it. The hold down the alt key and click and drag down.
See how it rotates the camera around the center of the scene without flipping?
puzzler2018
User Banned
Posted: 5th Mar 2019 23:04 Edited at: 5th Mar 2019 23:05
Not downloadable anymore

https://github.com/TheGameCreators/AGKAGE3D

Thanks Blendman

Interpret that beast...Welcome to programming that things are not so at your fingertips or thiings dont come so quickly


Ill let you review this and im sure we will all do the same to find the fix to your solution


Tier 1 Developer
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 5th Mar 2019 23:16
The problem is gimbal lock, the solution is usually quaternions, but the math is usually beyond me

Seems like your positioning against the dolly is fine, the problem is likely just with the lookat command.

Can you apply an additional 180 rotation to the flipped axis if you detect that it occurs?
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
puzzler2018
User Banned
Posted: 5th Mar 2019 23:19
Gimbal - didnt think of that - thanks
Tier 1 Developer
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Mar 2019 23:44
Quote: "he problem is likely just with the lookat command."

Yes. This is the problem. I need to rotate the camera myself.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Mar 2019 00:27 Edited at: 6th Mar 2019 03:31
*EDIT* : This works so far. It will probably go to pot when i try to add a roll (or rotation around the z axis)



Im not sure it's a gimbal lock issue. I think it's the way AppGameKit sets rotation values. As Bengismo explained. Maybe this approach prevents a gimbal lock, i'm not sure
This clearly demonstrates the issue;
As the camera orbits the scene, AppGameKit will flip the Y/Z axis when it crosses 90o. This causes the view to appear to bob up and down (Project attached)


You can see the x/y/z rotations (of the camera/dolly) flip at the top left

As i said i think i know the answer (Manage the rotations myself and not use SetCameraLookAt()).

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 6th Mar 2019 21:42
Cool and thanks -- Let us have a think...
Tier 1 Developer

Login to post a reply

Server time is: 2024-04-23 17:19:51
Your offset time is: 2024-04-23 17:19:51