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 following the surface of a sphere

Author
Message
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 29th Jul 2016 21:45 Edited at: 30th Jul 2016 10:20
Hi,

I'm trying to make an object fly around, as if it were subject to a planet's gravity. It works, until the ship reaches one of the poles. Anyone know what I'm doing wrong or how to fix it?



Thanks,
John
Hi. I am a real person (not a bot). I appreciate all replies and advice.
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 29th Jul 2016 22:17 Edited at: 29th Jul 2016 22:24
My guess, the problem stems from using the sphere's normals, which can be wonky at the poles. Unless it is an icosphere, it won't have a face at the pole and won't give a good normal. This pinching of the geometry is a familiar issue to anyone that has tried to uv map and texture a sphere

Because it is a sphere though, you can just use some maths against the object center



A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 29th Jul 2016 22:31
Thanks Ortu. That sounds about right.

I'll use Blender to create an icosphere and use that.
Hi. I am a real person (not a bot). I appreciate all replies and advice.
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 30th Jul 2016 00:31
Hmm. I just loaded an isosphere instead and I still seem to be getting problems at the poles.
Hi. I am a real person (not a bot). I appreciate all replies and advice.
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 31st Jul 2016 10:35
I'm now using maths, rather than raycasting to calculate the orientation and position of the ship. However, I have the same problem of the ship getting stuck. After doing some debugging it has become apparent that depending on the position of the ship, the SetObjectLookat function rotates the ship differently. So, if the ship is at the front of the sphere I need to rotate the ship on the X axis by 90 degrees to make it move perpendicular to the surface. If the ship is at the back of the sphere then I have to rotate it on the X axis by -90 degrees. This is what leads to the ship getting stuck at boundaries.

Any idea how to solve the problem i.e. easily calculate which way to rotate the ship depending on Euler position?
Hi. I am a real person (not a bot). I appreciate all replies and advice.

Login to post a reply

Server time is: 2024-11-25 03:58:22
Your offset time is: 2024-11-25 03:58:22