[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Simulating vehicle body

Simulating vehicle body

Official forum for the .

Re: Simulating vehicle body

Postby slembcke » Tue Dec 04, 2007 10:12 am

Yeah, you don't want to be setting the velocity explicitly each frame. Making small adjustments is ok, but making large adjustments effectively kills the ability of the physics to deal with collisions.

That car physics tutorial I mentioned above talks about how to calculate the friction forces you need. Citrys's solution kinda fakes them, and is much simpler to implement. Try that first. I've always surmised that they do a similar thing for the friction of the jeep in Halo 1 due to how nice and slidey it is, though I've never tried it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Simulating vehicle body

Postby joe » Tue Dec 04, 2007 2:08 pm

Hi people,

first off: thanks for you replies. The problem currently is not so much as to get the vehicle to drift (it already does if I want it to), but to get the new velocity vector into the system without touching the velocity vector (instead using forces or impulses). But your approach in "faking", citrys, is a lot cleaner than my current one (I basically let the rotation "lag" behind in some cases). I've read through the paper on car physics and implemented some (not all) of it: the tangential function, for example - which I in my case replaced by a sigmoid function. It gives the car a nice feeling of oversteering at a special point (e.g. when a combination of too high speed and slippery underground combines - there it is).

But as I said - I solved that. Now the real problem is changing the rotation and speed of the vehicle without touching the velocity vector. So I thought of the forces which would need to be applied.

I've made an illustration (yeah, I'm kind of an artist): http://bildrian.de/n/b/3cad8c19c6a250ae.png

Top is accelerating, Bottom is decelerating/reverse. Left to right is steer left, drive forward, steer right. So the arrows I drew in there should be the points where the (impulse?) force should apply to the body (leaving the driting thing completely out here for now). The problem is that I obviosly don't have a clue when to use impulses and when to use forces. I also totally don't get whe the offset vector "r" should be in world coordinates - sure the doc doesn't mean body coordinates here? When I set "r" to zero I get the results I'd expect when setting the *body* coordinates to zero.

Anyways, I just can't get it done. When I use forces the vehicle continues to accelerate infinitely or rotating like crazy. Resetting the forces every time step every time can't be the solution, or can it? When I use impulses the vehicle first turns but then bounces back like a spring.

The forces thing is so frustrating. I can't even get a freaking car simulated. Currently I'd just like to print out all the code I wrote and make some huge bonfire. God, guess that is currently because I'm really suffering from cerebral shortcircuiting after 8 hours of college classes, maybe I should just go to bed and have a look at it sometime else.

I really appreciate all the help you're giving me here. Please be patient with me, I'd be so proud if I got it running and you could see those little vehicles (yeah the sprites are ugly, but, hey) driving around :-) It's all in my head, I can clearly see it ;-)

Greetings,
Johannes
joe
 
Posts: 10
Joined: Sun Dec 02, 2007 3:27 pm

Re: Simulating vehicle body

Postby citrys » Tue Dec 04, 2007 4:19 pm

citrys
 
Posts: 16
Joined: Thu Nov 15, 2007 12:26 am

Re: Simulating vehicle body

Postby slembcke » Tue Dec 04, 2007 8:14 pm

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Simulating vehicle body

Postby joe » Sat Dec 08, 2007 8:04 pm

Hello again,

okay, I've now set up a pretty cool car simulation which works by only using implied forces (drag, axis, centripedal force) thanks to your help. So I'm not manipulating the velocity vector explicitly, but let the engine do everything via ApplyForce calls. Problem is: the tank still freaks out when colliding. This is a video of the tank colliding with a static object (invisible line shape, infinite mass/inertia): http://www.file-upload.net/download-546 ... e.mpg.html

What can I do about that weird behavior?

Greetings,
Johannes
joe
 
Posts: 10
Joined: Sun Dec 02, 2007 3:27 pm

Re: Simulating vehicle body

Postby joe » Sat Dec 08, 2007 8:35 pm

Sorry for my previous posting, I've fixed the problem now. It was with the inertia of the body which needs to be calculated from the mass and shape of the object. I currently just kind of made them up.

If inertia and mass/shape are interlinked in such a way - why seperate them in the first place? Or to paraphrase that: when is it necessary to have an object of high mass an low inertia (or vice versa)?

For those who like pretty videos, here's one: http://www.file-upload.net/download-546 ... n.mpg.html

I'm so proud! Wouldn't have ever worked without you guys, thank you so much. I sure hope the game is finished at some point in time, it's going to be cool :-)

Greetings,
Johannes
joe
 
Posts: 10
Joined: Sun Dec 02, 2007 3:27 pm

Re: Simulating vehicle body

Postby slembcke » Sat Dec 08, 2007 8:57 pm

Well, the mass doesn't really have any thing to do with the shape of the object. The moment of inertia on the other hand has to do with both the mass and the shape. To be even more specific, the moment of inertia has to do with the distribution of the mass about the center of gravity of the object. The distribution of mass isn't exactly linked to the shape.

For instance, imagine two spheres of the same size and mass. The first is something hollow like a ping pong ball, while the second is solid. Despite having the same size and shape, the moment of inertia will be lower on the solid ball. This is because some of the mass is very close to the center of gravity (having little effect on the moment of inertia) and some is far away. In the hollow ball, all of the mass is at the same distance from the center of gravity. If you were to roll both balls down a ramp, the solid ball would get to the bottom first due to it's lower moment of inertia providing less resistance to angular acceleration.

So to answer your question, you could have an object with a large mass and low moment of inertia if most of it's mass was concentrated near the center of gravity. Likewise for an object with a low mass and large moment of inertia if most of the mass is concentrated far away from the center of gravity.

Wikipedia knows all: http://en.wikipedia.org/wiki/Moment_of_inertia
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Previous

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 2 guests