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.

DarkBASIC Professional Discussion / In need of (mathematical) help with rotation.

Author
Message
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 20th Mar 2011 00:27
Hi, I could use some help with a little problem I'm having with rotation.
The problem is this: I have a model (a spaceship) and I need a way to check only the left and right side of the ship to see if it collides with another model or the environment.
I know how to raycast from the center of the spaceship to the left and right, but I need the ends of the raycasts to rotate with the spaceship. And, that is where the problem lies. I know there must be some formula to calculate, but its been way too long since I had maths, so I dont remember what it was.
So, when I rotate the spaceship (from the center) to the left/right, the endpoints of the raycasts both left and right, should rotate. Sorta like the moon around the earth.
Can someone help me with this?

this is the piece of code that does the controlling/rotation of the ship:



Thanks in advance.

SLAYER RULES! YEAH, MAN!!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 20th Mar 2011 13:42
Sorry for the bump. But uhm, does anyone know or has a better/easier idea to check only the sides of a model against collision?

Thanks.

SLAYER RULES! YEAH, MAN!!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2011 13:55
Could you place two hidden marker objects at the wing tips and test those for collision instead?
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 20th Mar 2011 14:08
Quote: "Could you place two hidden marker objects at the wing tips and test those for collision instead?"

Yes, I could, but the problem remains the same, right? The two hidden objects need to rotate - only if the ship rotates - in a circular way around the center of the ship, like the moon rotates around the earth. The distance of the objects away from the center of the ship needs to stay the same.

Cheers

SLAYER RULES! YEAH, MAN!!
Wyldhunt
16
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 20th Mar 2011 14:17
As luck would have it, I just noticed another thread in the DLL forum that may have enough code to get you started.

See if anything here helps with the math:
http://forum.thegamecreators.com/?m=forum_view&t=180891&b=18
Jimmy
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 20th Mar 2011 14:41
When I need to do this, I cheat and place joints on the model where I need to check for collision and then attach hidden objects to the joints with the Glue Object To Limb command. Once you've done that, you can get the positions of those hidden objects for your raycasting.

NaGaFailMo.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2011 15:22
That's the sort of thing I had in mind. Thanks for clarifying that.
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 20th Mar 2011 17:12
@Wyldhunt:
I did do a search for my problem before asking for help here, and found the same thread you just mentioned. I tried out the code several times, trying to adjust it for my needs, but it didn't work as I would like to.
The dummy object I placed where the endpoint of the raycast is, did rotate in a circular way and always stayed positioned at the same position relative to the center of the ship, but unfortunaly it wasn't positioned at the left or right side of the ship, but in front of it.
Thanks anyway for the help.

Quote: "place joints on the model where I need to check for collision and then attach hidden objects to the joints with the Glue Object To Limb command. Once you've done that, you can get the positions of those hidden objects for your raycasting."

Yeah, that came to my mind too. The limbs would automatically rotate in a circular way around the ship, and keep their exact position relative to the center of the ship at all times. I wanted to go the maths route first, cuz we're never too old to learn, right?
Thanks for the suggestion, Jimmy.

Quote: "That's the sort of thing I had in mind."

Yep, I thought you were, but wasn't sure. Sorry for the misunderstanding, GG.

Cheers

SLAYER RULES! YEAH, MAN!!

Login to post a reply

Server time is: 2026-07-17 13:58:56
Your offset time is: 2026-07-17 13:58:56