Sign in to follow this  
DirectXFreak

Ok, so how did they do it in treadmarks?

Recommended Posts

Hey, How did they do the tank physics in treadmarks? It looks like the tank is just one rigid body... no springs or wheels... Can anybody explain how?

Share this post


Link to post
Share on other sites
Does anybody know? I'm really lost when it comes to tank physics... Can somebody point me in the right direction? I understand rigid body dynamics, but what about driving it around?

Share this post


Link to post
Share on other sites
I would guess it's just a box with 4 contact points at the bottom corners. Not really 'tank physics',
just box physics. I don't think they are doing anything special.

Share this post


Link to post
Share on other sites
Hmmm, ok, so how would you code something like that?
Would you check to see if one of the points are colliding and if so apply the force (acceleration from the gas pedal)? I thinking I'm starting to understand but there's still some fuzziness, any help you be greatly appreciated.
I'm just trying to figure out how to drive it around in 3D!

Share this post


Link to post
Share on other sites
Battlefield 1942 had some amazing tank physics I thought. The ways the track laid over the bumpy terrain was excellent. When tanks fired they rolled back slightly and it all looked perfect.

Share this post


Link to post
Share on other sites
Yeah, they do some cool stuff. But there's no where on the net (at least that I can find) that tells me how! What kind of math equations does treadmarks use? If anybody knows where I can find out then please tell me (and don't say google, I've tried that).

Share this post


Link to post
Share on other sites
Quote:
Original post by Hybrid
When tanks fired they rolled back slightly and it all looked perfect.


== animation not physics. typically for things like firing animations where you want a subtle feel to the "physics" you'll handle the recoil with an animation that just layers above the "physics" of the tank. it's amazingly simple to get a feeling of "amazing" physics if you have a good animator and some really rudimentary physics...

-me

Share this post


Link to post
Share on other sites
Hmmm, ok, I have another question...

If you were going to model a tank using springs and wheels and the base rigid body model, would you model the wheels as mass points?

In other words, would it just be a point where the wheel would touch the ground? And if so, would you apply the force of the treads only if the points were touching the ground? And if that was true, would you then place the base of the tank on top of springs over the box points that would then add the essence of weight tranfer to the tank? (It would pitch slightly when it fires)

Is this a valid way to do it? Is there something I'm missing?

Share this post


Link to post
Share on other sites
The reason I say box physics, because in Treadmarks, the entire tank is two pieces, the turret, and the
body. The turret has nothing to do with how the body moves, so you just have the body. And this body is
one complete unit, all the treads and other detail is just painted on a box. There are no springs, no wheels, or complex connections.
That's my guess.

I haven't played Treadmarks in a while, but you get a sense of the physics by moving the tank over very
steep terrain. Find a map with peaks and try to climb up them and let the tank hang over a cliff
or something. This will give you a sense where those contact points are located.

Share this post


Link to post
Share on other sites
Ok,
I'm starting to get a good grasp on this! Thanks so much for your help guys!

I just have one more question, where would you apply the force on the tank? To the very rear of the box? And what kind of friction equations would you use? Thanks!

Share this post


Link to post
Share on other sites
I would guess if you wanted to create a basic tank/terrain game, it would be like moving a bar of soap
on a smooth surface. :)

That's only if you decide to use basic box physics. You have mass, gravity, velocity, acceleration, and
friction. Physics is only one part. You have terrain, so you need collision detecting. A box only
has 6 points, so these 6 points are constantly being checked for terrain/collision.

If you were doing a space sim (no terrain), then collisions would probably be easier to do.
IMHO, a zero gravity game is one step easier than your basic tank/terrain game.

Share this post


Link to post
Share on other sites
The 8 points method doesn't seem perfect to me. Take this scenario for example...

You have the tank (box) sitting on the terrain. However right in the middle of the tank the terrain rises sharply through the middle of the tank. Just imagine a peak with the tank sitting on it. Now if you use the point method then the tank will sink down through that peak, as the points being tested are all around the peak and none are on it.

The point method in that case, means that you must have fairly smooth terrain.

Share this post


Link to post
Share on other sites
Well I was thinking that for the rigid body part of the tank you check the whole box, so a point in the middle of the terrain would cause the tank to balance on that point, but the treads wouldn't do anything.

As for the bar of soap thing, how the heck would it look like that?! I've looked at treadmarks and it looks like they just put some pretty rough friction on the tank. And it LOOKS like they apply a constant friction without considering which way the tank is pointing.

Hmmm, Well in your opinion, what would be a good way to apply friction and to apply accellerating force on the tank.

Share this post


Link to post
Share on other sites
Looking at this picture...

http://www.fas.org/man/dod-101/sys/land/m1-003.jpg

I would represent the main bulk of the tank as a low polygon rigid body that represents the rough shape of it.

For the tracks, I'm wondering if it would be good to simulate all those wheels within the tracks as separate mass point wheels? The tank would certainly be able to climb over the terrain more realistically I think. As for applying acceleration/driving force on the tank, you can see if there are enough wheels from each track in contact with the ground and apply a forward force based on that. I would have two main driving forces one for each track. and drive it like a normal tank - e.g. to turn left on the spot, move the right track forward and the left track in reverse.

There are 9 wheels per track on in that picture, and I'm not sure the best way to apply the driving force though... I've thought of the following options...

1. If any of the 9 wheels per track is contact with the ground then apply a constant driving force for that track. This method is the simple one and will result in the tank driving in a straight line more consistently.

2. Modulate the driving force based on the number of wheels per track in contact with the ground. However, as wheels go in and out of contact with the ground, the driving force for that track will keep getting modulated differently and could result in the tank turning/shaking left to right over bumpy terrain in particular.

3. Similar to 2, but instead of one driving force per track, why not have smaller driving forces per wheel and apply them all? If the wheel is not touching the ground it doesn't apply a force. If a wheel is in contact apply the driving force or perhaps even modulate it based on the pressure (grip) the wheel is applying on the ground?

What do people think of the above suggestions?

Share this post


Link to post
Share on other sites
Yeah, basically, the more contact/collision points you have, the more smoother and more realistic your simulation
is going to be.

If you think about it, I would say a real surface has an infinite amount of contact points.

Question is, how much can you get away with before your game slows down to a crawling pace?

Share this post


Link to post
Share on other sites
I haven't attempted to do terrain collision in a long time, but I do remember there's no such thing
as a perfect collision. An example is a fast moving object colliding with terrain. You have two
times, one before the collision and one after, and you have to extrapolate back along the time curve
using the quadratic formula to the place where the collision actually happened. That's at least what
I can recall. You might be attempted to just move your object straight up until it rests on the terrain,
but that's a poorman's hack.

Share this post


Link to post
Share on other sites
Hmmm, Great suggestions hybrid.
I was thinking, like your last suggestion if you modeled the wheels as mass points, you could put springs on them so that if the tank went over bumpy terrain terrain, you would see each wheel on the tread rise slightly then spring back. You could model the tread to the wheels so that it changed shape to match the terrrain...

i would think that for the wheels, you would make the angular position be the same for all of them, then just edit it based on the movement of the treads.

So basically what you would have are fake wheels, they just have mass and apply force to the tank. You could use hybrid's last suggestion and use driving forces per wheel. But then find the average of all of them and apply that to each wheels masspoint. This would move the rigid body model because of the springs. (they would have to be locked to the vertical position) What do you think of this idea?

Also, this would sorta fix raydogs problem too, because each masspoint would have a radius, so each point would be touching the one next to it. (like the wheels in the pic provided by hybrid)

What do you think?
Would this work?

Share this post


Link to post
Share on other sites
Would you need to average the forces being applied to the wheel mass-points? If you just applied the forces calculated at each wheel to each individual wheel, won't it be more realistic? Perhaps averaging will produce smoother movement though?

Yep, having the wheels on springs would be expected. It's gotta be pretty satisfying having your tank with tracks and wheels that perfectly align to the terrain. :)

Oh yeah, and I was thinking about when the tanks fire and they roll back slightly due to the firing. Palidine said this was animation layered over the physics, but I was thinking about it more and having doubts as to whether the rollback effect of the tank when it fires was animation. I was wondering that if you have springs on each wheel then you could make the tank roll backwards slightly and rotate onto its back wheels by applying a force above the Centre of Mass, so that the force invokes rotation only, not movement. So when the tank fires, you apply a 'firing force' horizontally acting on a point above the COM. The tank will then rotate onto its back wheels (but naturally the suspension will dampen the rotation) and the tank will 'wobble' slightly. I have a feeling this will look amazing and also look realistic as well as being simulated, not animated.

Share this post


Link to post
Share on other sites
Yeah, all they do is let the springs do it.

If you applied a force to the body of the tank, the wheels with the springs would reset it to it's original position, but it would rock back and forth. That would be awesome!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this