Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

tower

vehicle align to terrain

This topic is 5272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A few months ago I started simple project about vehicle moving on terrain. I used faked physics model so my vehicle behave a little unnatural when driving over hills or bumps. I found many useful topics in this forum about car suspension calculations and decided to change entire "physics" in my project. I already calculated forces in each spring, but now I don''t know how to calculate roll and pitch of a vehicle to align it to terrain. Can someone give me just a basic idea how to do it? ... my first post !!! ... --------------- Thanks

Share this post


Link to post
Share on other sites
Advertisement
Typically, you''ll cast four rays from the corners of your car box down to terrain, and extract spring forces from the distance returned. Modify the sprint forces with dampening based on suspension velocity. It sounds like you already have this going.

Now, the box is a rigid body. Each time step, you apply the forces of the springs to that body, and integrate, to get the position/orientation of the box for the next step. The inputs to this integration is, at least, the position and linear velocity of the box, the orientation and angular velocity of the box, the box mass, and the box inertia tensor. The forces you apply from the springs turn into a translational component (acting on the center of the body) and a rotational component (acting as torque).

If you think the math scares you, the BSD license library "ODE" can do these operations for you in a fairly efficient manner. You can use it only to integrate the body; you don''t have to use all the joints, collision, and other goodness that comes with it. www.ode.org for more information.

Or you can just use it to have some good source to read :-)

Share this post


Link to post
Share on other sites
tower:
You shouldn''t determine the orientation of the car explicitly during the simulation. It should be determined by the physics engine by integration. You just add the forces and constraints in every frame, and it gives you the result. If it''s realistic, you have made a good job.
I strongly suggest avoiding using Euler angles for orientation. You will get strange results (I have found strange rotation in the game called Insane. I am sure that they didn''t use quaternion). So the keyword is quaternion, robust, perfect, low numercal drift, better than transformaion matrix, so the best so far for representing orientation. It''s worth knowing them well.
First you should only consider the tyre-ground collision. The tyre is actually a elastic object, so it could be treated like a spring with damping. But it''s not so elastic, that you had to treat it like that. You can just apply constraint on it, to keep it above the ground. But in this case determining the velocity (for suspension damping) is not so simple as in the previous case. However the previous case requires stiff springs (not to let the tyre sink in the ground when landing after a jump), which require smaller timestep, stable integrator.
In my carsim (see my profile) I applied the second solution.
But what you have to do in each case is determining the contact point at each tyre. When you have your contact points (if there is any), you know where to add tyre forces (longitudinal, lateral).
Make your own classes for physics: masspoint, rigidbody, spring, damper, flywheel, integrator, timer,...
From these you can derive your car''s components. Only the tyre (I mean here the tyre model) will be new.
Good luck!

Share this post


Link to post
Share on other sites
What are the minimum physics components I could get away with to simulate a vehicle on an arbitrary heightmap, allowing the vehicle to roll over? No frills basic implementation.

[ed] Hmm, I suppose it's exactly what Mr h+ wrote above.

[edited by - aph3x on June 7, 2004 8:14:16 AM]

Share this post


Link to post
Share on other sites
How do I model the case where the spring is at its maximum compression, to stop the 'wheel' sinking into the ground?
As szinkopa says: need stiff spring with small timestep and stable integrator.
But could I just cancel Y movement then apply full spring force upwards... sounds a bit hacky?

[ed: explain better] I mean the case where in effect I think I need another force in there (separate from the spring) resulting from the vehicle body touching the wheel touching the floor. A sort of a 'velocity canceller' equal and opposite to the current velocity * supported weight..?

[Edited by - Aph3x on June 15, 2004 9:08:18 AM]

Share this post


Link to post
Share on other sites
Cancel Y movement?

If you are in a flat plane, then it's a good idea, but on a hilly terrain it doesn't work. In this case you need the gravity and the spring force to push the wheel to the ground.

The max compression could be modelled as a collision, I think. I haven't treied it yet, give it a shot.

Share this post


Link to post
Share on other sites
By 'cancel Y movement' I mean the crunch when a vehicle lands heavily - the suspension is compressed and effectively gives the max upward force, but also (thinking about Newtons laws here;)) I think there should be a force pushing up from the ground straight through the tyre and spring into the vehicle body equal to the force downwards :. cancelling out the Y velocity, so left with the max spring force upwards?

phew!

Yes I suppose a collision is the ultimate answer - I'm on hilly ground btw ;)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!