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 Discussion / Rotating an object based on 2 points

Author
Message
KNau
22
Years of Service
User Offline
Joined: 25th Nov 2002
Location: Canada
Posted: 8th Nov 2003 17:18
I know..I know..the "how do I find an angle between two points" question has been asked before - many times. Unfortunately, when I did a search on the subject I found links that were no longer active or information that didn't apply. So here goes...

I have a vehicle model that I am driving around on an imported .X object landscape. I need my vehicle to angle correctly so that it hugs the ground when driving up hills, along ridges, etc. The method that I am attempting to use is by having 4 hidden collision objects - one in front, one in back and one on either side of the vehicle. I keep each collision object hugging the surface of the ground and use the difference between left and right to figure out the bank of the vehicle and the front and back differences to figure out the pitch. I think this is how it was done in the tank demo but I can't really make heads of tails of Lees poorly commented code

Oh, under no circumstances am I using a matrix object, even if it's hidden. This is an .x object only.

In the code sample I've include I am simply trying to figure out how to angle my box object between two spheres that can be raised or lowered and so far it isn't working. If anyone can check out my code and see what I'm doing wrong (I don't really understand it at all) it would be appreciated. Or if you can think of another efficient and simple way to achieve the same result, I'm all ears

In the code sample the mouse moves the selection object. Left click to raise or lower the selector or one of the spheres. The box is supposed to angle in real time to the sphere movement, which it doesn't

Thanks for your help!

http://www.canceriannewmedia.com

Login to post a reply

Server time is: 2025-05-21 16:47:46
Your offset time is: 2025-05-21 16:47:46