Breakable NewtonBody

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Breakable NewtonBody

Postby Auradrummer » Sat Jul 03, 2010 2:34 pm

Hello Guys!

Long time not posting here. This isn't because I stopped working with NGD, but because I'm playing around with it and almost simulating a racing car with very good results.

But, what brings me here is another thing:
Only for fun, I'm trying to shot down an airplane here. To do this, I built the various parts of plane in different collisions. So, I can detect where my shot hits.
Now, I want to stick the parts together. Is easy to do it creating joints. But I think that creating a NewtonBody for each part and compute the physics for every part will demand an unecessary processor resource.

Have some way to attach 10 parts but compute physics only for one of them, and make the another only follows what it does?

Thanks!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby kallaspriit » Mon Jul 05, 2010 3:42 pm

Sounds like what you want is compound collision, search for it in the forums and wiki :)
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Breakable NewtonBody

Postby Auradrummer » Mon Jul 05, 2010 4:02 pm

Thanks kallaspriit,

Compound collision cannot be broken, and this annoyed me.
I tried to use joints, and the result was close was I wanted.
Now, I'm working with a method that will allows me to simulate the break of compound collisions, and I think that will work very fine!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby kallaspriit » Mon Jul 05, 2010 4:20 pm

Fixed joints wont work as they are not really stiff and take rather a lot of power to compute. Creating compounds is rather fast, you should be able to do it real time when detaching parts.
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Breakable NewtonBody

Postby Auradrummer » Mon Jul 05, 2010 4:26 pm

AHa, is exactly what I thought! As is composite inside an array, is only rebuild the collision without the missing part. I can make a NULL collision part of the array?
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby Carli » Mon Jul 05, 2010 5:54 pm

what could be a possible condition to break some pieces out of the compound?
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Breakable NewtonBody

Postby Stucuk » Mon Jul 05, 2010 6:21 pm

Auradrummer wrote:I can make a NULL collision part of the array?


If i remember correctly you can.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Breakable NewtonBody

Postby Auradrummer » Mon Jul 05, 2010 8:16 pm

Hello guys,

Worked here, but the Null didn't worked, I have to build a little collision shape to replace by the lost part. Very good ahahaha!!!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby Julio Jerez » Mon Jul 05, 2010 9:44 pm

it is not not a null pointer it is a NULL collision.

but why do you just pass an array without that collision. it should be better.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Breakable NewtonBody

Postby Auradrummer » Tue Jul 06, 2010 9:42 am

Master Julio,

The problem is that the pieces of my airplane are distributed in a 0..8 array. So, I know what the part are by the number. For example, the plane[5] is the Wing. So, when I want to break out the wing, I "NULL" the plane[5] and rebuild. That way, if you are still in flight and loose the rudder, I'll make plane[3] NULL and rebuild. So, you'll lost the wing and the rudder, capisce?

If I simply remove from the array I'll have to reorder and pass it to the software. I'll need an index of parts... more problems...

I'll post the result soon.

Thanks
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby Stucuk » Tue Jul 06, 2010 10:18 am

You could just create a second array when you are creating the convexhull and populate it with the bits that should be a part of it. Then send the 2nd array to newton. That way you still have your original array intact.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Breakable NewtonBody

Postby Aldeminor » Tue Jul 20, 2010 7:50 am

Are this way possible to release parts of compound object? For example, I want to make a spaceship model, consisting of a parts of hull in array, like written here. And when the ship will be destroyed, I need to release all parts in free flight saving basic speed, vector and angular speed of compound object and do not releasing connections between random neighboring parts.
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Breakable NewtonBody

Postby Julio Jerez » Tue Jul 20, 2010 10:07 am

yes absolutely, check out this video


The demo in the SDK is broken now.
However all the funtionalitu is in the NewtonMesh SDK.

This is not a trivial feature to put together precedurally, because it requires lots of user interface.
That is why I stopped making the demo more pollished and I start working of a Graphical editor.

In that video the parts are made by doing random cuts to the the mesh and it took a lot of massagimng to get it right.
considering that it is a precedural demo it came out very good, but is I would hate to do it other model.
as the features become more intertwined with the Graphics I not longer can continue making precedual demos.
To remedy that I stop working on demos and start working on an editor that hopfully will help people to use all of the features in newton visually.
Basically the editor will help you to put together the scene and save to to a file that to can use a s a blue print to load teh result in your game.

The editor will not anything magic, it will just use the power of the engine to help people model scenes in a easier way than trying to figure out how
to use every single function. Unfortunally that is nature of the beast that as featire becoem more sofiticated theay are also harder to underntand and use by teh casual user.
with teh editro I will try to harder teh creativity an dteh inteligence of all user not just teh one teh can undertand the code.

Check the video to see if it is what you are lookin for, and tel me I can explain more how to get teh effect wit the engine.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Breakable NewtonBody

Postby Auradrummer » Tue Jul 20, 2010 1:28 pm

Hi Aldeminor,

There is another way to do what you want.
What master Julio said is the best way to destroy a battleship, because you can loose random pieces (at least, this way I understood).
But if you want to release a part of the compound (for example, you received a shot in the left wing an it flew away, spinning!) you can use the following method:
- Build all the pieces of ship separated;
- Put is on an array;
- Build the compound collision.

When you receives a shot:
- saves all the information of the body you'll need (speed, forces, torque and position).
- destroy the NewtonBody
- set the lost part as an NullCollision (not a NULL pointer)
- rebuild the CompoundCollision
- rebuild body
- set everything back.

You can, now, set the flying wing:
- before setting the lost part as null pointer, make another body with it;
- apply a torque to it (to make spinning)
- apply a force to make it 'eject' from the ship (was thrown away by an explosion, don't forget)
- count some seconds and destroy the body (or leave it there if you want).

This is some steps I used to shoot down a Me109 over here. I'm making more interesting graphics to show a video of it.
As you can see, the limit of the Newton Dynamics engine is our immagination!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Breakable NewtonBody

Postby Julio Jerez » Tue Jul 20, 2010 2:42 pm

but that is what tyhese funtion are support to do.

NewtonCollision* NewtonCreateCompoundBreakable (const NewtonWorld* newtonWorld, int meshCount,
const NewtonMesh* const solids[], const int* const shapeIDArray,
const dFloat* const densities, const int* const internalFaceMaterial,
int shapeID, int debriID, dFloat debrieSeapasationGap);

void NewtonCompoundBreakableResetAnchoredPieces (const NewtonCollision* compoundBreakable);
void NewtonCompoundBreakableSetAnchoredPieces (const NewtonCollision* compoundBreakable, int fixShapesCount, dFloat* const matrixPallete, NewtonCollision** fixedShapesArray);
int NewtonCompoundBreakableGetVertexCount (const NewtonCollision* compoundBreakable);
void NewtonCompoundBreakableGetVertexStreams (const NewtonCollision* compoundBreakable, int vertexStrideInByte, dFloat* vertex,
int normalStrideInByte, dFloat* normal, int uvStrideInByte, dFloat* uv);
NewtonbreakableComponentMesh* NewtonBreakableGetMainMesh (const NewtonCollision* compoundBreakable);
NewtonbreakableComponentMesh* NewtonBreakableGetFirstComponent (const NewtonCollision* compoundBreakable);
NewtonbreakableComponentMesh* NewtonBreakableGetNextComponent (const NewtonbreakableComponentMesh* component);
void NewtonBreakableBeginDelete (const NewtonCollision* compoundBreakable);
NewtonBody* NewtonBreakableCreateDebrieBody (const NewtonCollision* compoundBreakable, const NewtonbreakableComponentMesh* component);
void NewtonBreakableDeleteComponent (const NewtonCollision* compoundBreakable, const NewtonbreakableComponentMesh* component);
void NewtonBreakableEndDelete (const NewtonCollision* compoundBreakable);

basically it combine a NetwonMesh with a compound collision, and let you detache teh pice you want to detach at run time, in a very efficent way.
There si a demo in SDK samples of hwo it is used.

It is no teh simpler but I will try to make it mode data driven.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest