I packed a bunch of snippets showing how panda3d collisions works, split in ready to go standalone scripts, organized with progressive difficulty were you should learn the basics for prepare setups to make your scripts react when models collide each other, how to settle those models in a script and also in Blender3D.
Here a small summary of each step you’ll find in the package:
[color=blue]-- Beginner level
[size=100][color=olive]A first approach with Panda3D collisions[/size]
0) quick startup
first very simple setup
simple setup with masking discrimination
collision events w/ masking
more mouse picking
cheap collisions with isInVIew
panda physics overview
mouse picking in 2D space
[color=green]-- Intermediate level
[size=100][color=olive]Deeper into the topic[/size]
This tutorial is devised to be attended in conjunction with the Blender3D modeler files, therefore if you’re accustomed with a different one, i.e. maya or 3d studio max, I suggest you to download Blender3D nonetheless, study how the sources are structured and then try to reproduce in your beloved modeler.
So far the Chicken exporter do not correctly export collider nesting deeper that 1 level, therefore the descend feature stops there. Check here for more.
Beside this stepped tutorial is actually finished it is always perfectible, therefore drop a post to this thread if you find issues and questions blocking you to get what’s going on in a particular point of the tutorial or blender sources.
Great! This is exactly the kind of thing I could use. I’ve been afraid of collisions for a while, but looks like I have no choice now.
I don’t understand this part of the code:
#** this is where will be periodically tested the collision
for i in range(cHandler.getNumEntries()):
entry = cHandler.getEntry(i)
name = entry.getIntoNode().getName()
dlight.setColor(VBase4(0.8, 0.8, 0.8, 1))
if task: return task.again
dlight.setColor(VBase4(0.0, 0.0, 0.0, 1))
if task: return task.again
The top block is skipped if range(cHandler.getNumEntries())==0, right? But then what is the point of entry and name? I # them out, and the program still works. Is it for (potentially) checking to see what different objects collided with the smiley balloon?
Also, wouldn’t it be clearer if you masked your heart with a LOVE_MASK like the red smiley instead of just a 1?
how less better had you learn it if I ain’t put ‘on purpose’ those litl mistakes, eh?
jokes apart your points are correct, and now I corrected, commented more that part you noted and repacked the zip - keep posting if you find how to improve or find other stuff to fix.
I would like to see a pusher in the next version, like a sad face that you can push around. Maybe even a physics collision would be cool. With that you’ll have covered most of the beginning problems people have with collisions.
Thanks for putting this together. It helps a lot! When its done I’ll fix the grammar for you. I wish there were more collision examples available. This one could be really good (haha, maybe even ‘official’ tutor material ).
I like the new two item setup! There’s a problem, however, that will get people confused regarding your from and into objects. You make your hearts ‘from’ objects and your faces ‘into’ objects. The manual says to make the moving objects ‘from’ objects. I know this is because of your camera trick, but you should note that in the code. Otherwise, it’s a very good example. Thanks for the new version!
well thankyou again - about the from into issue, did YOU get confused? I ask you cos all is commented with fine grain detail so, unless I used bad english, I ain’t fear of that but lemme know otherwise.
#* to have collsions, the engine uses the model geometriy but to optimize the execution time is common practice to use simplified geometries - in our heart egg file we have provided a simple sphere to use for this purpose (look into he blender source to know what I mean) and so we'll gather it from there...
c = heartTrigger.find("**/collider")
cos’ simpler is better
that means to make collision detection on lower polycount surfaces and simpler geometries is less CPU demanding - anyhow here you’ll find a finer explanation: panda3d.org/manual/index.php/Collision_Solids
Today I updated and added 2 more samples to the pack - the new samples do the same things as the formers but in a different, clean and more efficient way using collision events instead to read from a collision queue. Check them out downloading the pack off the first post and of course report what’s wrong or that may be done better.
hey thankyou guys for the appreciation
treeform I guess is still incomplete to find a place in the official samples bunch - to me need at least to put in some ‘fluid’ sample and the gravity collider handler. Anyhow I think soon to fill the gaps.