Which Physics engine

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Christi258
Posts: 62
Joined: Wed Feb 06, 2013 12:11 pm

Which Physics engine

Post by Christi258 »

Hi all,
can you say me, which physic engine is the best to use, including the aspects of difficulty of implementation, speed, tutorials and so on.
What are you're favourites?
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Which Physics engine

Post by kklouzal »

http://bulletphysics.org/wordpress/ Seems to me like it is the most feature rich :)
Dream Big Or Go Home.
Help Me Help You.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Which Physics engine

Post by Seven »

I prefer PhysX 2.81 myself. (3.0 has some issues with the terrain that I never worked out)

I have used PhysX, Bullet and ODE in my app and always return to PhysX, but in the end, it is all personal preference i think.
Also, PhysX allows me to offload the work form the cpu if a GeForce card is available.
XenoZergNid
Posts: 17
Joined: Sun Oct 13, 2013 1:52 am

Re: Which Physics engine

Post by XenoZergNid »

well, I don't know much about it but if the game mechanics are 2d, then box2d should work.
If the mechanics are 3d then... ok I don't know. All I know about 3d ones is that physX is optimized towards nvidia graphics cards and bullet physics are generally used for movies instead of video games.
Christi258
Posts: 62
Joined: Wed Feb 06, 2013 12:11 pm

Re: Which Physics engine

Post by Christi258 »

Is there an engine which can handle collisions with bones and joints (if something hits a person)?
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Re: Which Physics engine

Post by ikam »

If I remember well, physx can handle joint collisions.
luthyr
Posts: 69
Joined: Wed Dec 30, 2009 5:47 pm

Re: Which Physics engine

Post by luthyr »

We are using PhysX 3.2.4 with Octodad and it does pretty well. PhysX 3+ seems to perform well on any CPU, though can accelerate some things like particle effects on NVIDIA cards. There's quite a lot of setup involved to get complex behavior, though.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Which Physics engine

Post by Seven »

luthyr,
Could you post the terrain physX code for us? I would prefer to use the 3.## series, but cannot get that to work.

You have no idea how much we would appreciate it!
Christi258
Posts: 62
Joined: Wed Feb 06, 2013 12:11 pm

Re: Which Physics engine

Post by Christi258 »

Did I understand wright, if I say that PhysX does not only works with nvidia graphics cards?

Edit: And where can i download the SDK, do you know any usefull tutorials
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Which Physics engine

Post by Seven »

search PhysX SDK, sign up, download and begin using.

PhysX works without geforce card yes.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Which Physics engine

Post by Nadro »

Christi258 wrote:Is there an engine which can handle collisions with bones and joints (if something hits a person)?
Bullet has support for it. I use this engine in all my private projects and it works great.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
luthyr
Posts: 69
Joined: Wed Dec 30, 2009 5:47 pm

Re: Which Physics engine

Post by luthyr »

Seven wrote:luthyr,
Could you post the terrain physX code for us? I would prefer to use the 3.## series, but cannot get that to work.

You have no idea how much we would appreciate it!
Sorry, we aren't using terrain in our game. :(

This is what we use for our mesh code, though:

Code: Select all

 
// -----------------------------------------------------------------------
PxTriangleMesh* PhysicsFactory::createTriangleMesh(
   scene::IMeshBuffer* meshBuffer, 
   const core::vector3df& scale)
{
   if (!m_sdk) return 0;
 
   if (!meshBuffer) return NULL;
 
   PxTriangleMesh* triMesh = NULL;
 
   PxVec3* verts = new PxVec3[meshBuffer->getVertexCount()];
   switch (meshBuffer->getVertexType()) 
   {
   case video::EVT_STANDARD: {
      video::S3DVertex* vertices = (video::S3DVertex*)meshBuffer->getVertices();
      for (u32 i = 0 ; i < meshBuffer->getVertexCount() ; ++i) 
         verts[i] = PxVec3(
            vertices[i].Pos.X * scale.X, 
            vertices[i].Pos.Y * scale.Y, 
            vertices[i].Pos.Z * scale.Z);
      break;
                             }
   case video::EVT_2TCOORDS: {
      video::S3DVertex2TCoords* vertices = 
         (video::S3DVertex2TCoords*)meshBuffer->getVertices();
      for (u32 i = 0 ; i < meshBuffer->getVertexCount() ; ++i) 
         verts[i] = PxVec3(
            vertices[i].Pos.X * scale.X, 
            vertices[i].Pos.Y * scale.Y, 
            vertices[i].Pos.Z * scale.Z);
      break;
                             }
   case video::EVT_TANGENTS: {
      video::S3DVertexTangents* vertices = 
         (video::S3DVertexTangents*)meshBuffer->getVertices();
      for (u32 i = 0 ; i < meshBuffer->getVertexCount() ; ++i) 
         verts[i] = PxVec3(
            vertices[i].Pos.X * scale.X, 
            vertices[i].Pos.Y * scale.Y, 
            vertices[i].Pos.Z * scale.Z);
      break;
                             }
   }
 
   // Build the triangle mesh.
   PxTriangleMeshDesc meshDesc;
   meshDesc.points.count               = meshBuffer->getVertexCount();
   meshDesc.triangles.count            = meshBuffer->getIndexCount() / 3;
   meshDesc.points.stride              = sizeof(PxVec3);
   meshDesc.triangles.stride           = 3*sizeof(u16);
   meshDesc.points.data                     = verts;
   meshDesc.triangles.data             = meshBuffer->getIndices();
   meshDesc.flags                      = PxMeshFlag::e16_BIT_INDICES;
 
   PxDefaultMemoryOutputStream out;
   if (m_cooking->cookTriangleMesh(meshDesc, out)) 
   {
      //Create the mesh from the cooked data.
      PxDefaultMemoryInputData in(out.getData(), out.getSize());
      triMesh = m_sdk->createTriangleMesh(in);
      //m_cooking->release();
   } 
   else 
      printf("Failed triangle mesh cooking\n");
 
   zaparr(verts);
 
   if (!triMesh) {
      printf("Failed to create triangle mesh\n");
      return NULL;
   }
 
   return  triMesh;
}
 
// -----------------------------------------------------------------------
PxRigidActor* PhysicsFactory::createMesh(
   PxTransform transform,
   IAnimatedMesh* colMesh, 
   vector3df scale, 
   float mass,
   float restitution,
   float friction,
   bool isStatic)
{
   if (!m_sdk) return 0;
   if (!colMesh) return 0;
 
   const float HEIGHT = 20.0f; // meters high above the plane
   const PxVec3 POSITION = PxVec3(0.0f, HEIGHT, 0.0f);
 
   PxRigidActor* actor;
 
   if (isStatic)
      actor = m_sdk->createRigidStatic(transform);
   else
      actor = m_sdk->createRigidDynamic(transform);
 
   PxTriangleMesh* triMesh;
   PxMaterial* material = createMaterial(friction, friction, restitution);
   for (unsigned int i = 0; i < colMesh->getMeshBufferCount(); i++)
   {
      triMesh = createTriangleMesh(
         colMesh->getMeshBuffer(i), scale);
      actor->createShape(PxTriangleMeshGeometry(triMesh), *material);
      triMesh->release();
   }
   if (!isStatic)
   {
      PxRigidBodyExt::setMassAndUpdateInertia(*((PxRigidDynamic*)actor), mass);
   }
   addToScene(actor);
 
   return actor;
}
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Which Physics engine

Post by Seven »

Thanks! it seems that I should post out physX code somewhere. It isnt great code, but it seems to work for us.... hmmm.. maybe tonight.
Christi258
Posts: 62
Joined: Wed Feb 06, 2013 12:11 pm

Re: Which Physics engine

Post by Christi258 »

Nadro wrote:Bullet has support for it. I use this engine in all my private projects and it works great.
Well at least I decided to work with bullet.
Can you say me, how to get started?
Do you use coincidentally Visual Studio 2012?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Which Physics engine

Post by Nadro »

You can use build/vs2010.bat for generate VS2010 projects. Those projects you can import in VS2012 without any problems.

For some basic infos about Bullet you should check Bullet_User_Manual.pdf included in Bullet archive. You can find some nice tips also on Bullet wiki: http://bulletphysics.org/mediawiki-1.5. ... /Main_Page
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Post Reply