Panda PhysX

This last one is a bug, but easy to fix, I even can choose between two ways to fix it. Since this is a rather serious bug I will do a new release next week (around Thuesday or Wednesday).

Of course doPhysics() should not do anything on already destroyed actors, but I am using PhysX active transforms to minimize the number of transforms to update. Updating transforms happens while PhysX simulates the scene, in two different threads. This saves a lot of time, but it means that the active transform list which I get from PhysX is the active transform list from the previous simulation step. This list might contain removed actors.

enn0x

Ah, thanks. I’m waiting with anticipation.

http://enn0x.p3dp.com/libpandaphysx_0.4.3.zip

Mainly a bugfix release, but cloth simulation has been added also (currently only for windows).

  • Adds simulation of clothes (ALPHA stage, API may change in future releases!).
  • setSharpness() has moved from PhysBoxController to PhysController.
  • Fixed a bug in the controller callback implementations.
  • Fixed a bug in the controller creation (actor had NULL pointer as name).
  • Fixed a bug with removing actors.
  • Replaces set/getPythonData with them more flexible set/getPythonTag system.
  • Updated some of the samples.
  • Add some variants of PhysActor.addForce/addTorque.
  • Add methods to set/get linear and angular momentum on PhysActor.

(see included file doc/RELEASE-NOTES.txt)

The included binaries are built for Panda3D-1.5.4.
Many thanks to all who helped finding bugs. :slight_smile:

enn0x

Thanks for the great library. Would you recommend using force fields for modeling buoyancy or is there a better way I’m missing?

To be honest I have been wondering myself how to do buoancy. the tricky part if when only part of a shape is submerged. Then the upward force depends on the submerged fraction of the total volume.

Force field will either apply the full force or none, depending on the center of the shape (I think…). So you will get an constant up-and-down oszilation.

One way would be to split up the total shape in subshapes/actors. Another would be to append a number of points (?) from which you estimate the submerged volume, and then apply buoyancy forces yourself each frame.

PhysX has a feature in preparation which will solve this and other features of fluids: fluid heighfields. So I guess the best is to wait until this feature is released by NVIDIA.

enn0x

Makes sense, guess I’ll put in a placeholder non-physics object for now, thanks for the feedback.

hello.
I wanna try this physic engine,too.
Then I tried your lastest code.
I ran 01_Basic.py(and another.) then I get this error.

Assertion failed: error == NXCE_NO_ERROR at line 230 of c:\users\rpf\desktop\phy
sx\source\physEngine.cxx
Traceback (most recent call last):
  File "01_Basics.py", line 176, in <module>
    world = World( )
  File "01_Basics.py", line 55, in __init__
    base.setBackgroundColor( 0, 0, 0.3, 1 )
  File "C:\Panda3D-1.5.4\direct\src\showbase\ShowBase.py", line 1615, in setBack
groundColor
    color = VBase4(r, g, b, a)
AssertionError: error == NXCE_NO_ERROR at line 230 of c:\users\rpf\desktop\physx
\source\physEngine.cxx

I use Panda3D-1.5.4. , ageia_physx_7.07.24 and NVIDIA PhysX SDK 2.8.0, 2.8.1
Does I miss something?
Help me please.

There has been an error when initializing the PhysX SDK. There are several reasons why this could happen, for example not finding the system software, or two applications trying to grab the same hardware, or a version mismatch.

The error should have been reported on the console, somwhere ABOVE the assert. The output is category “error”, so if you don’t turn off every output manually then you will see it.

By the way: you need the SDK only if you want to compile yourself.

enn0x

Oh!!~
I tried remove SDK and install older version of PhysX.
(PhysX_8.04.25_SystemSoftware.exe )

It 's work well.
Thank you very much enn0x. :wink:

Ok, seems like the installed system software has been to old.

Just to make sure: did you see this line on the console, or has there been another error type?

:physx(debug): Error when setting up the PhysX system: NXCE_WRONG_VERSION

enn0x

Edit | Nevermind, found the SFDisableRaycasting flag to get a raycast to ignore a certain shape…

enn0x, would it be possible for you to add some functions to add forces to a character controller? It would help with part of a project I’m working on, and currently the functions that set force on actors don’t work as the controller is not dynamic.

How can I get the surface normal of the hit surface when doing a raycast?
I’m trying to place a decal on the hit surface. Any ideas how to get the correct angles for the decal?

PhysRaycastHit.getImpactNormal() should work.

@Executor:
BMCha is right, hit.getImpactNormal() should return the surface normal at the impact point. However, it is a “smoothed” normal . So far I don’t support a way to ask for either a smoothed normal or the real face normal. I will put this on my todo list.

@BMCha:
I’m afraid this is not possible, because the actor created by a controller is a kinematic actor. The error messages you see are not from my code but from the PhysX SDK itself. Setting forces on a static or kinematic actor is not allowed. Only dynamic actors can bemoved with forces. To move around a kinematic actor you must use move(). The PhysX SDK documentation has some more explanation on the different actor types. So here is what you can do:

(1) Create a dynamic actor and write you own controller code, for moving it around with forces. It’s hard, especially if you want to have all the features that PhysX controller offer, but possible. Look at the Newton, Ode or Bullet examples for how to implement a controller.

(2) Depending on how complex your forces are you can calculate a velocity change from your forces, and use actor.move() or controller.setLocalSpeed() accordingly.

enn0x

I am trying to create a convexmesh nxb file for an object within a map that I created with 3dmax. Heres the code:

import direct.directbase.DirectStart
from pandac.PandaModules import Filename
from libpandaphysx import PhysKitchen

fname = 'map01'

map=loader.loadModel( 'models/%s.egg' % fname )
np=map.find("*/object")

status=PhysKitchen( ).cookConvexMesh( np, Filename( 'models/%s.nxb' % fname ) )
print 'Kitchen status for mesh:', status

I get the following assertion:

If it can’t find the object it gives an assertion that says something about isEmpty(). So I believe that it does find the object but its not in the same ‘form’ as when using the loader to load a model and then the kitchen says that the mesh is missing. I have also reparented the found nodepath to the render node and the object does get rendered, which means that the mesh can’t be missing.

Any idea how I can get it to work or a reason why its not?

The egg model has already been read and vertices collected from it at the time when the assert is raised. So this is not the problem. Still, the NxMeshDesc created from these vertices seems to be invalid. Thi sis checked before attempting to cook the mesh.

One idea would be that the mesh contains more than 256 vertices. Convex meshes are restricted to a max of 256 vertices.

If this is not the problem I would like to see the egg or bam file. Maybe I can figure out what is going wrong with this mesh.

enn0x

http://enn0x.p3dp.com/libpandaphysx_0.4.4.zip

Just a maintenance release. Focus has been on strengthening collision and interaction filtering as well as enabeling the visual remote debugger.

  • Add one-way interactions between dynamic objects using dominance groups.
  • Adds support for the Visual Remote Debugger.
  • Adds support for actor groups and actor group filtering.
  • Adds support for 128-bit mask for collision filtering.
  • Adds raycast methods for axis aligned bounding boxes.
  • Additional parameter to raycastClosest/Any methods for smoothed normals.
  • Adds preliminary(!) implementations for vehicles.

(see included file doc/RELEASE-NOTES.txt)

The included binaries are built for Panda3D-1.5.4. Please note that the vehcile classes are not yet ready for being used. I have just been too lazy to remove them for the release.

ennox

enn0x, I noticed in the raycast sample that the ray originates from the box, how were you able to prevent it from immidiately colliding with the box?

By utilizing an oddity of PhysX collision detection system. Box shapes won’t collide from the “inside”. It won’t work with sphere shapes or capsule shapes. Hmm… considering this I think I provided a bad example. I should have used actor groups or shape groups to explicitly filter collision detection.

enn0x