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.

3 Dimensional Chat / How 2 tilt a model to the terrain

Author
Message
Scary_Liam
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location: United Kingdom
Posted: 10th Mar 2003 18:41
Hi any1. i havent been doing darkbasic 4 long but im doing my first game at the moment and im a bit stuck.
im trying 2 get the vehicles to tilt 2 the angle of the matrix. im using the example off of the darkbasic website but sometimes it tilts in the wrong direction.
any help or other ideas would be wellcome. chers.
Andy Igoe
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 10th Mar 2003 19:31
Yeah this is actually quite hard to solve and one I puzzled over for a good while before I realised the solution.

You need to read off the ground height along the two axis of the vehicle so you end up with four variables

bow#
aft#
port#
starboard#

We then need to convert this to our two axis.

yaw#=port#-starboard#
pitch#=bow#-aft#

You can adjust how dramatic the tilt is by increasing the range at which you read the matrix height from.

Now we use this information to rotate the unit.

roll object left vehicleObject,yaw#
pitch object down vehicleObject,pitch#

Also this is where we set the objects Y rotation, this will be explained in a second.

turn object right vehicleObject,vehicleDirection#

After that is our display update

sync

Now here's the cunning part. We undo everything we've just done! Why? Well rotating in 3D on a localised rotational system will make it impossible for us to sustain perpetual rotation because our unis axii will cross. By restoring everything back to 0 again we are ready to simply repeat the process.

It is important to unwrap our rotation using the exact reverse order of our original rotation, so....

turn object left vehicleObject,vehicleDirection#
pitch object up vehicleObject,pitch#
roll object right vehicleObject,yaw#

This is not copy pasted code so I may have crossed my left/right or up/down, but hopefully that fairly clearly explains the principle behind terrain rotation.

Good luck!

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
LLX
21
Years of Service
User Offline
Joined: 17th Feb 2003
Location:
Posted: 10th Mar 2003 19:50
i use the one from the tutorial



obviously you might need to name your own varibles

but i use



Login to post a reply

Server time is: 2024-04-28 01:16:51
Your offset time is: 2024-04-28 01:16:51