|
|
|
Return to Code Snippets
by ditus » Mon Jan 21, 2008 8:24 pm
oh, that feels like xmas(s) for me
thx a lot 
is the idea of the lenov diing? no!
the aries is already on build 
-

ditus
- Troll
-
- Posts: 277
- Joined: Mon Oct 15, 2007 2:15 pm
- Location: moon
-
by bigfoot29 » Tue Jan 22, 2008 4:06 am
Hi Ennox.
In case you don't need a compiler guru I might try to take a look at it.
I could also set up a linux machine for the compiler stuff where both could have a look at in the case of problems.
In case you would want to spend some time with compiling problems on linux there might be a solution. Lemme know its that of interest.
Regards, Bigfoot29
-

bigfoot29
-
- Posts: 617
- Joined: Thu Jun 30, 2005 4:22 am
- Location: Germany
-
by enn0x » Sat Jan 26, 2008 2:01 pm
Than you for your offer, bigfoot29.
I am interested, but it won't be before 3/2008 until I can come back to it. Also I have a spare PC by now, which I could turn into a dual boot machine. Which flavour of Linux (SuSe, RedHat, ...) would be best to go for?
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by bigfoot29 » Tue Jan 29, 2008 9:51 am
Well, about the date: doesn't matter that much to _me_.
I would like to suggest to put SuSe into the trashcan - since its only a local phenomenom (and is rather bad imho)
Due to the fact that I use an Debian based OS (Ubuntu), I am pro-Debian. Other users might suggest Red Hat or whatever, but thats a matter of taste.
However, I do NOT suggest using an bleeding edge Linux since many other (not-so-top-notch) distributions might not be able to use the binaries (due to missing libraries / older versions) then.
Regards, Bigfoot29
-

bigfoot29
-
- Posts: 617
- Joined: Thu Jun 30, 2005 4:22 am
- Location: Germany
-
by kampfgnu » Wed Feb 27, 2008 12:20 am
i am trying to compile NxPanda with scons in VS8.
i did it like you described in the Readme.txt.
now i have a "NxPanda.dll" and "NxPanda.pyd" which are both ~1.6 mb.
the original dll (named NxCharacter.dll) is about 140kb.
after replacing NxCharacter.dll with NxPanda.dll and NxPanda.pyd, panda can't load the dll.
can you please give me a hint?
greets
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Wed Feb 27, 2008 4:40 pm
Sure. I try to explain.
(1) "NxPanda.pyd" is just a renamed copy of "NxPanda.dll". Both are the same files. I have choosen to change the extension to .pyd in case Python 2.5 users want to use it. Python 2.5 doesn't find .dll wrappers without some tricks.
(2) "NxPanda.pdy/.dll" is the Python wrapper file. the one you load from Python. But the wrapper dynamically loads "NxCharacter.dll". So it requires to find "NxCharacter.dll". "NxCharacter.dll" is a pure C++ DLL (distributed by AGEIA as part of the PhysX SDK).
(3) You must have two libraries to use NxPanda:
- first: either "NxPanda.dll" or "NxPanda.pyd"
- second: "NxCharacter.dll" in the same directory as the first.
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by kampfgnu » Sat Mar 01, 2008 10:31 am
ok thanks.
another question: i am trying to make a tearable clothobject, therefore using your cloth.py example code and adding the tearable-flag and tearfactor.
- Code: Select all
clothDesc = Nx.NxClothDesc( ) clothDesc.globalPosition = pos clothDesc.thickness = 0.25 #clothDesc.density = 100.0 clothDesc.bendingStiffness = 1.0 clothDesc.stretchingStiffness = 1.0 clothDesc.dampingCoefficient = 1.0 clothDesc.friction = 0.5 clothDesc.tearFactor = 8.0 #clothDesc.attachmentResponseCoefficient = 1.0 clothDesc.flags |= Nx.NX_CLF_BENDING clothDesc.flags |= Nx.NX_CLF_COLLISION_TWOWAY clothDesc.flags |= Nx.NX_CLF_TEARABLE
but that doesn't work.
any suggestions please?
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Sat Mar 01, 2008 12:56 pm
Hmm.... tearable cloth doesn't work so far. Tearing a cloth will change the number of vertices/normals/texcoords etc. of the cloth mesh. This is usually done by allocating (yes, we are on the C level) buffers with enough "spare" vertices for tearing, for example 2x the number of original vertices.
There are several other problems with cloth and soft body so far. For example that I don't update the nodes bounding box. I have been thinking about a new way to provide PhysX support for some time now (e.g. deriving cloth from PandaNode --> ClothNode), but this would be a redesign starting from zero. Right now I am missing time for such a project.
I suggest sticking to the "core" objects for now, which I hope a stable enough for usage. Sorry for the bad news.
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by cheesus » Mon Mar 10, 2008 12:38 pm
hi enn0x,
first of all, thanks for sharing your work, this helps me alot for my panda-rendered physics project
as i need softbodies, i tried your example with the ageia froggy model and it works! but its very slow (compared to ageia samples) and i guess it hast to do with how the mesh information is passed from physx to panda?
do you have any clue what the problem could be? if you have any hint i can take a look at it myself (as i already read through the c++ nxpanda code and i think i understand whats going on there)
if you want to somehow get feedback of bugs i've found or about stuff i add to your bindings please tell me...
greetings
β
-
cheesus
-
- Posts: 13
- Joined: Mon Mar 10, 2008 12:21 pm
by enn0x » Mon Mar 10, 2008 3:25 pm
Well, first the demo code that comes with NxPanda doesn't render the soft body. I think I never tried this before. It just shows a debug render of the mesh. If you turn off the debug renderer then the framerate should go up.
The debug renderer is freaking slow, because it creates a new LineSegs NodePath each frame, by adding one line segment after the other.
- Code: Select all
def renderDebug( self ): if not self.debug: return
dbg = self.scene.getDebugRenderable( ) segs = LineSegs( )
for p0, p1, color in dbg.getLines( ): segs.setColor( *color ) segs.moveTo( p0 ) segs.drawTo( p1 )
self.debugNP.removeNode( ) self.debugNP = render.attachNewNode( segs.create( ) )
The AGEIA demos do this loop in C++, and so they are faster. Another reason why rendering cloth and soft bodies in Panda3D will be slower than the AGEIA demos: The "visible" mesh has to creates each frame (on the C++ layer), by reading the vertex/tex coord/normal buffers that PhysX creates and write them to a Panda3D mesh using GeomVertexWriter. The AGEIA demos just pass the complete vertex etc. arrays to OpenGL with one function call. This makes them faster too. Panda3D users have to stick to GeomVertexWriter, and add vertex after vertex in a loop. This is slower, but on the other hand Panda3D can use OpenGL and DirectX. Well, would be interesting if sonthing like these calls can be used for Panda3D too, perhaps using GeomVertexArrayData. This could give a huge speedup for cloth and soft body. - Code: Select all
glVertexPointer( 3, GL_FLOAT, sizeof(buffer), buffer ); glNormalPointer( GL_FLOAT, sizeof(buffer), buffer );
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by drwr » Mon Mar 10, 2008 3:51 pm
Well, would be interesting if sonthing like these calls can be used for Panda3D too, perhaps using GeomVertexArrayData.
Yep. This is even possible from Python. You only need to use GeomVertexWriter if your data is not already formatted for rendering; if it is already in a block of data ready to be rendered, then you can just stuff it directly in a GeomVertexArrayData.
The trick is to create the appropriate GeomVertexFormat structure that accurately represents your one or several arrays. Set this format on your GeomVertexData, and it will create the corresponding GeomVertexArrayData objects. Then for each GeomVertexArrayData you can call data.modifyHandle().setData(string) to stuff a Python string into the data buffer, very quickly.
David
-
drwr
-
- Posts: 11253
- Joined: Fri Feb 13, 2004 12:42 pm
- Location: Glendale, CA
by cheesus » Mon Mar 10, 2008 4:25 pm
thanks for your quick and profound replies! as i am quite happy for now with cloth rendering performance (even tearing works fine if you allocate enough memory) i will change the softbody source to act like the cloth source. but good to know that there is direct access too!
...falling more and more in love with panda  ...
regards
β
-
cheesus
-
- Posts: 13
- Joined: Mon Mar 10, 2008 12:21 pm
by cheesus » Wed Mar 12, 2008 1:16 pm
one question concerning triggers: i want to catch the onTrigger callback with the NxUserTriggerReport class. i thought i have to define a new python class which inherits from NxUserTriggerReport like this:
- Code: Select all
class sbTriggerReport(DirectObject, Nx.NxUserTriggerReport):
def onTrigger(self, shape1, shape2, status):
in my app i do this: - Code: Select all
self.triggerReporter = sbTriggerReport() self.scene.setUserTriggerReport(self.triggerReporter)
but unfortunately onTrigger never gets called if i do it like this: - Code: Select all
self.triggerReporter = Nx.NxUserTriggerReport() self.scene.setUserTriggerReport(self.triggerReporter)
i get an error when an object enters the trigger (which proofs that the trigger itself is set up correctly):
AttributeError: onTrigger
so how should i do this correctly? (i'm still a python noob...)
thanks!
-
cheesus
-
- Posts: 13
- Joined: Mon Mar 10, 2008 12:21 pm
by enn0x » Wed Mar 12, 2008 1:55 pm
The problem is the way Python handles multiple inheritance. You derive sbTriggerReport from DirectObject AND NxUserTriggerReport. In this case you have to call the __init__ methods yourself, for example like this:
- Code: Select all
class sbTriggerReport(DirectObject, Nx.NxUserTriggerReport):
def __init__( self ): Nx.NxUserTriggerReport.__init__( self ) DirectObject.__init__( self )
def onTrigger(self, shape1, shape2, status):
I think you can leave away the DirectObject __init__ call, but you can not leave away the NxUserTriggerReport call.
With single inheritance you don't need an explicit __init__ method. If no __init__ method is found on the object, then the __init__ method of the parent object is called. But with two parents the compiler doesn't know what to do (call both, but in which order?).
If you don't need the DirectObject inheritance then you should leave it away, or handle user input in another object (not the trigger callback object).
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by cheesus » Wed Mar 12, 2008 6:26 pm
ah ok that sounds reasonable... i just wanted the DirectObject for receiving events from the messenger.
so now i try to implement the direct passing the pointers of mesh data from ageia to panda. i understand the structures and formats of GeomVertexData, but i dont understand what to do with GeomVertexArrayDataHandle.setData(string):
e.g. for the vertex data: ageia gives me a pointer to the beginning of a bunch of vertices (one vertex occupies 3 float32), and it tells me how many vertices there are. so i will create one GeomVertexArrayData which holds only the vertices (GeomVertexFormat.getV3()), get the handle to it, and then i call setData
but what should i pass here? the pointer to the first vertex as a string?
the API says it replaces this string replaces the whole raw array data, so do i have to pass the content of the whole array? wouldnt this mean that all the data gets copied again?
thanks for your help!
-
cheesus
-
- Posts: 13
- Joined: Mon Mar 10, 2008 12:21 pm
by enn0x » Wed Mar 12, 2008 7:04 pm
- Code: Select all
void GeomVertexArrayDataHandle::set_data(string const &data);
This one? Here data get passed by reference (&), so it is not copied.
Maybe a reinterprete cast helps. Haven't been working with these methods so far.
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by cheesus » Thu Mar 13, 2008 3:58 pm
yes this one, but in the c++ source it looks like there is something copied:
- Code: Select all
void GeomVertexArrayDataHandle::set_data(const string &data) { ... _cdata->_buffer.unclean_realloc(data.size()); memcpy(_cdata->_buffer.get_write_pointer(), data.data(), data.size()); ...
or does that mean that just the adress of this string is copied?
anyway, another question is how to pass the pointer of the indices array to GeomTriangles? i couldnt find a handle or setData method. maybe they would still have to be copied...
-
cheesus
-
- Posts: 13
- Joined: Mon Mar 10, 2008 12:21 pm
by enn0x » Thu Mar 13, 2008 6:09 pm
Ah... ok, you are right. memcpy is a standard C function defined in string.h. It makes a binary copy. I would guess this is still way faster than feeding every vertex by hand to GeomVertexWriter.
Thanks drwr for this tip. Next time I touch the mesh code I will try to use the GeomVertexArrayData.
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by kampfgnu » Wed Mar 19, 2008 12:58 pm
i just installed panda3d 1.5.
when importing NxPanda, i get the following error (in german):
"Der Prozedureinsprungpunkt "?_global_ptr@ObjectDeletor@@0PAXA" wurde in der DLL "libpandaexpress.dll" nicht gefunden"
any ideas how to solve this?
greets
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Wed Mar 19, 2008 1:41 pm
By compiling NxPanda for Panda3D 1.5.0. The current binaries are compiled for Panda3D 1.4.2.
I don't have Panda3D 1.5.0 installed right now, and I am using a different version of the PhysX SDK. But I think I have some spare time during the easter days. So perhaps I can compile it for you. It not, the source is included.
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by kampfgnu » Wed Mar 19, 2008 4:06 pm
ohhhh sure... what a dumb question, sorry i am stupid hehe...
anyway, thanks for your answer!
for anyone who needs it, here is the NxPanda.pyd for panda 1.5
http://kampfgnu.ka.funpic.de/stuff/NxPanda.zip
greets, kampfgnu
p.s.: ennox, thanks for sharing your work, ageia rocks
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Sun Mar 23, 2008 11:51 am
Not a dumb question. I think I should have compiled right after 1.5.0 was released. Thanks for sparing me some work :-)
Here is some new info releated to NxPanda:
- PhysX 1.8.0 is out, but there are major changes in the API, and NxPanda won't compile out of the box for the new SDK version.
- Nvidia has bought AGEIA. Nvidia has not revealed their plans yet. I don't know if Nvidia wants to continue separate physics hardware cards, or if they want to integrate the chips on their graphics cards (maybe to push users to buy SLI systems?). Whatever, I guess they will continue to use the SW physics engine. Hopefully with a royalty-free license form too.
- I am currently not improving NxPanda, but started a new PhysX project which integrates PhysX and Panda3D much stronger. I won't be a native Python extension but will use interrogate for wrapping to Python. And so far it compiles on Linux too.
- Since this has come up in several other threads: I don't think NxPanda can ever be part of Panda3D, like for example pro-rsoft's PGMM module. This is not because I don't want to, but because the PhysX license. Well, maybe this changes too with Nvidia.
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by kampfgnu » Tue Mar 25, 2008 7:32 am
so you mean nxpanda will "die"/you won't go on working on it ?
and your new physX-project...do you again use ageia?
i will soon do a project for university (making a game), that i would really like to make with panda and nx (or maybe your new physxs-thing). do you think this is just a dream  ?
ok and another question concerning the current nxPanda:
i am trying to limit a joint:
- Code: Select all
jointDesc.flags |= 1 #NX_RJF_LIMIT_ENABLED jointDesc.limit.high.value = 0.25*math.pi jointDesc.limit.high.restitution = 1 jointDesc.limit.low.value = -0.25*math.pi jointDesc.limit.low.restitution = 1
but i get this error: "AttributeError: attribute 'limit' of 'NxPanda.NxRevoluteJointDesc' objects is not readable" the same here: - Code: Select all
jointDesc.flags |= 1 limit = Nx.NxJointLimitPairDesc() limit.high.value = 0.25*math.pi limit.high.restitution = 1 limit.low.value = -0.25*math.pi limit.low.restitution = 1 jointDesc.limit = limit
AttributeError: attribute 'high' of 'NxPanda.NxJointLimitPairDesc' objects is not readable
what can i do?
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Tue Mar 25, 2008 4:23 pm
your new physX-project...do you again use ageia?
This "new" Project is PhysX too. AGEIA is the name of the company, and PhysX the name of the physics engine. So no, it won't die. I just try to figure out how to make NxPanda more "Panda3D-like", and take lots of the complexity away into the C++ layer. It will be a step back for the first time though, since I focus on "basic" features: rigid body & character controllers. Oh, and Linux too :-) so you mean nxpanda will "die"/you won't go on working on it
Adapting NxPanda from PhysX 2.7.3 (current) to 2.8.0 will be about 40 hours of (boring) work. More than I have in the next two month, so it will be some time before this happens. But I will continue (slow) work on NxPanda. right now I suggest you stick with the current 2.7.3 bindings. AttributeError: attribute 'high' of 'NxPanda.NxJointLimitPairDesc' objects is not readable
Right. I didn't implement getters for these attributes. ThePython wrapper objects are structs for C++ pointer (even the "desc" objects). I have considered making getters too, using the template below, but then I would have a problem if the new PyObject deallocated while the "original" PyObject is still in use. So I decided not to implement getters (only setters).
- Code: Select all
template<typename V, typename T> static inline PyObject * getter_value( const V &value, T * &_o, PyTypeObject &type ) { _o = PyObject_New( T, &type ); _o->ptr = &value; return (PyObject *)_o; }
You can work around this by using only setters. More complex, but it should work. Not tested though... - Code: Select all
highLimit = JointLimitDesc( ) highLimit.value = 0.25*math.pi highLimit.restitution = 1
lowLimit = JointLimitDesc( ) lowLimit.value = -0.25*math.pi lowLimit.restitution = 1
limit = Nx.NxJointLimitPairDesc() limit.high = highLimit limit.low = lowLimit
jointDesc = NxJointDesc( ) jointDesc.flags |= 1 jointDesc.limit = limit
enn0x
-
enn0x
-
- Posts: 1267
- Joined: Wed Nov 08, 2006 1:39 am
- Location: Germany, Munich
by kampfgnu » Thu Apr 03, 2008 8:54 am
how can i access a joint after creation?
- Code: Select all
#create revolutejoint joint = self.scene.createJoint( revjointDesc ) print joint
<NxPanda.NxRevoluteJoint object at 0x00A5C1E0> - Code: Select all
joint.getFlags()
AttributeError: 'NxPanda.NxRevoluteJoint' object has no attribute 'getFlags' when i do a "print dir(joint)", i get the functions of NxJoint. i tried to cast the joint (although it still seems to be a NxRevoluteJoint): - Code: Select all
Nx.NxRevoluteJoint(joint).getFlags()
TypeError: cannot create 'NxPanda.NxRevoluteJoint' instances
greets
-

kampfgnu
-
- Posts: 94
- Joined: Thu Nov 22, 2007 10:29 pm
- Location: austria, vienna
by enn0x » Thu Apr 03, 2008 4:37 pm
I just looked at the source, and... well, none of the NxRevoluteJoint methods are wrapped. Same for most other joint types. It wouldn't be hard to add these methods, just apply the same pattern as found in other objects. NxPanda is far away from being complete, I know.
By the way: casting is something you can do in C++ and some other languages, but not in Python. And I think this is a good thing.
(Almost) all NxPanda objects are created using factory methods, which take an descriptor object as argument. So I have explicitly disallowed to create the Python wrapper objects for these classes.
enn0x
-
enn0x
-
- Posts: 1267
- 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 1 guest
| | |