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.

DLL Talk / Vehicle wheels to a terrain object???

Author
Message
SpiderPig
10
Years of Service
User Offline
Joined: 11th Jul 2009
Location: Australia
Posted: 16th Jul 2009 08:14
Does anyone know how to get a vehicle to rotate so that all the wheels are on the ground??

I have Ez rotate, but I don't know exactly how to do this with it or if I should just use the DB Pro commands?

Anyone got any ideas?

thanks in advance
NeX the Fairly Fast Ferret
14
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 19th Jul 2009 23:39 Edited at: 19th Jul 2009 23:44
Find out the angle the rectangle of terrain the car is on. The atanfull command will come in handy for this. Given an X and Y, it returns the angle relative to 0, 0. Figure out the angles of the four lines that make up the tile the car sits on.

However, if the terrain has a sudden bump and/or the car is very long, the angle returned won't always be perfect.

The way to solve this is to first find out the exact height of the terrain under each wheel. But this then creates a paradox; when you adjust the wheels to match the terrain, the car is rotated and so the wheels move.

Ish.

AndrewT
12
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 30th Jul 2009 20:42
Yes, doing this can be quite difficult and I think you're probably just finding using DP or Newton.

It seems like it would just be a matter of checking the height of the terrain at each wheel. But as NeX pointed out, what if there's a large bump in the terrain between the wheels? Because you're only checking the height at the wheels the car would not register this bump and would be much lower than it should be.

i like orange
RiiDii
14
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 7th Aug 2009 03:17 Edited at: 7th Aug 2009 03:19
My solution to this problem was not a dll. I used limb rotation instead. Basics: 3D terrain movement is basically the same as 2D (x,z) terrain movement with two fundamental differences. The first is terrain height. This difference is easily handled with Get Terrain Ground Height() or similar function to determine the height of the ground. Then simply place the object at the x/z 2D coordinates at the ground-height y coordinate.

The next addition is angles on the terrain, which is what you are asking about. But I pointed the 2D movement for a reason; "keep it simple." Think of the objects on the terrain as moving only in 2D space. Or perhaps, think of 'shadow' objects at the y=0 height. Movement by these objects is basic. Turn on the y-axis and move forward/backwards & left/right on the x/z plain. the only thing left now is to calculate the angle on the terrain.

There are two obstacles to overcome with this. The first is the y-axis angle tends to really screw everything up and make finding the angle on the ground difficult at best. The second obstacle is that once the object is rotated to match the terrain, the y-rotation gets screwed up. We need a method that handles both at the same time. Sort of like a Heisenberg Compensator.

The solution is to retain the y-angle of the object and still angle rotate the object based on the ground heights. This can be done by rotating limbs within the object. Limbs within an object retain a sort of "local-space" coordinate and angle system. That is to say, the object can be rotated in any direction without changing the limb's angles (or position) relative to the object. So, while the object's Y-axis rotation is adjust by the direction the object is facing, the limb can be rotated to match the terrain.

This works perfectly by itself if the object is not animated and has limbs. Of course, that's pretty restrictive for most games. The solution would then be to create a dummy-object that would be placed, rotated, and twisted based on the terrain, and then place the actual game-object at the limb's global (opposed to local) coordinates and rotate to match the limb's global angles.

The code snippet below was used for spider-critters that needed to stick to heavily angled terrain. I used limb 1 for angles on the terrain and I used limb 0 for a wiggle angle (makes the spiders wiggle when they walk). You can eliminate the wiggle and switch limb 1 to be limb 0 as needed. Of course, if you are not using Advanced Terrain, other adjustments will need to be made.

Oh, and this is pure DBPro. No DLL's. If there is a dll command/function, it is probably from IanM's Matrix 1 Utilities.




Open MMORPG: It's your game!
CuCuMBeR
16
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 7th Aug 2009 13:19
AI Get Entity X and Y(ObjectID) <- darkai commands

Anyhow, if you want to make vehicles, Newton wrapper is your best option.

There is always one more imbecile than you counted on.
SpiderPig
10
Years of Service
User Offline
Joined: 11th Jul 2009
Location: Australia
Posted: 22nd Aug 2009 10:29
Thanks everyone for the info,
I'll give it all a try and see what i come up with...
I'm giving Newton Wrapper a look through now, it looks promising thx!

"I ask you,....what could possibly be in my eye that would explain this!?" - Jack O'Neill : Stargate SG-1
SpiderPig
10
Years of Service
User Offline
Joined: 11th Jul 2009
Location: Australia
Posted: 9th Sep 2009 00:45
I'm going to try and use Sparkeys 'SC_IntersectObject()' command to get the exact wheel positions, and then rotate the body to match, so far this is looking good!

Then I'll write a function to test if it hits a rock or bump under the chassis, and cause drag to the vehcile, and/or lift a wheel off the terrain.

I'll let everyone know of my progress when I get to this stage!

"I ask you,....what could possibly be in my eye that would explain this!?" - Jack O'Neill : Stargate SG-1
SpiderPig
10
Years of Service
User Offline
Joined: 11th Jul 2009
Location: Australia
Posted: 7th Nov 2009 22:44
I've been working on a different project lately....
as for the car, "SC_IntersectObject()" worked for exact wheel positions, and pointing the axle first to the other wheel position,
then the body will rotate to the axle accordingly.

Of course, when you hit a hill, the forward half of the wheels disappear through the terrain....this will require more functions to test not only directly below each wheel, but in front as well..

hopefully by the end of all this i will have a realistic car physics engine!!

"I ask you,....what could possibly be in my eye that would explain this!?" - Jack O'Neill : Stargate SG-1

Login to post a reply

Server time is: 2019-10-17 03:47:41
Your offset time is: 2019-10-17 03:47:41