Tank demo (using material callbacks)

Share with us how are you using the powerrrr of the force

Moderator: Alain

Tank demo (using material callbacks)

Postby Sascha Willems » Thu Jul 21, 2005 6:09 pm

After playing some (sadly rather bad) tank game I also wanted to implement a tank in Newton and thought about how doing that. Recrating the tracks piece by piece was something I did some months ago but it was neither very great to drive nor was it's performance acceptable. Raycasting would be an alternative, but I like to try out things others haven't already done. So I sat down and then I thought : Hey, basically tank tracks are nothing else than "inverted" conveyor belts. Instead of being static and transporting stuff it moves itself and some attached body.

So I used an old model of a JagdPanther I modelled last year (for learning purposes, it's a rather easy to model WWII-tank) and plugged it onto a landscape. The tracks come from a separate mesh and I applied a special material to them that has a callback where I do almost the same stuff as Walaber with the material callback for his conveyor-demo (it's also here in the showcase, just search for it). And after some testing and tuning and trying I finally got it to work and I must say that it feels nice, even better than the tank of the so-called realistic tank-simulation I played today (which gave me the impulse to create the tank demo). So it's again just impressive what one can do with Newton's material system.

Here is a screenshot (clicky) :
Image

And since a static picture is totally boring and videos are very common here, you can download a video of the tank in action here (~1min20secs, 5 MBytes, WMV-format).

It's a bit late here (almost falling asleep), so I haven't had the time to finish it up (not 100% content with it) and upload the demo. But I think I'll be able to upload it within the next 2 or 3 days, so you can see yourself what Newton's material system can do. It's not only impressive that such a thing is possible with materials, it's even more impressive at how easy this is. The callback for the tracks is only ~10 lines long and there is no single line of higher mathematics in it. Although this isn't the perfect solution for a super-realistic tank-simulator it's nothing short of how other current games implement tanks (at least I haven't seen a game where the track bends realistic on the terrain).
User avatar
Sascha Willems
Moderator
Moderator
 
Posts: 346
Joined: Fri Aug 27, 2004 10:18 am
Location: Germany

Postby Julio Jerez » Thu Jul 21, 2005 7:24 pm

Dark master Sascha perhaps you should post a tutorial in the FAQ or in the wiki, for the youngerrrr apprentices explaining how you manipulate the dark secrets of the material side to create life, I mean game play.
I once suggested a similar idea to a younger apprentice but the engine was not as forgiven as it is now, and the idea did not really worked. But now is strongerrrr and morrrrrre powerfurrrrr that this kind of idea can be implemented.
Awesome man, I have not idea how you did it, I do not even want to know, All I thknow is that it is really cool.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby martinw » Thu Jul 21, 2005 8:26 pm

Awesome :shock: Great work.
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Postby walaber » Thu Jul 21, 2005 10:52 pm

very, very, very cool! can't wait to try it out on my own :D
Independent game developer of (mostly) physics-based games. Creator of "JellyCar" and lead designer of "Where's My Water?"
User avatar
walaber
Moderator
Moderator
 
Posts: 393
Joined: Wed Mar 17, 2004 3:40 am
Location: California, USA

Postby Sury » Fri Jul 22, 2005 5:02 am

Awesome work, as usual ! :)
User avatar
Sury
 
Posts: 193
Joined: Sat Aug 14, 2004 5:32 am
Location: Bulgaria

Postby bal » Fri Jul 22, 2005 6:03 am

Wonderful :).
User avatar
bal
 
Posts: 18
Joined: Wed Nov 10, 2004 10:03 am

Postby BigB » Fri Jul 22, 2005 7:05 am

Looking very very good Dark Master Sascha..,
I see the force is strong in you :P
BigB
 
Posts: 78
Joined: Sun Mar 21, 2004 8:08 pm

Postby Julio Jerez » Fri Jul 22, 2005 9:37 am

Here is an idea.
If you separate the vehicle into three parts, the body, left thread and right thread. Then you use a joint to connect then, the is a special suspension custom joint, that I will esplain lately, but for testing you could use a custom hinge.

What you do is you place a custom hinge centered on some nice pivot point at the tank body. Then you add and extra rotational constraint to keep the joint fixed, that will turn the hinge into a fix joint but if you set the stiffness for that one rotational row to something like 0.8 (play with the value) then it will act as a spring/damper angular suspension that will make the body lean forward and back.
By adding one joint on each side now you get two independent suspension tank treads.

If this work the next step is to make the suspensions move up and down. This is simple too, the is a name for this kind of joint in real like they are called sliding contacts.
This are like the corkscrew joint but instead of the spinning part moving longitudinally it moves sideway along a fix axis.
Implemented with care and some joint limits. I believe the final result could be very convincing.
I would try the hinge first, and see how it goes. Another thing is that the suspension will allow the track to be more in contact with the floor and provide more grips.

Can you imagine a battle field with several of those tanks and other vehicles, I guess you could say it is not too hard to make a good game with that that concept alone.

I do not know what it is but I feel something on the dark side of the force that makes people to become more creative.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Sascha Willems » Fri Jul 22, 2005 4:51 pm

Download the demo here(1.3 MBytes)
Please take a look at the readme, it's beta.

I'm short on time so I wasn't able to polish it up like I wanted to. So before you guys bash, me here is what's not correct in the demo : The track itself isn't animated, it's just it's texture. And since I didn't texture the tracks 100% perfect the animation looks awkward on certain parts of the track. If the track is textured right, that won't happen. Also note that the speed of the track animation and wheel rotation is right now taken from the velocity of the tank's body. That's not correct, and I'll change it so that those animations will later be based on the tangent acceleration.

Movement is almost perfect but still there are some problems here and there. And that's basically why I release this beta-demo : I want you to test it out and tell me where it behaves opposite to what it should and what can be improved on the demo. Please not that this is a proof-of-concept, so as of now I don't even know if the method I use can ever be made 100% perfect. I mostly noticed problems when turning while the tank stands on a slope, and driving backwards also isn't acting the way I wanted to. But as I said I'll see what I can do when I get more time to work on this one.

@Julio :
Your idea sounds interesting and I'll give it a try when I get the time. I already make the tank out of three parts (chassis and the two tracks) and I already connect them via a joint (two hinges for each track so that they stay fixed, that's dirty but cheap in terms of lines of code). I'll see when I get to implement your idea.


@Tutorial :
As I said above it's a proof-of-concept. So I won't write a tutorial or something in that vein until it turns out that this concept actually is useable. So you'll have to be patient, but if there are any questions on how I do it I'll be glad to answer them. And maybe I'll also release the sourcecode, or at least post and comment the important parts.

Oh and one thing I noticed (maybe helpfull to others) : You can basically set the maximum speed of the tank with this method by just increasing friction between the terrain and the tracks. It took me some hours to get a good balance between tangent acceleration and friction, but after trying and testing I found out that it's better to have high material friction and lower tangent acceleration for more realistic movement. And once again it's impressive what Newton's material system is able to deliver. If you e.g. just up the friction between the tracks and the terrain you get a lightning fast tank that even can jump over the hills (that's like many modern tanks are : fast and "light"), whereas low friction (remember, it's just two lines of code) makes the tank feel old, heavy and slow.
User avatar
Sascha Willems
Moderator
Moderator
 
Posts: 346
Joined: Fri Aug 27, 2004 10:18 am
Location: Germany

Postby martinw » Fri Jul 22, 2005 5:11 pm

Looks pretty darned fantastic to me, thanks :D
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Postby Assembler » Fri Jul 22, 2005 5:12 pm

do you know where to get the gdiplus.dll from? :( :cry: :x :evil:
Programming is just for 15 year old boys! Not for grown ups! :)

http://www.celement.de (currently german only)
Assembler
 
Posts: 47
Joined: Fri Mar 11, 2005 10:20 am
Location: Schorndorf (Germany)

Postby Sascha Willems » Fri Jul 22, 2005 5:51 pm

http://www.microsoft.com/downloads/details.aspx?FamilyId=6A63AB9C-DF12-4D41-933C-BE590FEAA05A&displaylang=en

It's needed because the texture loader supports PNG using GDI+. If you're on Windows XP or 2003 you already have GDI+ installed, so only Win98/2k Users need that DLL. I'll comment out the PNG-stuff from my texture loader for the next release of the demo.
User avatar
Sascha Willems
Moderator
Moderator
 
Posts: 346
Joined: Fri Aug 27, 2004 10:18 am
Location: Germany

Postby _Tux_ » Fri Jul 22, 2005 7:24 pm

great work sascha. except ive noticed a side effect to using such high frictions. if you are going down hill and put the brakes on, the tank rolls onto the turret.
_Tux_
 
Posts: 81
Joined: Wed Sep 08, 2004 10:38 am
Location: UK

Postby martinw » Fri Jul 22, 2005 8:28 pm

I'm glad you pointed that out, I've been trying to get it to roll all the way over the front, not managed it yet, but i'll keep trying; too much fun :D
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Postby Stucuk » Sat Jul 23, 2005 3:20 am

When turning wouldn't it be best to have to have the forward or backward key down, so the tank would know to turn one track eather backwards or forwards when turning right or left, rather then backwards all the time?
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Next

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 5 guests

cron