|
|
|
Return to Code Snippets
by enn0x » Thu Aug 30, 2007 4:26 pm
AGEIA, manufacturer of the first mass-market PPU cards, has come under pressure from upcoming graphics cards with integrated hardware physics, for example NVIDIA 8 Series Quantum Effects Technology. Only a few games support AGEIA PhysX cards so far, and if they don't gain market share soon they will be second to the big GPU companies.
One effect of this pressure has been that AGEIA has lowered their license fees for their physics SDK some month ago. From 50000$ to ZERO! Commercial use too.
Maybe I will buy a PhysX card next month, maybe not. But even without hardware acceleration (530 million sphere/sphere collisions per second...duh) their physics engine is tremendous, both concerning speed and features. Whatever, here is a first preview for NxPanda (or whatever the final name will be. Nx because of Novodex, the original name for their physics engine):
http://www.dachau.net/users/pfrogner/NxPanda.zip
The demo is compiled for windows, but AGEIA has a Linux SDK too. To run the demos you will need to have Panda3D-1.4.0 and the latest AGEIA PhysX system software (7.07.24). Beware, the system software is a large download. Not as large as Panda3D, but still ~30M:
http://www.ageia.com/drivers/drivers.html
For now I follow the PhysX API very closely, so integration with Panda3D is only "light". But once I have learned more about using PhysX I might re-design and integrate more tight.
Only a very small part of the PhysX API is wrapped by now, and it will be some time before I work on more advanced features like fluids or soft bodies. Still, here are some highlights:
- Kinematic character controllers, with stair stepping, slop limit, jumping and crouching. Something I found to be tricky to implement with other physics engines (ODE, Newton). A small "mini game" is included. Hmmm... actually not a game since their is no goal for the player, so just a techdemo.
- Cloth. Well, see yourself. No tearing and attaching so far. Turn off the debug renderer to see the real fps (more than 500 on my PC).
The downside: PhysX might be powerful, but is not open source. This mean PhysX is not suited to replace the built-in collision & physics systems of Panda3D. It will always stay just an alternate way to do physics.
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by rdb » Fri Aug 31, 2007 8:02 am
Looks very good, enn0x! Thanks very much for sharing!
It's indeed a pity that it's not opensource... because if I use it in my game, I can't call it opensource no more
1 question: "Turn off the debug renderer to see the real fps"
Any suggestion how to do that?
-
rdb
-
- Posts: 8547
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by enn0x » Fri Aug 31, 2007 1:07 pm
Thank you very much. It's not exactly sharing, because I didn't release the source code so far. I will, once a "0.1" state is achieved, and PandaProjects is running.
F3 toggles the debug renderer in all scripts, except for the very first one which just shows how to initializes the engine. The debug renderer is a big impact on framerate, because every frame all the wireframe geometry is created anew. And I am pretty sure I didn't choose the fastest way to do this.
Open source: Well, yes, I would prefer if PhysX was open source too. But maybe this is wishing for too much. PhysX might not be equal to Havok in all aspects, but it is close.
I know it is very hard to define what open source really is. I think open source software can utilize other closed source libraries, but this is just my opinion. There wouldn't be any open source software possible on MS Windows otherwise, since any code sooner or later uses OS functionality, for example output to the console, or opening a window. And these MS Windows system functionality is closed source. So Panda3D on MS Windows would not be opens source, because of "#include <windows.h>" and linking against M$ CRT.
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by BoZ » Tue Sep 04, 2007 3:34 am
I <3 you Ennox! I needed physics for my game and this looks a lot easier than PYODE!
-
BoZ
-
- Posts: 45
- Joined: Mon Aug 28, 2006 3:13 am
by mindstormss » Wed Sep 05, 2007 6:20 pm
I installed and did everything your first post said to do, but on my system it is creating an error on all 5 (that I tested) of the demos...the error is close to
self.sdk = Nx.createphysicsSDK()
could not create NxPhysicsSdk
on line 96 in the 01_basics tutorial...
All human beings should try to learn before they die what they are running from, and to, and why.
- James Thurber
-

mindstormss
-
- Posts: 203
- Joined: Mon Jul 30, 2007 9:21 pm
- Location: California
by BoZ » Wed Sep 05, 2007 7:37 pm
Are you sure you have the latest AGEIA drivers?
I thought I did and got that error but it was fixed when I downloaded the link in the first post.
-
BoZ
-
- Posts: 45
- Joined: Mon Aug 28, 2006 3:13 am
by mindstormss » Wed Sep 05, 2007 9:40 pm
oops...I scrolled down to the bottom of the page and downloaded the second latest version  sorry
All human beings should try to learn before they die what they are running from, and to, and why.
- James Thurber
-

mindstormss
-
- Posts: 203
- Joined: Mon Jul 30, 2007 9:21 pm
- Location: California
by Braveheart » Thu Sep 06, 2007 12:48 pm
So we can use this free of charge for a commercial game? How do i download it? How exactly do i use it with Panda? Is there any tutorials on how to, or is this download a tutorial?
Thanks!
-
Braveheart
-
- Posts: 26
- Joined: Thu Mar 15, 2007 2:22 pm
- Location: Scotland
by mindstormss » Thu Sep 06, 2007 4:32 pm
I believe that Ageia is required to be installed on all computers for it to work, in addition to the dlls that ennox is using to bind it. This means that to distribute a game with it, you have to include the ageia installer as well. As far as I know, physx is free for commercial and private use now, but it is still closed source. The download consists of 11 examples along with a game and a way to "cook" nx models from nodepaths.
What is missing (and it would be really helpful ennox) is a list of all the commands wrapped so that we do not have to guess which commands there are. (documentation can be found for physx in general online)
All human beings should try to learn before they die what they are running from, and to, and why.
- James Thurber
-

mindstormss
-
- Posts: 203
- Joined: Mon Jul 30, 2007 9:21 pm
- Location: California
by mindstormss » Mon Sep 10, 2007 6:59 pm
Hey ennox, this doesn't work with panda 1.4.1, can you recompile the binaries (or give the source  please
All human beings should try to learn before they die what they are running from, and to, and why.
- James Thurber
-

mindstormss
-
- Posts: 203
- Joined: Mon Jul 30, 2007 9:21 pm
- Location: California
by enn0x » Fri Sep 14, 2007 11:00 am
Sorry for the late response. Just back from a holiday on a boat at the red sea, and the only piece of electronic equipment I had with me has been my old Aladin diving computer. I will try to answer some of the above questions:
Panda3D 1.4.1:
I have re-compiled for Panda3D 1.4.1, and replaced the above download. So now the requirements are AGEIA PhysX system software 7.07.24 or later and Panda3D 1.4.1.
http://www.dachau.net/users/pfrogner/NxPanda.zip
Documentation:
At the moment (pre-alpha!) documentation consists only of a few tutorials and examples. But as with every Python module you can use introspection to find out what classes/methods/attributes exist (that's "print dir( object )"). Also you can use pydoc to create a minimal html documentation. But this only lists what methods exist, and not what arguments are required/possible.
Writing full documentation is quite a bit of work, and until I know exactly what way I will go with NxPanda I won't put much effort in writing manuals or docstrings. Please see below for future plans.
PhysX system software:
The PhysX system software is very similar to DirectX. It contains all versions of the physics engine runtime, plus hardware drivers for the PhysX cards. Just like DirectX. And like DirectX, PhysX needs to be installed only once for several PhysX-enabled applications/games.
There has been some talk on the AGEIA forums about the size of the system software, and AGEIA announced to create smaller, customized installers with one of the next releases.
30M might be big at the first glance, but look at typical games nowadays: distributed on one DVD usually, with several gigs of content (models, textures, speech, music/sounds, ...). 30M for PhysX and 60M (???) for DirectX doesn't matter much.
For online distributed games you could ask the end user to download and install the PhysX system software himself. Downloading the system software from AGEIA is free of charge and does not require registration.
"Free":
There are many shades of "free". For certain PhysX is not open-source, and it is not GPL/LGPL. But unlike other products like Havok, 3D Max or SpeedTree there is a way to use it for commercial and non-commercial applications without license fees. With a few restrictions.
Please go to the below link and read the topic "How do I become a licensed developer and what are the licensing terms?":
http://devsupport.ageia.com/ics/support/default.asp?deptID=1949
I'm not a lawyer, so please tell me if you think NxPanda is violating any part of the PhysX EULA. I'm rather positive, since there are other projects too, like for example NxOgre (link below), which is released under the LGPL.
http://www.nxogre.org/
Future:
Right now I consider NxPanda to be in a pre-alpha state. I don't know much of the PhysX C++ API. And I am not yet sure which would be the best practice for using it with Panda3D.
One option (which is currently used) is a "wrapper" that keeps close to the PhysX C++ API. Integration with Panda3D is at the level of automatic conversion of arguments like Vec3, Mat4 or Point3, plus callbacks and some utils like parsing a NodePath geometry.
Another option would be to integrate more tight with Panda3D. Perhaps offering classes derived from NodePath which handle physical bodies, triggers or other game objects. Similar to the native Panda3D physics system, but based on PhysX. Pro-rsoft has given a good example on how to extend Panda3D using C++ and interrogate. But this would require some design work first (and better knowledge on how to use the PhysX API).
Comments, ideas and suggestions are welcome, of course.
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by Slade992 » Wed Sep 26, 2007 5:18 am
Hi,
I decide to use Nxpanda for my game, but i have some question ^^
I tryed to texture a cloth without succes i just get the color of the texture on it, is there a way of doing this ?
Do you intend to make a attachment system for cloth ?
Another thing, if i rotate vertically the cloth to 90° into the tutorial, the close fall like that :
She fall from the camera (front of the crate) horizontaly, insteed of falling from the top to the bottom of the screen.
Is there a way for making a falling of a cloth rotated at 90° ?
Sorry for my poor english ^^
and a big applause for your good work ^^
-
Slade992
-
- Posts: 81
- Joined: Thu Jul 27, 2006 11:59 am
by enn0x » Wed Sep 26, 2007 6:56 am
Thank you for your interest. I hate to say so, but NxPanda is still in a very early stage. I don't even dare to make a first full release. So please be prepared for strange behavior.
For now my focus is on making the basic features of NxPanda stable (rigid bodies, controller, joints, triggers, raycast...). I do this by writing a *small* demo-game, and while I do so fix any kinks or memory leaks I encounter. The demo-game will be 3rd person RPG, similar to your Herdelia project, but without any network support, and without any good looking graphics. More advanced features like cloth, fluids or mesh paging are far down on my priorities list. About your questions:
Rotation:
I guess you did it this way:
- Code: Select all
self.clothNP = self.clothData.generate( ) self.clothNP.reparentTo( render ) self.clothNP.setColor( 1, 1, 0.5 ) self.clothNP.setP( 90.0 )
This won't work because every frame the cloth mesh gets updated. Updating works by reading all vertices from C++ NxMeshData, and using a GeomVertex(Re)Writer to update the vertex position. The vertices generated by Nx are in global space ("render"), so adding a transform (translation, rotation, scale, shear) to clothNP will result in a mismatch between the physical world and the visual world. Or in other words: the physics simulation doesn't know that you have rotated the cloth if you modify clothNP. I could add code to read the clothNP transform and transform each vertex before writing it to the vertex writer, but this would be a significant slowdown. The right way would be to tell NxPanda that the mesh is translated and rotated by replacing the first line with the second line, where matrix is a Mat4 with translation AND rotation: - Code: Select all
#clothDesc.globalPosition = pos clothDesc.globalPose = matrix Texture:Texture are not supported by now. Texture is a bit tricky, since the cloth could tear (not supported yet, too), and tearing changes the number of vertices. So Nx has to remember the *original* index for each mesh vertex. The PhysX C++ API has support for this, but it is not yet wrapped. Attachment:Attaching the cloth to something is possible, and already wrapped, but experimental. Uncomment these lines (346-348) in the cloth demo: - Code: Select all
for i in range( length ): p = pos + Vec3( -stride * i, 0, 0 ) self.cloth.attachVertexToGlobalPosition( i, p )
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by Slade992 » Wed Sep 26, 2007 10:23 am
Ok thanks you for your answers ^^
i'll try this.
just a last question, how can i do that ?
where matrix is a Mat4 with translation AND rotation:
I didn't find anything about it on the manual.
good luck for this huge work !
-
Slade992
-
- Posts: 81
- Joined: Thu Jul 27, 2006 11:59 am
by enn0x » Wed Sep 26, 2007 11:01 am
Either by using a dummy node, e.g. like this:
- Code: Select all
np = NodePath( 'dummy' ) np.setPos( 1, 2, 3 ) np.setR( 30.0 ) matrix = np.getMat( )
...or by computing it yourself, e.g. like this: - Code: Select all
m1 = Mat4.rotateMat( 30.0, Vec3( 0, 1, 0 ) ) m2 = Mat4.translateMat( Vec3( 1, 2, 3 ) ) matrix = m1 * m2
Order is important: m1 * m2 is not the same as m2 * m1 !!!
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by Slade992 » Wed Sep 26, 2007 12:19 pm
ok thx, i must make this onto clothNP and then make
clothDesc.globalPose = matrix
Thank you a lot 
-
Slade992
-
- Posts: 81
- Joined: Thu Jul 27, 2006 11:59 am
by enn0x » Thu Sep 27, 2007 3:40 am
Umm... no.
clothNP does no exist at the time when you configure cloth and clothDesc. You will have to use a separate dummy node or compute the matrix yourself. Computing it yourself is probably the better way. But below is the modified code using a dummy node.
- Code: Select all
np = NodePath( 'dummy' ) np.setPos( pos ) np.setP( 90.0 ) matrix = np.getMat( )
# cloth clothDesc = Nx.NxClothDesc( ) ###clothDesc.globalPosition = pos clothDesc.globalPose = matrix clothDesc.thickness = 0.1 clothDesc.bendingStiffness = 0.5 clothDesc.stretchingStiffness = 1.0 clothDesc.friction = 0.3 clothDesc.flags |= Nx.NX_CLF_BENDING clothDesc.flags |= Nx.NX_CLF_COLLISION_TWOWAY clothDesc.clothMesh = mesh clothDesc.meshData = self.clothData print clothDesc.isValid( )
self.cloth = self.scene.createCloth( clothDesc )
# cloth NP self.clothNP = self.clothData.generate( ) self.clothNP.reparentTo( render ) self.clothNP.setColor( 1, 1, 0.5 )
Another way would be to create the cloth vertices in a different way. Clothes are not restricted to planar meshes. It can be tubes for example. The ultimate goal is to have characters clothed in cloth. But I reckon this will need physics hardware support and a faster way to update the Panda3D meshes. The code below creates the mesh vertices vertical (x/z plane) and not horizontal (x/y) plane like in the original demo. - Code: Select all
points = [ ] for j in range( length + 1 ): for i in range( width + 1 ): x = stride * i - 0.5 * stride * width y = 0 z = stride * j - 0.5 * stride * length points.append( ( x, y, z ) )
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by Slade992 » Thu Sep 27, 2007 4:53 am
Ok, thnaks a lot i'll look at it.
-
Slade992
-
- Posts: 81
- Joined: Thu Jul 27, 2006 11:59 am
by Cronos » Sun Nov 04, 2007 6:43 pm
Hi, I'm trying to make a trigger to represent the field of view from the NPCs.
Well, doing the shape as Nx.NxSphereShapeDesc( ) it works, the TriggerReport detects the collisions. Here is the code to create the shape:
- Code: Select all
shapeDesc = Nx.NxSphereShapeDesc( ) shapeDesc.radius = 5.0 shapeDesc.shapeFlags |= Nx.NX_TRIGGER_ENABLE shapeDesc.name = self.name shapeDesc.localPose = shapeDesc.localPose.translateMat( Vec3(0, 1, -5) ) # Translate the sphere to simulate the field of view.
Result is a pink sphere in front of the bunny.  Instead of a sphere I want to use a pyramid shape, but the TriggerReport don't detect anything Making the pyramid shape: - Code: Select all
cooking = Nx.getCookingLib( ) cooking.initCooking( )
meshDesc = Nx.NxConvexMeshDesc( ) meshDesc.flags = Nx.NX_CF_COMPUTE_CONVEX meshDesc.points = [ ( 0, 0, -7 ), ( 1, 3, 0 ), ( 1, -3, 0 ), ( -1, 3, 0 ), ( -1, -3, 0 ) ]
# option (1): save to file and load again #print cooking.cookConvexMesh( meshDesc, 'models/pyramid.nx' ) #mesh = self.sdk.loadConvexMesh( 'models/pyramid.nx' )
# option (2): cook in memory mesh = Physx.physx.sdk.createConvexMesh( meshDesc, cooking )
shapeDesc = Nx.NxConvexShapeDesc( ) shapeDesc.meshData = mesh shapeDesc.shapeFlags |= Nx.NX_TRIGGER_ENABLE shapeDesc.name = self.name
The result is an orange pyramid. I guess it should be pink to work like the sphere
If someone can help.. thanks!
-
Cronos
-
- Posts: 30
- Joined: Sun Apr 22, 2007 1:33 pm
- Location: Brazil
by enn0x » Sun Nov 04, 2007 7:02 pm
For triggers these interactions are not possible:
- convex vs. triangle mesh
- triangle mesh vs. triangle mesh.
See the SDK documentation for more details:
SDK > Guide > Collision Detection > Triggers
I think it is best to use only primitives for triggers.
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by Cronos » Sun Nov 04, 2007 8:39 pm
Thanks, now its clear to me, I think I'll use box then.
-
Cronos
-
- Posts: 30
- Joined: Sun Apr 22, 2007 1:33 pm
- Location: Brazil
by weihuan » Fri Nov 23, 2007 9:47 pm
Does NxPanda work with the newest Panda3D 1.4.2?
newbie.weihuan
-
weihuan
-
- Posts: 75
- Joined: Wed Jun 20, 2007 6:33 am
- Location: Beijing,China
-
by Cronos » Sat Nov 24, 2007 7:02 pm
weihuan wrote:Does NxPanda work with the newest Panda3D 1.4.2?
Hi weihuan, it works here, I'm using NxPanda with Panda3D 1.4.2.
-
Cronos
-
- Posts: 30
- Joined: Sun Apr 22, 2007 1:33 pm
- Location: Brazil
by weihuan » Sun Nov 25, 2007 8:05 pm
Thank you for inform me Cronos.
newbie.weihuan
-
weihuan
-
- Posts: 75
- Joined: Wed Jun 20, 2007 6:33 am
- Location: Beijing,China
-
by enn0x » Mon Dec 24, 2007 6:15 am
After quite some time: here is the second release of NxPanda (0.2)
http://www.dachau.net/users/pfrogner/NxPanda.zip (996776 byte)
The code has been rewritten from scratch, with focus on stability and memory leaks. Also some new features have been added:
- force fields
- joints
- serialization (xml or binary)
- cloth simulation now with texture support
- fluid simulation and fluid emitters/drains
- soft body simulation (unfinished)
- hardware accelerator support
Source and binaries are included. Binaries have been compiled for Panda 1.4.2
using VC++ 8.0 and Python 2.4.
There are still some kinks and edges. For example I really should check if filenames passed as arguments are valid. Suggesting, criticism or bug reports are welcome, as always.
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by neighborlee » Tue Dec 25, 2007 3:04 pm
enn0x wrote:After quite some time: here is the second release of NxPanda (0.2) http://www.dachau.net/users/pfrogner/NxPanda.zip (996776 byte) The code has been rewritten from scratch, with focus on stability and memory leaks. Also some new features have been added: - force fields - joints - serialization (xml or binary) - cloth simulation now with texture support - fluid simulation and fluid emitters/drains - soft body simulation (unfinished) - hardware accelerator support Source and binaries are included. Binaries have been compiled for Panda 1.4.2 using VC++ 8.0 and Python 2.4. There are still some kinks and edges. For example I really should check if filenames passed as arguments are valid. Suggesting, criticism or bug reports are welcome, as always. enn0x
That is wonderful news, and thx so much for taking the time to make this happen for all Panda3d'ers  )
Cheers and Merry Christmas everyone...may the reason for the season uplift us all
cu
nl
One Game at a time-
http://heartseed.sf.net
[ We are currently looking for help ]
Email us or goto: irc.freenode.net
to channel #heartseed {You can also find us in #neighbors & #panda3d }
Thank You.
-

neighborlee
-
- Posts: 149
- Joined: Sat Jun 18, 2005 11:01 am
- Location: Seattle, Washington
-
by Cronos » Wed Jan 02, 2008 3:47 pm
Very cool the samples and new features! Thanks enn0x
-
Cronos
-
- Posts: 30
- Joined: Sun Apr 22, 2007 1:33 pm
- Location: Brazil
by treeform » Thu Jan 03, 2008 6:20 pm
what is the state of PhysX for linux? And what licensing restrictions we have on using it?
-

treeform
-
- Posts: 2106
- Joined: Sat May 05, 2007 5:15 pm
- Location: SF, CA
-
by Cronos » Fri Jan 04, 2008 1:27 pm
treeform wrote:what is the state of PhysX for linux? And what licensing restrictions we have on using it?
I would like to know this too.. I don't know how to build from the source to run in Linux
About the licensing restrictions, there is a License.txt in the .zip, see if it helps.
-
Cronos
-
- Posts: 30
- Joined: Sun Apr 22, 2007 1:33 pm
- Location: Brazil
by enn0x » Fri Jan 04, 2008 2:36 pm
I think these questions are about NxPanda. PhysX (tm!!!) is a first-grade physics engine developed by AGEIA. First-grade means that it is on the same level as Havoc. A PhysX SDK for Linux is available from the AGEIA site (link is above), for registered users.
NxPanda is a (not really first grade :-) wrapper around PhysX written by me. For my own work the zlib license applies. For the underlying PhysX engine the AGEIA license applies (link is above too).
In short and as far as I understand the AGEIA license:
- royalty free for commercial and non-commercial use
- have to register with AGEIA
- have to give attribution to AGEIA technology (readme.txt, intro screen, ...)
- not allowed to reverse-engineer AGEIA binary code etc
- not allowed to distribute any documentation, samples or other material that is copyrighted by AGEIA
But please read the AGEIA license yourself, I'm not a lawyer and can't give legal advice here.
About Linux: I am pretty optimistic that NxPanda can be compiled on Linux. But I don't have a Linux computer available. Getting Linux, setting up a machine, getting familiar with building on Linux and so on will require me two or three days. So I am afraid there won't be Linux support if not someone else gives it a try.
The basic steps for building:
- install PhysX SDK for Linux
- install scons (just an ordinary Python module)
- edit the NxPanda SConstruct file (adapt paths and compiler flags)
- run "scons"
enn0x
-
enn0x
-
- Posts: 1264
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
Return to Code Snippets
Who is online
Users browsing this forum: No registered users and 0 guests
| | |