Destructible geometry

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Destructible geometry

Postby MrDan » Mon Jul 29, 2013 11:53 pm

Does Newton support destructible geometry?
MrDan
 
Posts: 2
Joined: Mon Jul 29, 2013 11:41 pm

Re: Destructible geometry

Postby Julio Jerez » Tue Jul 30, 2013 12:26 am

what kind of destructible geometry?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Destructible geometry

Postby MrDan » Sun Aug 04, 2013 2:28 pm

something similar to havok destruction. suppose you have a convex mesh and having applied a certain amount of force to a point on that mesh it would break into several fragments. that sort of destructible geometry.
MrDan
 
Posts: 2
Joined: Mon Jul 29, 2013 11:41 pm

Re: Destructible geometry

Postby FSA » Sun Aug 04, 2013 2:30 pm

Yes that would be a nice feature!
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: Destructible geometry

Postby Julio Jerez » Sun Aug 04, 2013 3:04 pm

Newton support that alreadysince version 2.0, for a long time.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Destructible geometry

Postby FSA » Sun Aug 04, 2013 3:41 pm

Could you make a sample of that? That would be very nice!
In the newton header CoumpoundBreakable things are commented.
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: Destructible geometry

Postby Julio Jerez » Mon Aug 19, 2013 10:24 am

Ok now I completed the simple destruction demo, please try it out.

now this week I will make the complete building destruction, an if I have time maybe add some special fractures pattern like wood splinter, Glass, plane slicing, and rock crack
I will also see if I can add a layered destruction like the plaster of walls and tuff like that.

now I think it is time again to go revisit the authoring tool Archemedia,
the engine now has so many features that it really require an authoring tool

are they any public domain authoring tool there that we can integrate plugins?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Destructible geometry

Postby FSA » Mon Aug 19, 2013 3:34 pm

Now I've looked intensive to the demo. Am I right that I can get all the data from a newton mesh (for rendering with my system) with the function
NewtonMeshGetVertexStreams?
Documentation about that function? Or short sample code?
And how can I get every piece of the broken model before updating the physic system and just get matrices to render the segments?
Or is there a bestter solution to handle destruction without using NewtonMesh for rendering? The solution must support uv coordinates from my Model.
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: Destructible geometry

Postby Julio Jerez » Mon Aug 19, 2013 3:43 pm

you need to use NetwonMesh to build the model. you nee to inetgrate newton mesh to you edidtor.
newto mesh is very very powerful tool. and it sodu support all of teh complexity of you modeler upto two set of UV per vertex.

if you look at function ..\demosSandbox\sdkDemos\demos\SimpleConvexFracturing.cpp
FractureEffect(NewtonWorld* const world, NewtonMesh* const mesh, int interiorMaterial)


afte teh peices are creatde tsi code let yo uget thet pices form the mesh


Code: Select all
      // now we call create we decompose the mesh into several convex pieces
      NewtonMesh* const debriMeshPieces = NewtonMeshCreateVoronoiConvexDecomposition (m_world, count, &points[0].m_x, sizeof (dVector), interiorMaterial, &textureMatrix[0][0]);
      dAssert (debriMeshPieces);
      
      // now we iterate over each pieces and for each one we create a visual entity and a rigid body
      NewtonMesh* nextDebri;
      for (NewtonMesh* debri = NewtonMeshCreateFirstLayer (debriMeshPieces); debri; debri = nextDebri) {
         // get next segment piece
         nextDebri = NewtonMeshCreateNextLayer (debriMeshPieces, debri);
         
         //clip the voronoi convexes against the mesh
         NewtonMesh* const fracturePiece = NewtonMeshConvexMeshIntersection (mesh, debri);
         if (fracturePiece) {
            // make a convex hull collision shape
            NewtonCollision* const collision = NewtonCreateConvexHullFromMesh (m_world, fracturePiece, 0.0f, 0);
            if (collision) {
               // we have a piece which has a convex collision  representation, add that to the list
               FractureAtom& atom = Append()->GetInfo();
               atom.m_mesh = new DemoMesh(fracturePiece);
               atom.m_collision = collision;
               NewtonConvexCollisionCalculateInertialMatrix (atom.m_collision, &atom.m_momentOfInirtia[0], &atom.m_centerOfMass[0]);   
               dFloat debriVolume = NewtonConvexCollisionCalculateVolume (atom.m_collision);
               atom.m_massFraction = debriVolume / volume;
            }
            NewtonMeshDestroy(fracturePiece);
         }

         NewtonMeshDestroy(debri);
      }

      NewtonMeshDestroy(debriMeshPieces);



then to extract the data from a NetwonMesh you can check this function


Code: Select all
DemoMesh::DemoMesh(NewtonMesh* const mesh)
   :dClassInfo()
   ,m_uv(NULL)
   ,m_vertex(NULL)
   ,m_normal(NULL)
   ,m_optilizedDiplayList(0)      
{
   // extract vertex data  from the newton mesh      
   AllocVertexData(NewtonMeshGetPointCount (mesh));
   NewtonMeshGetVertexStreams (mesh, 3 * sizeof (dFloat), (dFloat*) m_vertex, 3 * sizeof (dFloat), (dFloat*) m_normal,   2 * sizeof (dFloat), (dFloat*) m_uv, 2 * sizeof (dFloat), (dFloat*) m_uv);

   // extract the materials index array for mesh
   void* const meshCookie = NewtonMeshBeginHandle (mesh);
   for (int handle = NewtonMeshFirstMaterial (mesh, meshCookie); handle != -1; handle = NewtonMeshNextMaterial (mesh, meshCookie, handle)) {
      int textureId = NewtonMeshMaterialGetMaterial (mesh, meshCookie, handle);
      int indexCount = NewtonMeshMaterialGetIndexCount (mesh, meshCookie, handle);
      DemoSubMesh* const segment = AddSubMesh();

      segment->m_shiness = 1.0f;
      segment->m_ambient = dVector (0.8f, 0.8f, 0.8f, 1.0f);
      segment->m_diffuse = dVector (0.8f, 0.8f, 0.8f, 1.0f);
      segment->m_specular = dVector (0.0f, 0.0f, 0.0f, 1.0f);

      segment->m_textureHandle = textureId;

      segment->AllocIndexData (indexCount);
      // for 16 bit indices meshes
      //NewtonMeshMaterialGetIndexStreamShort (mesh, meshCookie, handle, (short int*)segment->m_indexes);

      // for 32 bit indices mesh
      NewtonMeshMaterialGetIndexStream (mesh, meshCookie, handle, (int*)segment->m_indexes);
   }
   NewtonMeshEndHandle (mesh, meshCookie);

   // see if this mesh can be optimized
   OptimizeForRender ();
}
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Destructible geometry

Postby FSA » Mon Aug 19, 2013 3:54 pm

OK tank you. I think it'll take a while to test it out.
But how can I set my own texture coordinates to newtonMesh external material?
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: Destructible geometry

Postby Julio Jerez » Mon Aug 19, 2013 4:46 pm

I asume you mesh is soem kind of vertex list index list
take a look at demo ..\applications\demosSandbox\sdkDemos\demos\UsingNewtonMeshTool.cpp
it buidl a cube with dirent UV, and different material face

if your mesh is a simep veret array, then take a look at function
..\applications\demosSandbox\sdkDemos\DemoMesh.cpp
NewtonMesh* DemoMesh::CreateNewtonMesh(NewtonWorld* const world)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Destructible geometry

Postby FSA » Tue Aug 20, 2013 8:06 am

What is the reason to use two texture coordinate channels?
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: Destructible geometry

Postby Julio Jerez » Tue Aug 20, 2013 9:05 am

because some time an object maybe have more than one texture with different mapping coordinates, for example say you want to make a plain object and you wan to apply a tiling alpha mask.
the alpha mask may tile, while the object base texture may not. In cases a secund UV channel come handy.
you can set the secund UV channel to zeros.

This is why I mention before that the Newton Mesh is very flexible and should support almost all of the information that any Game engine is using to describe meshes.
The mesh has lots of functionality.
In the future I will change the NewtonMesh you use Channel and Semantic vertex description, but for now a flat verted is OK
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron