Splitted world

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Splitted world

Postby murtaught » Mon Mar 08, 2010 3:53 pm

Hi all!

I'm actually working on a demonstration for my job. We work with large outdoor environnements, and we actually search a good physic engine for the implementations tests.
The rendering engine is ok, and we work with "quadtrees" (it's a method between the basic quadtree and the octree).

My goial is to create "triangles soup" enclosed in a AABB, each AABB reflect a final leaf of the quadtree, and each AABB is an trigger volume. Each time a collision occur in the defined AABB, i've to load from the hdd, if not present in memory, the associated collision geometry of this AABB, and set it in newton (I can't load the whole geometry in one time)

I've few questions :
- The described process is possible, with newton?

If yes:
- I've found the NewtonCollisionSetAsTriggerVolume function, but how i can set up the collision geometry before the tests? I've to use NewtonContactBegin, chek if the contact is a trigger, load the geometry if needed, and setting it in newton?

Thanks you for your help.

PS : I'm Belgian, excuse me for my poor english...
murtaught
 
Posts: 3
Joined: Mon Mar 08, 2010 3:25 pm

Re: Splitted world

Postby JernejL » Mon Mar 08, 2010 7:32 pm

Newton supports a "user mesh" collision object. In essence, it is a custom tri-shape defined by your own implementation that interacts with newton.

User mesh can be implemented in your own engine in such way, that you only load and handle what is needed - newton will tell you where the collisions are being checked, and you return it the data on what is there from your own structures.
That can also involve streaming of data when needed or when the world /levels are in a particular file format, for example user meshes work great with bsp treses or custom infinitely detailed terrains.

See: NewtonCreateUserMeshCollision

Please note that it might be more efficient to build those aabb leafs in newton and just serialize them to binary data. You should do a test and see what works more efficiently.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Splitted world

Postby murtaught » Tue Mar 09, 2010 9:12 am

Ok, thanks. I will try with a user mesh object.

I suppose that we can manager the destrcution of all the NewtonUserMeshCollisionCollideDesc created in the NewtonUserMeshCollisionCollideCallback functions, and maybe don't delete them if we plan to reuse it in the future? In this way, i can manage entierely the construction/destruction of the meshes, and anticipate the loading of the collisions objects. I suppose that i've to use the NewtonUserMeshCollisionDestroyCallback function, but i can't have access to the definition in the Wiki. Where i can find documentation about that?

Thx a lot!
murtaught
 
Posts: 3
Joined: Mon Mar 08, 2010 3:25 pm

Re: Splitted world

Postby Julio Jerez » Tue Mar 09, 2010 9:38 am

The user height field and the Plane collision are two examples of user mesh static collision in the SDK.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Splitted world

Postby JernejL » Tue Mar 09, 2010 10:10 am

murtaught wrote:Ok, thanks. I will try with a user mesh object.

I suppose that we can manager the destrcution of all the NewtonUserMeshCollisionCollideDesc created in the NewtonUserMeshCollisionCollideCallback functions, and maybe don't delete them if we plan to reuse it in the future? In this way, i can manage entierely the construction/destruction of the meshes, and anticipate the loading of the collisions objects. I suppose that i've to use the NewtonUserMeshCollisionDestroyCallback function, but i can't have access to the definition in the Wiki. Where i can find documentation about that?

Thx a lot!


Some functions / callbacks are not completely documented on wiki yet, this includes some callbacks including NewtonUserMeshCollisionDestroyCallback - it is still a blank page.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Splitted world

Postby Julio Jerez » Tue Mar 09, 2010 10:31 am

a destruction callback idea is very simple, Here is the plane collision class,

Code: Select all
class PlaneCollision
{
   public:
   PlaneCollision(NewtonWorld* nWorld, const dVector& plane);
~PlaneCollision(void);

   static void PlaneCollisionDestroyCallback(void* userData)
   static void PlaneCollisionCollideCallback (NewtonUserMeshCollisionCollideDesc* collideDesc);
   static dFloat PlaneMeshCollisionRayHitCallback (NewtonUserMeshCollisionRayHitDesc* rayDesc);

   static void PlaneCollisionGetCollisionInfo (void* userData, NewtonCollisionInfoRecord* infoRecord);

   static int PlaneCollisionGetFacesInAABB (
      void* me,
      const dFloat* p0,
      const dFloat* p1,
      const dFloat** vertexArray,
      int* vertexCount,
      int* vertexStrideInBytes,
      const int* indexList,
      int maxIndexCount,
      const int* userDataList);

   dVector m_sphape[4];
   dVector m_plane;

   dMatrix m_rotation;
   NewtonCollision* m_collision;

   dInt32 m_attribute[MAX_THREAD_FACES];
   dInt32 m_faceIndices[MAX_THREAD_FACES];
   dInt32 m_indexArray[MAX_THREAD_FACES][4];
   dVector m_collisionVertex[MAX_THREAD_FACES][4];
};

As you can see if have a few callback defined as static funtions, these funtion are bouned to teh object via teh user data pointer.
The shape itsel is and allocated objects. as you can see in teh create funtion

Code: Select all
NewtonCollision* CreatePlaneCollidion (NewtonWorld* nWorld, const dVector& Plane)
{
   PlaneCollision* plane;

   plane = new PlaneCollision (nWorld, Plane);
   return plane->m_collision;
}

Then when the last body using this shape is destroyed,
Newton will call the destrotroct call back to give the application the chance to destroyed any alloctaed data the the shape used for local operation. As you can see here.

Code: Select all
   static void PlaneCollisionDestroyCallback(void* userData)
   {
      PlaneCollision* me;
      me = (PlaneCollision*) userData;
      delete me;
   }
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Splitted world

Postby murtaught » Wed Apr 21, 2010 2:16 pm

Thanks a lot.

I've downloaded the 2.0 version, what's the last parameter of NewtonCreateUserMeshCollision (Shapeid)? What's the usage and the utility?
murtaught
 
Posts: 3
Joined: Mon Mar 08, 2010 3:25 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests