Cad Cam Development

How to integrate 3D Studio with Nvidia PhysX?

I had to write a project that will have some PhysX functionality. At first I wanted to use some 3DS model and animate it using PhysX. After spending some time on googling I realized that there are lots of questions on how to combine 3DS and physx and relatively little anwsers, so I decided to write a about it. This post presents a simple way with an explanation on how to combine 3DS and PhysX. I am covering rigid body only, so in case you want to create clothing or soft body, you have to perform research on your own and It would be good to publish your results as a comment to this post.

First of all, download PhysX plugin for 3DS Max from NVidia website and install it. Then, download some kind of 3DS model that you’re going to play with. See the video below I have recorded for you and try following it to see how do I create a PhysX mesh out of 3DS model.

In order to start I selected the model’s part I want to export to PhysX and clicked PhysX->Rigid Bodies->Select As Dynamic Body from the 3DS menu. Then you’ll have to define the mesh what is the most important part in this tutorial.

There following options you can set while creating a PhysX mesh from 3DS model:

  1. Sphere
  2. Box
  3. Capsule
  4. Convex
  5. Composite
  6. Original
  7. Custom

This options describe the way the PhysX mesh will be generated.  It can be convex (convex hull of your model), sphere (the smallest sphere that covers the model), ellipsoid, custom and combined etc. Personally I advice you to use composite way of creating PhysX mesh with appropriate parameters “split levels” and “max vertices”. See the gallery of screenshots below to see the difference between the options. The blue wireframe is the PhysX mesh that will be exported.

This slideshow requires JavaScript.

You can switch to the mesh view from the properties menu you have available within 3DS . Modify property window and then Modifier List->PhysX RBody. You should have displayed PhysX Rigid body somewhere at the tree list control.  Now you can play with some different options to get known with the PhysX 3DS export plugin.

At the end you should export your mesh so that it would be visible for PhysX. Therefore click PhysX->Export PhysX Scene. You can also try validating the model, but is not necessary. You can choose export format. Personally I highly recommend using plain xml text file, despite the drawbacks of text file describing geometry because the Nvidia PhysX plugin is a little bit buggy and you can have control over the exported content. It seems that the PhysX export plugin has been developed in .NET. The exported file does not exist in invariant .NET culture, this means, if you don’t have English OS (your floating numbers are not ‘.’ separated) you have to convert your system separator to ‘.’. Mine system is Polish and floating separating char is ‘,’ , so I opened it with Notepad++ and exchanged all separators in a file with a dot ‘.’. PhysX reads only ‘.’ separated values, so please do it, because this is a bug from Nvidia and your model won’t be read otherwise. You can test your model in PhysX viewer.

How to use it in your code  and how to create your own PhysX mesh browser in OpenGL?

I have prepared a simple model browser that has been written in C++ and OpenGL. It’s based on Nvidia example – SampleSceneExport. You have to load your previously defined model just the same Nvidia has done it  in theirs example. There are some sample models that you can easily load to PhysX GL scene and download either with sourcecode or executable. The models are: teapot, torus, and penguin that can bee seen in the video above.

You can download source code from here and exectuable from here . The video below presents my PhysX mesh viewer in action.


Trackbacks & Pingbacks


  1. * hazem says:

    great work …

    I’m Hazem and i’m working on my graduation project
    it’s all about computer graphics .. “physx ” 🙂

    I just wonder if you could help 🙂
    and may i have your contact ?

    | Reply Posted 7 years ago
    • * Grzegorz says:

      Well, at the moment I am very busy. I’ll help you only to some extent because it’s your task to complete your thesis but if you had some questions and I could answer them then this will be ok. I’ll write you an email.

      | Reply Posted 7 years ago
      • * hazem says:

        hi Grzegorz 🙂

        remember me … i wish u do 🙂

        anyway… I just have a simple question but it considered critical to me and i wish you can help me

        after loading 3d max object to physx does it collide ?

        I mean if I created a cloth and try to collide it with the model … will there be any changes ?

        it’s so important to me you reply 🙂

        thx anyway

        Regard ..

        Posted 6 years, 11 months ago
  2. * Grzegorz says:

    Hi Hazem,

    Ofcourse, I remember you. If you load objects to physx and setup the correct parameters they you will have collision detection enabled. It’s not difficult. Mine example with multiple penguins on the scene has been built so. The penguins can hit on another and they will be moved accordingly to the result force. You can play with my code. Change for instance the acceleration of each penguin so that they can hit themselves and see what happens. As far as I am concerned the cloth should behave correctly accordingly to physx and model. This means that they will swap around cylinder or body. There are samples on how to do it in PhysX samples. Have you looked down there? If you try to change acceleration as I wrote you, please do not forget, that the penguins are rigid body, and the cloths are not. So the collisions would form different kinds of deformations in rigid body and soft body or cloth. I hope this is the answer. If not, write to me once again.

    Best Greetings,

    | Reply Posted 6 years, 11 months ago
  3. hi…
    i’m just start with Physx…
    I have a question about the mesh…
    how can I create a cylinder in physx?
    since there is no default object as …
    I think I should use a convex mesh …
    I do not know which way the head 😦
    I would like to create a cylinder using two balls and a parallelepiped, but I have no idea comes to do …
    thank you very much

    | Reply Posted 6 years, 10 months ago

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s