multiple body treated as an integrated body?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

multiple body treated as an integrated body?

Postby Neo » Thu May 24, 2012 4:43 pm

I'm loading a tank model into my game, but the tank model was divided into 3 parts. I wish the tank to move as an integrated body, and fall apart when explode.
The problem is how can i do it, i've created newton bodies for each part, but when collide with sth, they fall apart..:(
And it's impossible to create one nowton body for whole tank, the upper part can rotate...you know... it's not a static model...
I use irrlicht for rendering, it can treat the upper part as the child node of the main body, I wonder if newton dynamics have similiar feature...

BTW, I dont know how to create a car controler...it's a little difference from the example: player controler: i wish my tank could accelerate gradually to the max speed when player push the key. Does anyone have solution?thx
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: multiple body treated as an integrated body?

Postby Julio Jerez » Fri May 25, 2012 7:07 am

you can use a compound collisions
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple body treated as an integrated body?

Postby JoeJ » Fri May 25, 2012 5:06 pm

Neo wrote:And it's impossible to create one nowton body for whole tank, the upper part can rotate

gun-pipe + drivers-cabin = compound, which could be joined to the bottom object with a hinge joint.
I think the hinge from the joint lib has motor support to control the gun pipe direction.

Neo wrote:I dont know how to create a car controler

float inContactWithGround = detect and project to some some fuzzy between 0 and 1; try simply 1 first...
float grip = clamp (0, 1, tank.upVector dot world.upVector);
grip = pow (grip, 3);
grip *= inContactWithGround;
vector force = tank.frontVector * grip * thrust;
vector torque = tank.upVector * grip * steer;

... thats really approx., but it's a start
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: multiple body treated as an integrated body?

Postby Neo » Sat May 26, 2012 10:13 am

Julio Jerez wrote:you can use a compound collisions

ooch...i forgot there's sth called compound collision...thx
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: multiple body treated as an integrated body?

Postby Neo » Sat May 26, 2012 1:16 pm

JoeJ wrote:
float inContactWithGround = detect and project to some some fuzzy between 0 and 1; try simply 1 first...
float grip = clamp (0, 1, tank.upVector dot world.upVector);
grip = pow (grip, 3);
grip *= inContactWithGround;
vector force = tank.frontVector * grip * thrust;
vector torque = tank.upVector * grip * steer;

... thats really approx., but it's a start

i got confused about your words...what does grip here for? plus, what if i import a car without tire? I created a Newton box for tank, and made the tracks' motion into mesh animation(static physics) in order to save system resources.
However, the problem is, how to tell the tank to climb over the stairs? Any ideas?
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: multiple body treated as an integrated body?

Postby JoeJ » Sat May 26, 2012 1:45 pm

Grip means: How good is it possible to put power to the ground, because the contact situation allows high friction.
If tank rests horizontally on ground, friction is good, so good driving.
If tank gets more vertically, situation gets more badly, and driving will not work.
grip = pow (grip, x): with x you can control, how good driving will work at various angles.

I can't speak for the car, as i never worked with it - it's surely more complex.
The code i've given is maybe the most simple way, but it may be enough.

To be more accurate, you could apply the forces on more positions aligned to the chains, using that formula:
http://newtondynamics.com/wiki/index.php5?title=How_can_I_control_an_object_using_a_physics_engine%3F
That way you could do the steering (go left / right) without the torque, by setting different speed on left / right chains...

Neo wrote:However, the problem is, how to tell the tank to climb over the stairs?

You could change the box to (sideview):

\-----------/
..\--------/.......

Some trapezoid-shaped object. That should allow some climbing.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron