Newton 2.0x Archemedia Open Beta

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Newton 2.0x Archemedia Open Beta

Postby shybovycha » Fri Oct 23, 2009 2:20 pm

Well, good luck, then! =)
Image
User avatar
shybovycha
 
Posts: 52
Joined: Fri Oct 23, 2009 6:15 am
Location: Poland

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Sun Oct 25, 2009 12:53 pm

Here is a small video of the new Paaaawaaaa the will come in like these week
http://www.newtondynamics.com/downloads/LevelDestruction.wmv
It is still work in progress, but the majority of the hard work is already done, Now what it is need it is to issue the remove pierces as small and large debriis, but we are close to a final demo for 2.11
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby aqnuep » Sun Oct 25, 2009 1:21 pm

AWESOME!!!
As I see there will be way to dynamically remove parts of the geometry. I suppose Newton will provide us a callback to handle the removed parts so they can fly out from the destruction. That will provide loads of possibilities.

Wondering if there would be possibility e.g. if all the pillars are broken then issue some kind of collapsing of the whole building. Of course, this will be probably up to the application.

Another thing that comes to my mind is that maybe this feature can be used also for creating deforming objects like dips on metallic surfaces or stuff like that.
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Sun Oct 25, 2009 2:07 pm

aqnuep wrote:AWESOME!!!
As I see there will be way to dynamically remove parts of the geometry. I suppose Newton will provide us a callback to handle the removed parts so they can fly out from the destruction. That will provide loads of possibilities.

That’s the idea, the call back will tell you when a body hit the destructible structure.
Then the breakable structure have an interface will all king of function.
The function you ask in the split structure. This function you pass the pointer to the breakable shape and a pointer to a half space structure, and the function separate everything fully inside the half space as anther new breakable structure, plus you it will copy all the pieces interaction the half space boundary into and array of loose shapes,
Then application can emit each loose piece as a debris, the new Breakable if any was found as a New dynamics or static breakable.
This is just one of the interfaces, and it is the one I am working now, but the are other, for example a small bullet hit can ship out a small debrief, for that you can call for all pieces intersection a small spherical volume, and the is the function I am using in the video, but I am not emitting the small pieces as debris. There is also get all lose pieces which is still pending but I am working on it.

Imagine a big Building with solid wall made out bricks, and many othe materials, shown with a artillery charge and is bolo a hole, better yet the wall is sick and it only carve a hole the to do go all the way, and you shoot another bullet and to make the hole bigger.

aqnuep wrote:AWESOME!!!
Wondering if there would be possibility e.g. if all the pillars are broken then issue some kind of collapsing of the whole building. Of course, this will be probably up to the application.

Yes of course, that is the function that will give you the lose pieces after any modification.
The functionality is in, but I have no written the Newton Interface.
But yes you can break a pillar in the top, The you can weaken the base and when the base break the rest of the pillar will fall as one solid Breakable pieces than may or may not break as if hit the ground.
Imagine the fallen pillar falling down a hill, breaking into smaller pieces as it tables downhill.

aqnuep wrote:AWESOME!!!
Another thing that comes to my mind is that maybe this feature can be used also for creating deforming objects like dips on metallic surfaces or stuff like that.

You are think the same was I am, the other day I made the same comment as I realize that one this feature is complete, it is the foundation for any FEA solver. And I am planning to use it as such for local plastic deformations and soft bode lattices.
I am glad you too see that angle.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby aqnuep » Sun Oct 25, 2009 4:09 pm

Cooooooool!

Now I'm sure that this feature can be the foundation of some real next generation physics effects.
From what you've said about the interface that will be provided I think this could be used not just for the mentioned effects but also loads of other possibilities as well. I have already some ideas... :twisted:
Now I can start how to streamline this with my graphic pipeline :D

Off-topic: I still not received response to my PM.
aqnuep
 
Posts: 97
Joined: Sat Dec 22, 2007 4:14 pm

Re: Newton 2.0x Archemedia Open Beta

Postby Carli » Mon Oct 26, 2009 4:04 am

I've got a question:

In my old gwX Engine there was a voxel system to simulate dynamic landscape destruction: http://www.youtube.com/watch?v=4NYQ8snYQ1Y

The 2nd Version of the Engine is using Newton Game Dynamics - I think it would be more realistic to use a mesh-based destruction system - but it was very slow....

Is there a possibility to make a destructable huge landscape with Newton Game Dynamics in Realtime? (with fixed 40 FPS)
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Mon Oct 26, 2009 6:46 am

Carli wrote:Is there a possibility to make a destructable huge landscape with Newton Game Dynamics in Realtime? (with fixed 40 FPS)

That's the idea, that level there has 6970 parts.
In fact tha number of pieces do no affect the preformance, it only affect memory.
In the future it will supports instances in teh same shape, for example the columns an dteh steps can be instaces. righ now it does no support that at the componets level
I does support instancing at the the shape level, you can make the columns separate, and the place as many as you want, by placing separate rigid bodies,
so instead teh building be one body, it can be a seriues of bodies.

However after I finish thr frst pass I will try adding the instancing for version 2.12


Carli wrote:Is there a possibility to make a destructable huge landscape with Newton Game Dynamics in Realtime? (with fixed 40 FPS)

How do you make you terrain? It is 2d highmap?
the voxel think is not bad. I experimented with it before going with precalculated solid polygonal pieces.
The problem with Voxel is that you can not get away from the Blooby looks, which is OK for stylized games but not for more natural looks,
polygonal meshes it is easier to get a natural look, but it you can not generate the meshes in real time, it is too expensive.
Anything other than simple cuts like in the first destrution demo in 2.10 is juts too time consumimg for real time.

However the precalculated cut lead to amost raalime destrution as you can see in the demos. and teh cut can be gided to look in many diffrent ways.
you can have Glass, Concrete, Dirt, Regular Paterns, etc.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby Marc » Mon Oct 26, 2009 11:57 am

Wow, that 's cool!

That reminds me of this old shooter red faction that had destructible maps - even though the things that could be destroyed were predefined and maybe scripted: Image
Would be cool to see a shooter use that functionality to do it right :)

From the technical point of view: Is this destructible mesh a treecollision? Or something else? Does it work for static geometry only?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Mon Oct 26, 2009 3:08 pm

It is a compoound collision of solids.
It is the kind of meshes that engine like quake, and Half liff use, but way more flexible since with Newton they brushs do not have to be convex.
The only condition is that the Pieces have to be closed. But you can add as many as you want.
The mesh can be static or dynamics, and the broken part can be simple convex or other complexBreakable compound.
The broken pieces can be dynamics or static, for example you can have a bridge the you break the center, then the part of one size is fix,
the part on the other side is also fixed, bu the part in the midle collapes to teh groudn if it doe no hla any conetion to any of the other to parts.
you can make a buidlings in wich teh Glass Panel brake in different paternm that teh congret walls, or teh roof
Yoy can also can make statues, Glass Vessel or Boses that can brake with different patterns when the fall,
It is the full package.


Later I will add modification to handle open meshed, but for now this first implementation is sufficient to release Beta 2.11
I wish I have more time to spend on this, but unfortunately I have to go to my 8 to 5 regular job on week days. :cry:

you can make entire buildings or world using it. You can also make buiding blocks for constructions,
for example you can make walls and place then in a building, that way you can have the no destructible parts be collision tree and every thing destrutible be modular compound.
It is very flexible, plus you also get the set of Booleans that you can use to modify mesh in a level editor.
Those are teh new feature that Newton 2.0 i bringing in to the table.

I hope people like them.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby Marc » Tue Oct 27, 2009 1:15 pm

Do I have to define the parts into which a geometry can break myself or does newton split it by itself on demand?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Tue Oct 27, 2009 2:43 pm

Newton split it by itself in a preprosses stage and is put it into a database. You get a call back with the information nessesary to defien teh cuts.
Depending how small you make the cuts, that how close the close is to the actual impact.

there you can set the cut pattern, Newton cut the visual mesh and make the collision shapes.
Then it provides all the information so that the graphics engine build the graphics mesh for one Vertex Buffer.

I do not like to post WIP work, but I guess tha later I can post part of the set up code.

The set up is made so the it can be use as a simpel call, but it sll designed to ne integrated into a Level Editor, or Graphics Package liek Maya for interatiove setup.
people how can do that can get the Best set up bacause they can post edit the Meshes after the Build prosses.
As you know, pretty graphics go a long way to make a nice presemnsation.
if at this ealy stage with just one Materail this looks this good, Imagine what an artist can do with many material in an interative enviroment.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby Auradrummer » Tue Oct 27, 2009 10:27 pm

Hey Master!!!

As I see, no problem to make a breakable car, right? :D IS just what I'm needing!!!
Developing a racing game.
Auradrummer
 
Posts: 132
Joined: Sat May 17, 2008 9:17 am

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Wed Oct 28, 2009 10:10 am

Marc wrote:Do I have to define the parts into which a geometry can break myself or does newton split it by itself on demand?


thsi is a sampel code of how to set it up for a presaved mesh

Code: Select all
static void LoadSolidBuilding (SceneManager& system, NewtonBody* landScapeBody)
{
   int vertexCount;
   int texCount;
   FILE* file;
   int matrialMap[256];
   NewtonBody* body;
   NewtonWorld* world;
   NewtonCollision* compound;
   ShareVertexMesh* meshInstance;
   NewtonbreakableComponentMesh* meshData;


   world = system.m_world;

   // open the level data
   file = OpenFileAsset(system, "SolidRuins.mdl", landScapeBody);
   // read the textures;

   memset (matrialMap, 0, sizeof (matrialMap));
   DeSerializeFile (file, &texCount, sizeof (int));
   for (int i = 0; i < texCount; i ++) {
      int id;
      char buffer[64];
      DeSerializeFile (file, &id, sizeof (int));
      DeSerializeFile (file, &buffer, sizeof (buffer));
      matrialMap[id] = LoadTexture(buffer);
   }

   compound = NewtonCreateCollisionFromSerialization (system.m_world, DeSerializeFile, file);
   fclose (file);

   // tell the engine which pieces of this compound are touching this static body and
   // this call is only need it for compound how are static bodies
   dMatrix fixMatrix;
   NewtonCollision* fixCollision[1];
   NewtonBodyGetMatrix(landScapeBody, &fixMatrix[0][0]);
   fixCollision[0] = NewtonBodyGetCollision(landScapeBody);

   NewtonCompoundBreakableResetAnchoredPieces (compound);
   NewtonCompoundBreakableSetAnchoredPieces (compound, 1, &fixMatrix[0][0], fixCollision);

//   NewtonCollisionInfoRecord collisionInfo;
//   NewtonCollisionGetInfo (compound, &collisionInfo);


   // create a visual Mesh for the Compound Breakable
   vertexCount = NewtonCompoundBreakableGetVertexCount (compound);

   g_vertex = (dFloat*) malloc (3 * vertexCount * sizeof (dFloat));
   g_normal = (dFloat*) malloc (3 * vertexCount * sizeof (dFloat));
   g_uv = (dFloat*) malloc (2 * vertexCount * sizeof (dFloat));
   NewtonCompoundBreakableGetVertexStreams (compound, 3 * sizeof (dFloat), g_vertex, 3 * sizeof (dFloat), g_normal, 2 * sizeof (dFloat), g_uv);


   meshData = NewtonBreakableGetMainMesh (compound);
   meshInstance = new ShareVertexMesh (vertexCount, g_vertex, g_normal, g_uv);
   for (void* segment = NewtonBreakableGetFirstSegment(meshData); segment; segment = NewtonBreakableGetNextSegment ( segment)) {
      int material;
      int indexCount;
      dSubMesh* subMesh;

      subMesh = meshInstance->AddSubMesh();

      material = NewtonBreakableSegmentGetMaterial (segment);
      indexCount = NewtonBreakableSegmentGetIndexCount (segment);

      subMesh->m_textureHandle = (GLuint)matrialMap[material];

      subMesh->AllocIndexData (indexCount);
//      subMesh->m_indexCount = NewtonBreakableSegmentGetIndexStreamShort (compound, meshData, segment, (short int*)subMesh->m_indexes);
      subMesh->m_indexCount = NewtonBreakableSegmentGetIndexStream (compound, meshData, segment, (int*)subMesh->m_indexes);
   }


   dMatrix matrix (GetIdentityMatrix());
   RenderPrimitive* primitive;
   primitive = new RenderPrimitive (matrix, meshInstance);
   system.AddModel(primitive);

   meshInstance->Release();

   // create the rigid body
   body = NewtonCreateBody(world, compound);

   // Release the collision
   NewtonReleaseCollision(world, compound);

   //m_matrix = dPitchMatrix (15.0f* 3.141592f / 180.0f);
//   dMatrix matrix (GetIdentityMatrix());

   // set the global position of this body
   NewtonBodySetMatrix (body, &matrix[0][0]);

   // save the pointer to the graphic object with the body.
   NewtonBodySetUserData (body, primitive);
}



This is how the to build a new Mesh one

Code: Select all
int ClipSolidCallback (NewtonMesh* const mesh, void* userData, dFloat* pinAndPivotSplitMatrix)
{
   dFloat x;
   dFloat y;
   dFloat z;
   dMatrix splitMatrix;

   // get the OOBB along for this mesh
   NewtonMeshCalculateOOBB (mesh, &splitMatrix[0][0], &x, &y, &z);

   if (x > 0.5f) {
      // if the largest piece is too big, the continue the split process

      // randomize the clip plane position a little
      dVector posit = splitMatrix.m_posit;

      // randomize the plane orientation
      posit += splitMatrix.m_front.Scale (x * RandomVariable(0.5f));
      splitMatrix = splitMatrix * dYawMatrix(3.1416f * RandomVariable(1.0f));
      splitMatrix = splitMatrix * dRollMatrix(3.1416f * RandomVariable(1.0f));

      splitMatrix.m_posit = posit;
      memcpy (pinAndPivotSplitMatrix, &splitMatrix[0][0], sizeof (dMatrix));

      // return different than zero to indicate that the plane is valid and the process should continue spliting
      return 1;
   }

   // return zero to indicate that this pieces should not be split anymore.
   return 0;
}


static FILE* OpenFileAsset(SceneManager& system, const char* name, NewtonBody* landScapeBody)
{
   int shapeCount;
   GLuint tex;
   dFloat width;
   dFloat breadth;
   HANDLE handle;
   char name1[128];
   char fullPathName[2048];
   char fullPathName1[2048];
   int piecesID[512];
   dMatrix pallete[512];
   NewtonMesh *clippers[512];
   NewtonMesh *solidPieces[512];
   dMatrix matrixPallete[512];

   FILE* file;
   OGLModel* model;
   NewtonMesh *meshCliper;
   NewtonCollision* compound;

   strcpy (name1, name);
   strtok (name1, ".");
   strcat (name1, ".bin");
   GetWorkingFileName (name1, fullPathName1);
   GetWorkingFileName (name, fullPathName);

   handle = CreateFileA(fullPathName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
   if (handle != INVALID_HANDLE_VALUE)   {
      FILETIME nameCreationTime;
      GetFileTime(handle, NULL, NULL, &nameCreationTime);
      CloseHandle(handle);

      handle = CreateFileA(fullPathName1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
      if (handle != INVALID_HANDLE_VALUE)   {
         FILETIME nameCreationTime1;
         GetFileTime(handle, NULL, NULL, &nameCreationTime1);
         CloseHandle(handle);
         if (CompareFileTime(&nameCreationTime1, &nameCreationTime) > 0) {
//            return fopen (fullPathName1, "rb");
         }
      }
   }

   // create a Clip Plane for build the derbies pieces
   dMatrix plane (GetIdentityMatrix());
   dMatrix texMatrix (GetIdentityMatrix());

   width = 20.0f;
   breadth = 20.0f;

   tex = LoadTexture ("destructionDetail.tga");
   texMatrix[1][1] = 4.0f /breadth;
   texMatrix[2][2] = 4.0f /breadth;

   // create a clipper plane (only one for all solid, but there may be a different one for different meshes
   meshCliper = NewtonMeshCreatePlane (&plane[0][0], width, breadth, tex, &texMatrix[0][0]);

   // load a model made form solid pieces, each pieces must intersect a nearby piece to make a complex solid large piece
   model = new OGLModel ();
   OGLLoaderContext context;
   model->Load (fullPathName, context);

   // create the matrix pallete that locate each child solid piece, relative to the origin
   model->UpdateMatrixPalette (GetIdentityMatrix(), pallete, sizeof (pallete) / sizeof (dMatrix));

   shapeCount = 0;
   // iterate over the mode and searching for each solid piece of geometry
   for (ModelComponentList<dList<dMesh*> >::dListNode* list = model->m_meshList.GetFirst(); list; list = list->GetNext()) {
      for (dList<dMesh*>::dListNode* node = list->GetInfo().m_data.GetFirst(); node; node = node->GetNext()) {
         OGLMesh* mesh;
         mesh = (OGLMesh*)node->GetInfo();

         // assign a clipped mesh to this solid mesh
         clippers[shapeCount] = meshCliper;

         // each piece can have it own ID, for now make it 0
         piecesID[shapeCount] = 0;

         matrixPallete[shapeCount] = pallete[mesh->m_boneID];

         // convert the solid geometry to a newton mesh
         solidPieces[shapeCount] = mesh->BuildMesh();
         shapeCount ++;
      }
   }

   // we do not need the mode anymore
   delete model;

   // create ad solid destructible
   compound = NewtonCreateCompoundBreakable (system.m_world, shapeCount, &solidPieces[0], &clippers[0], &matrixPallete[0][0][0], &piecesID[0], 0, 0, ClipSolidCallback, NULL);

   // tell the engine which pieces of this compound are touching this static body and
   // this call is only need it for compound how are static bodies
//   NewtonCreateCompoundBreakableSetAncheredPieces (compound, 0, NULL, NULL);


   // destroy the mesh because not need anymore
   NewtonMeshDestroy (meshCliper);
   for (int i = 0; i < shapeCount; i ++) {
      NewtonMeshDestroy(solidPieces[i]);
   }

   // save the collision file
   file = fopen (fullPathName1, "wb");

   // save the Material information Before Serializing the data

   // Iterate over all components finding Material ID
   dTree<const char*,int>textureMap;
   for (NewtonbreakableComponentMesh* component = NewtonBreakableGetFirstComponent (compound); component; component = NewtonBreakableGetNextComponent (component)) {
      for (void* segment = NewtonBreakableGetFirstSegment(component); segment; segment = NewtonBreakableGetNextSegment (segment)) {
         int material;
         const char* textName;

         material = NewtonBreakableSegmentGetMaterial (segment);
         textName = FindTextureById (material);
         if (textName) {
            textureMap.Insert(textName, material);
         }
      }
   }

   // save all the textures
   int texCount;
   texCount = textureMap.GetCount();
   SerializeFile (file, &texCount, sizeof (int));
   dTree<const char*,int>::Iterator iter (textureMap);
   for (iter.Begin(); iter; iter++) {
      int id;
      char buffer[64];
      const char* name;
      const char* fullName;

      id = iter.GetNode()->GetKey();
      fullName = iter.GetNode()->GetInfo();
      name = strrchr (fullName, '/') + 1;
      sprintf (buffer, "%s", name);
      SerializeFile (file, &id, sizeof (int));
      SerializeFile (file, &buffer, sizeof (buffer));
   }

   NewtonCollisionSerialize (system.m_world, compound, SerializeFile, file);
   fclose (file);
   NewtonReleaseCollision (system.m_world, compound);

   return fopen (fullPathName1, "rb");
}



This is the callback when a body hit the mesh

Code: Select all
static void DestroyThisBodyCallback (const NewtonBody* body, const NewtonJoint* contactJoint)
{
   NewtonCollision* collision;
   NewtonCollisionInfoRecord collisionInfo;

   // Get the collision shape for the body and see if this is a compound breakable shape
   collision = NewtonBodyGetCollision(body);
   NewtonCollisionGetInfo (collision, &collisionInfo);
   if (collisionInfo.m_collisionType == SERIALIZE_ID_COMPOUND_BREAKABLE) {
      // this is a compound breakable, finds the part at the contact and create the debris pieces

      dFloat maxSpeed;
      NewtonMaterial* bestMaterail;

      // find the location of the strongest impact
      maxSpeed = 0.0f;
      bestMaterail = NULL;
      for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) {
         dFloat speed;
         NewtonMaterial* material;

         material = NewtonContactGetMaterial (contact);
         speed = dAbs (NewtonMaterialGetContactNormalSpeed(material));
         if (speed > maxSpeed) {
            maxSpeed = speed ;
            bestMaterail = material;
         }
      }

      int debriCount;
      dVector contactPoint;
      dVector contactNormal;
      NewtonbreakableComponentMesh* components[32];
      dMatrix matrix;

      _ASSERTE (bestMaterail);
      NewtonMaterialGetContactPositionAndNormal (bestMaterail, &contactPoint.m_x, &contactNormal.m_x);
      NewtonBodyGetMatrix(body, &matrix[0][0]);

      // Get the origin in the space of the collision mesh
      contactPoint = matrix.UntransformVector(contactPoint);

      // get all the debris pieces on the radios of the impact
      debriCount = NewtonBreakableGetComponentsInRadius (collision, &contactPoint.m_x, 1.0f, components, sizeof (components)/sizeof (components[0]));

      // for each piece add a new body to the scene
      for (int i = 0; i < debriCount; i ++) {
         NewtonbreakableComponentMesh* component;

         // get the information from this component and emit a visual an dphysics debris piece
         component = components[i];
         


         // finally remove this component for the
         NewtonBreakableDeleteComponent (collision, component);
      }


      // now reconstruct the main visual mesh

      // we do no need to allocate the vertex buffer sine the mesh use the same previous buffer
      // we only need to create the sub mesh that had changed
      RenderPrimitive* primitive;
      NewtonbreakableComponentMesh* meshData;

      primitive = (RenderPrimitive*) NewtonBodyGetUserData(body);
      meshData = NewtonBreakableGetMainMesh (collision);
      for (void* segment = NewtonBreakableGetFirstSegment(meshData); segment; segment = NewtonBreakableGetNextSegment ( segment)) {
         int material;
         int indexCount;
         OGLMesh* mesh;
         dSubMesh* subMesh;

         mesh = NULL;
         subMesh = NULL;
         material = NewtonBreakableSegmentGetMaterial (segment);
         indexCount = NewtonBreakableSegmentGetIndexCount (segment);

         // find a mesh and a submesh by this material
         for (ModelComponentList<dList<dMesh*> >::dListNode* list = primitive->m_meshList.GetFirst(); !mesh && list; list = list->GetNext()) {
            for (dList<dMesh*>::dListNode* node = list->GetInfo().m_data.GetFirst(); !mesh && node; node = node->GetNext()) {
               for (dMesh::dListNode* meshSegment = node->GetInfo()->GetFirst(); !mesh && meshSegment; meshSegment = meshSegment->GetNext()) {
                  if (int (meshSegment->GetInfo().m_textureHandle) == material) {
                     mesh = (OGLMesh*) &list->GetInfo().m_data;
                     subMesh = &meshSegment->GetInfo();
                  }
               }
            }
         }

         if (!mesh) {
            _ASSERTE (0);
//            _ASSERTE (mesh);
         }

            // if we did no find this material this is a new segment
         if (!subMesh) {
            subMesh = mesh->AddSubMesh();
            subMesh->m_textureHandle = material;
         }

         // now check if this segment can hold the vertex array;
         if (subMesh->m_indexCount < indexCount) {
            subMesh->AllocIndexData (indexCount);
         }
//         subMesh->m_indexCount = NewtonBreakableSegmentGetIndexStreamShort (collision, meshData, segment, (short int*)subMesh->m_indexes);
         subMesh->m_indexCount = NewtonBreakableSegmentGetIndexStream (collision, meshData, segment, (int*)subMesh->m_indexes);
      }
   }

/*
   PrefFabDebrisDatabase::dTreeNode *debrisPiecesNode;

   // find a the strongest force
   debrisPiecesNode = PrefFabDebrisDatabase::prefabDebrisDatabase.Find(NewtonBodyGetCollision(body));
   if (debrisPiecesNode) {
      dMatrix matrix;
      NewtonWorld* world;
      SceneManager* system;
      NewtonBody* rigidBody;
      dVector veloc;
      dVector omega;


      // Get the world;
      world = NewtonBodyGetWorld (body);
      system = (SceneManager*) NewtonWorldGetUserData(world);

      NewtonBodyGetOmega(body, &omega[0]);
      NewtonBodyGetVelocity(body, &veloc[0]);
      NewtonBodyGetMatrix (body, &matrix[0][0]);

      veloc = veloc.Scale (0.25f);
      omega = omega.Scale (0.25f);

      for (PrefFabDebriList::dListNode* node = debrisPiecesNode->GetInfo().GetFirst(); node; node = node->GetNext()) {
         OGLMesh* meshInstance;
         NewtonCollision* collision;
         RenderPrimitive* primitive;
         PrefFabDebriElement& debriData = node->GetInfo();
      
         // make a visual object
         meshInstance = debriData.m_mesh;

         // create a visual geometry
         primitive = new RenderPrimitive (matrix, meshInstance);

         // save the graphics system
         system->AddModel (primitive);

         collision = debriData.m_shape;

         // calculate the moment of inertia and the relative center of mass of the solid
         //create the rigid body
         rigidBody = NewtonCreateBody (world, collision);

         // set the correct center of gravity for this body
         NewtonBodySetCentreOfMass (rigidBody, &debriData.m_com[0]);

         // set the mass matrix
         NewtonBodySetMassMatrix (rigidBody, debriData.m_mass, debriData.m_Ixx, debriData.m_Iyy, debriData.m_Izz);

         // save the pointer to the graphic object with the body.
         NewtonBodySetUserData (rigidBody, primitive);

         // assign the wood id
         //   NewtonBodySetMaterialGroupID (rigidBody, NewtonBodyGetMaterialGroupID(source));

         // set continue collision mode
         NewtonBodySetContinuousCollisionMode (rigidBody, 1);

         // set a destructor for this rigid body
         NewtonBodySetDestructorCallback (rigidBody, PhysicsBodyDestructor);

         // set the transform call back function
         NewtonBodySetTransformCallback (rigidBody, PhysicsSetTransform);

         // set the force and torque call back function
         NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce);

         // set the matrix for both the rigid body and the graphic body
         NewtonBodySetMatrix (rigidBody, &matrix[0][0]);
         PhysicsSetTransform (rigidBody, &matrix[0][0], 0);

         dVector debriOmega (omega);
         dVector debriVeloc (veloc + omega * matrix.RotateVector(debriData.m_com));

         // for now so that I can see the body
//debriVeloc = dVector (0, 0, 0, 0);
//debriVeloc.Scale (0.25f);
//debriVeloc.Omega
//omega = dVector (0, 0, 0, 0);

         NewtonBodySetOmega(rigidBody, &debriOmega[0]);
         NewtonBodySetVelocity(rigidBody, &debriVeloc[0]);
      }

      RenderPrimitive* srcPrimitive;
      srcPrimitive = (RenderPrimitive*) NewtonBodyGetUserData (body);

      // remove the old visual from graphics world
      delete srcPrimitive;
      system->Remove(srcPrimitive);

      // finally destroy this body;
      NewtonDestroyBody(world, body);
   }
*/
}


Of couse they are still subget to chnages but that is teh general idea of hwo it wull work.
I am hopping to ge teh first demo by elarly saturday, or sunday at most.
if I do not get to a demo that I like I post the SDK anyway beacsue it has few bug fixes a inteface improvements.
But I will do my very best to have a working demo by them.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2.0x Archemedia Open Beta

Postby winstrol » Thu Oct 29, 2009 10:18 am

Julio,

I've just bought iPhone, I have OS 3.0.1, and when I'm trying to run tutorial on it there is 272 errors (on Project>Set Active SDK>Use Base SDK), but when I set there "iPhone device 3.0" there is 1 error:
<com.apple.tools.product-pkg-utility>: error: CFBundleIdentifier 'com.yourcompany.tutorial_102_AddingRigidBodies' contains illegal character '_'

and when I do "Edit target", and there delete "com.yourcompany.${PRODUCT_NAME:identifier}" and write "a"

I have 0 errors but "Failed to upload tutorial_102_AddingRigidBodies.app"

could you please help me with that ?
User avatar
winstrol
 
Posts: 30
Joined: Fri Jul 24, 2009 9:57 pm

Re: Newton 2.0x Archemedia Open Beta

Postby Julio Jerez » Fri Oct 30, 2009 2:14 pm

I belive that question is bets to ask on the Mac Iphone Forum.
I remember having some similar problems and I post there and the sugest removing some character from the name,
but I do not remember exactly hwo I solve, but after reading in their foruns I found the answer.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron