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 good with 3D maths?

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

I'm having issues that have almost got me to breaking point now, so I'm hoping someone can help.

Basically, I have planets, and around them are two light sources (for shaders - lets just consider them two "moons" around a planet). I need them to place on opposite sides, which I have done, and then NOT move as I rotate the planet object (light side of the planet, dark side of the planet)....until zooming in on the planet, at which point I need to rotate the two light sources WITH the planet but in position so that they can be fixed and you can move from the light side to the dark side.

I have this working perfectly in this code by fixing the two moon objects to the planet:



Objects 6 + 7 are the moon objects. However, if you rotate or scale the object before fixing, they randomly jump to completely new locations the the lighting is completely messed up. I have also tried using fixobjectpivot on the planet first to reset it's rotation to zero but keep it as is, however unless the planet is at location 0,0,0 then this then starts moving in it's own elliptical orbit when rotated, and the moon objects move even more erratically.

Has anyone got any ideas?
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 10th May 2016 23:50 Edited at: 11th May 2016 00:07
Sorry, I don't think I was clear in the first post actually. When you fix the moon objects to the planet object, after the planet has been rotated, then the moons move to where they would have been had they always been fixed to the planet - i.e. they seem to have the rotation of the parent applied to them retrospectively.

For ease, I produced this simple example video which should hopefully show what I mean.

Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 11th May 2016 00:43
Hello Santman,

I have not seen the problem that you have shown with fixobject, but I try to establish an advanced math function library, that could help you out with this kind of problems.
https://forum.thegamecreators.com/thread/217064
A rotation Matrix should help you to get the right position of the moon in relation to the earth, but there Iam stuck right now. It would be great if someone with good math experience could
contribute there, so all rotation can be managed directly into the matrix4 commands.


[/url]
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th May 2016 21:30
Hi Jack.

I may have found a way around it for myself, but I'm still testing it now. It's just slightly infuriating but I guess that's programming. Lol.

Will keep this updated with my success/failure.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 13th May 2016 18:39
I got it working, found a different, better way of doing it.

Still not sure that fix object is working the way it should, but it's working.

Login to post a reply

Server time is: 2024-09-29 13:36:37
Your offset time is: 2024-09-29 13:36:37