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 / ANyone help with rotating a 3d object around another 3d object on the Z axis?

Author
Message
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 31st May 2016 23:29
Hey everyone.

Ok, maths is completely beyond me at this level. What I need to do is rotate one object with another so that they stay together. Or specifically, I have a planet, a sphere, which is rotating and I need to an object to stick to the surface at a specific point. The point that it sticks too needs to be computable through maths though, and this is beyond me.

I've gotten as far as this thanks to the space demo which came with AGK:



What this achieves, is it makes the object stick perfectly to the sphere, but only when it;s rotated around the Y angle. If you try any other angle, it fails dismally, and so the planet cannot be rotated on the X axis.

Does anyone know how to do this?
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Jun 2016 08:37 Edited at: 1st Jun 2016 08:39
Here's my orbit code:


To do what you're wanting to do you would call it with:


angle# will need to be increased in order to see the 'moon' orbit the 'planet'. You could set that to be the same as Timer() to test it.

Note: If you try orbiting in multiple planes then you may suffer from Euler lock. In which case you would be better using quaternions but they are not for the faint hearted!
AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Jun 2016 11:41 Edited at: 1st Jun 2016 11:44
or you can use a dummy object, rotate it at center and move along local axis you get your orbit pos. for your planet and after that move the dummy back.
Turn Dummy Center RotateObjectLocalY ( objID, amount )
MoveObjectLocalZ ( objID, +100)
Get the Position for Planet
MoveObjectLocalZ ( objID, -100 )

your dummy can align in world space once by
RotateObjectGlobalX ( objID, amount )
RotateObjectGlobalY ( objID, amount )
RotateObjectGlobalZ ( objID, amount )
AGK (Steam) V2.0.18 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 1st Jun 2016 15:19
Thanks guys, the answers were very much appreciated.

I took Marcus root last night and decided the maths was beyond me (is it called the Hergle effect or something), and decided it must be possible another way and hopefully have it working.

Then issue was, the planet doesn't spin, it rotates by moving the UV of its texture, so the planet based objects needed to follow that. In the end, I created a dummy planet, hid it, locked the surface objects to it then rotated it at the same speed as the texture. Then, when the planet needs to rotate, I locked the dummy planet to the main planet itself and everything *seems* to work.

That angle stuff is DEF useful than though, thank you for that.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 1st Jun 2016 15:24 Edited at: 1st Jun 2016 15:25
Anyway, here's a dodgy phone captured video that I got at 2am yesterday.

I think it works OK?

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jun 2016 12:09
Looks great!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 8th Jun 2016 00:42 Edited at: 8th Jun 2016 00:44
Thanks CJB, much appreciated.

So I've discovered that mixing 2d and 3d in AppGameKit is not exactly easy, however the basics now almost seem working. What do you guys think of the trading interface? Obviously menu's and such are next, along with actual stock to trade, but is the premise ok? Any suggestions? Here's a better quality video.

Login to post a reply

Server time is: 2024-11-25 06:47:22
Your offset time is: 2024-11-25 06:47:22