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.

Dark GDK / Moving object based on current rotation.... not using dbMoveObject()

Author
Message
Duncan
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 24th Aug 2008 23:21
I'm working on a space sim where movement is determined not only but the current direction, but also planetary gravity.
Basically every cycle:
-Find added velocity due to any acceleration from gravity.
-Find added velocity due to ships own acceleration.
-Add these to the current velocity.
-Move ship.

Ironically getting the first step and third step is easy. But am having trouble just figuring how to move the ship based on it's own acceleration. I figure I need to get a normalized vector based on it's current rotation and then I can multiply it by it's acceleration. But how do I get what "direction" the ship needs to be moved based on it's current rotation? I basically want to know how the dbMoveObject() function works.

Thanks!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Aug 2008 23:45
You can't use the dbMoveObject command easily for this kind of movement.

Basically, you would have a vector for current velocity. Add to this a vector for acceleration due to the engines (which would normally be in a forward motion, ie related to your current angles), then add the vectors for acceleration due to gravity for all planets & the local star. That becomes your new velocity. The final step is to add your velocity vector to your current positional vector.

It's not scientifically accurate, but more than good enough for a game.

Duncan
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 25th Aug 2008 02:27
Exactly. So the problem is this bit:
"Add to this a vector for acceleration due to the engines (which would normally be in a forward motion, ie related to your current angles),"

How would I go about this? It seemed like it would be trivial.. but once I sat down to do it I couldn't really come up with a way. Given that I know the objects orientation given dbObjectRotationX, Y, Z -- how do if get the forward motion? I assume I'm try to get a normalized vector that would represent this.

Thanks for the reply.
Duncan
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 25th Aug 2008 02:31
Hmm... I made a reply to this but didn't see it. If it double post I apologize.

Anyway thanks for you answer and I agree but it's this bit:

"Add to this a vector for acceleration due to the engines (which would normally be in a forward motion, ie related to your current angles)"

I can get the current angles using dbObjectRotaionX, Y, Z -- but using this how do I figure out the acceleration vector? I assume I need to get a normalized vector the represents the direction I'm going then multiply by what ever that acceleration is.. but I can't figure out how to do this.

Thanks.

Login to post a reply

Server time is: 2024-09-30 05:34:16
Your offset time is: 2024-09-30 05:34:16