If I read the manual correctly, polygon-polygon tests are not permitted under the collision library. If I want to do an exact object to object test, and the objects are arbitrary polygonal meshes, how would I do this? Can I do it just with Panda, or do I need something external, like ODE or Newton? If I do need something external, could someone point me to something on how to integrate it with Panda?
That is correct; Panda does not currently support polygon-polygon tests; just sphere-polygon and line-polygon. I suppose you could cobble something together by building a wireframe model for one of your objects out of CollisionSegments, but that’s just silly.
Another alternative is to write the polygon-polygon test in C++ and add it to the Panda3D codebase. If you’ve got a particular algorithm you’d like to use, it’s not too hard to put it in. But it will probably be expensive. Not because a single polygon-polygon test is expensive, but because you’ll really want to perform n^2 polygon-polygon tests.
So your third choice is to integrate with some third-party library that already does support this. It won’t be ODE; that’s a physics engine, not a collision library. I don’t know about Newton.
When you find a collision library that’s suitable, we can consider the best ways to integrate it with Panda; it really depends on the nature of the collision library itself. At its simplest, it would be a matter of loading each model twice: once into Panda, and once into the collision library. Depending on the sophistication of the collision library, it may be possible to achieve a tighter integration, so that the library is able to operate directly on Panda structures.
ODE actually does support collisions, it contains the OPCODE collision library.
So it does. My bad, I didn’t realize that.
Looking over at the ODE docs, it looks pretty straightforward; but in order to integrate with Panda (or any other engine) you’ll have to write the glue code that copies from Panda’s data structures into ODE’s, or vice-versa, and keeps them up-to-date each frame. Whether it makes more sense to copy from Panda to ODE or vice-versa depends on the nature of your application–the number and complexity of objects in your scene, whether you will be using ODE physics in addition to ODE collisions, and the rendering complexity of these objects.
In either case, you’ll need to learn details about both data structures and how to read one and write the other. Probably the glue code should be written in C++, unless you have few enough objects that you won’t mind the cost of doing all this math work in Python each frame.
We can help you learn the details of the Panda data structures, but I know beans about ODE (as I’ve already demonstrated .)
Hmm, I think I’ll probably put off trying integration for now, since I’m a newbie to Panda, and only slightly more skilled at ODE. I’ll probably be able to make due with less exact bounding methods like sphere-polygon/ line-polygon for now. I was just curious if there were any ready-made solutions I was missing.
I was just curious what you were doing that reqired more than sphere/line on poly collision? Sounds like it could be quite cool. = )
I had in mind eventually doing some kind of fighting game where, rather than having the character’s actiond be static, they’d be user driven. So, if, for example, the character had a sword, rather than simply clicking the mouse and doing a preset move, the player would move the tip of the blade with the mouse. The problem with this is that I’d pretty much need to get an intersection between the sword polygon and the target poly. Although, now that I think about it, it might be possible to fake it by using a few lines at key points on the sword.
If you remember that game. Lots of fun…I rather enjoyed chopping off my friend’s arms, and one leg, so they could not do anything but hop around. Then I’d pick up one of their arms and beat them with it!
But that’s just a bit of a glimpse into my own twisted psychology. I would suggest that your collisions could be done with multiple spheres - for example on the arm you might have one for shoulder, elbow, wrist, each just large enough to kiss the next. That probably coincides fairly closely with where you would want to apply the damage. And if you are going so far as to have your sword simulated in this way, you might as well make the player body with…detachable limbs! Yeah!
The more spheres (and therefore smaller) you use, the closer your collision body will match your avatar model. I think you’ll find that it takes only a small number of spheres.
Yeah, I’d be willing to bet with a few well place lines and spheres, you could do what you need. And alot faster than poly-poly collisions.