I can’t seem to figure it out, so can someone talk me through the process of creating a collision model, loading the egg/nodes, and creating the collision node?
I can’t find anything in the manual or API for collisions beyond the geometry panda supplies. While I know I should use spheres for From objects, I want to use hitboxes/low poly models for my Into objects.
My modeling software is Maya if that makes any difference.
Im not sure how the conversion works for that format, it might already apply the collision stuff for you but just incase, here is a way of doing it by hand.
When you convert to egg format, you should be able to open that up into a text editor and you should see something like…
Then when you load the model you should be able to search for myCollisionName in the model. Have a look at how the labyrinth example deals with the getting/handling of that bit.
Here is a sample of what I did in my test game, I load the main scene and a separate collision model, which has its wall { Polyset descend } tags to make it a collision geom node.
Hope it helps.
# load the visual model
self.scene = loader.loadModel('models/course1/course1')
self.scene.reparentTo(render)
#load the collisions model
self.solids = loader.loadModel('models/course1/course1_coll')
self.solids.reparentTo(render)
#load player model
self.player = loader.loadModel('models/carnsx/carnsx')
self.player.reparentTo(render)
#search for group "wall"
# in my model I've set the tag:
# <Group> wall {
# <Collide> wall { Polyset descend }
# this tells panda its a geom collision node
walls = self.solids.find("**/wall")
# Set the collision bit in the IntoCollideMask
walls.node().setIntoCollideMask(BitMask32.bit(0))
Edit: Darn, sandman beat me to it. Not nice posting while I’m still writing
hey, i´m trying to add a collision tag in my model exported from 3d max. but the code doesn´t have a group before the tags, to add the collide tag, like i saw in an earlier post.
NodePath.node().find("**/myCollisionName") #nodepath is the name that i create
the prompt return a error message saying that the node is empty. in what line i need to add the tag? and what is the difference between polyset keep and polyset descend?
thanks
I’m not sure what you want to do, but if you just want collisions on pre-existing models, you don’t have to edit the .egg file. You can create a collision sphere/polygon/whatever in panda and parent the sphere to the model.
Read through the collision detection tutorial that comes with panda, and search the forums for collision detection examples, there should be a bunch of them.
I’ve done a few rapid prototypes with panda, and I would never even consider editing the .egg file for collisions…it’s much nicer to do it in panda using code.
It supports collision polygrons (for geom collisions)
Its faster then loading 50 collision spheres and saves code
More efficient
those are my reasons anyway ^^
I also found its usefull to edit some egg files in notepad to make sure all is as it should be. When exporting from 3dsmax, I usually get a tag trown in at the start of the first group, I have to remove that when I use tags.
ok, i´m seeing the people don´t understand what i want. maybe because my english is not so good. do you know the collision detection tutorial? the maze model has a tag, not colision spheres or something like this. my model is complex like a maze, and put colision spheres or tubes will be boring a lot. do you understand now?
thanks for the patience
Kutz: Use collision Polygons in the egg file. To understand more about it, look a the link that The_Sandman posted above. It tells you all about Polyset, keep and descend.
Rainbow Brite: Yes you can add collision polygons in code, but it is a whole lot easier if you are able to position them in a modeling program. I still use collision solids in code, but sometimes the egg file is the better way. Especially for a polyset collision solid, which is what Kutz seems to be looking for.
well… “I” find it easier to use because I can just place my solids using a modeling program, which is ofcourse more visual so… easier for me to grasp
Collision polygons; I create simplified geometry in a modeling program for the player to collide with, this is usefull for things like walls, terrain or to tell the engine the player is in a certain area (ie water). I supose you could add collision polygons through code, but that would be rather a lot of trouble.
Python code is rather slow compared to C++, as far as I understand, loading from egg or bam files is mostly done in C++, while you need more lines for creating your collision models in python.
Code in the egg file isnt python, its comparable to .x model format, merely a human readable format, while the bam files are the binary format. So… I dont think you can compare egg/bam code to python code.
I’m not a guru in this field, but this is what I figure…
Sorry for taking this thread astray.
I just figured the generel discussion of .egg vs .py was interesting.
I will make a new thread for this discussion now.
So Kutz can get his answers here.