collision troubles[SOLVED]

Hi everybody

I’m in trouble about collisions. I want put my Model in Bitmask 0. See the code:

magic=loader.loadModel(“models/cubeMagik”)
magicNode=render.attachNewNode(“magikNode”)
magic.reparentTo(magicNode)
magic.find("**/hand").node().setIntoCollideNode(BitMask32.bit(0))

“**/hand” is a collide group im my model. But when i run the code i got:

File “BlenderImport.py”, line 20, in init
magic.find("**/hand").node().setIntoCollideNode(BitMask32.bit(0))
AssertionError: !is_empty() at line 269 of c:\p\panda3d-1.5.4\panda\src\pgraph\nodePath.I

So what the … :open_mouth:

Someone can help
Thanks

It means the node that “magic” points to is empty. That’s usually the result of a find() operation that failed.
It just means it failed to find the node “hand”. Are you sure an EggGroup named like that exists in the model, and with that exact name? I believe it’s case-sensitive.

Rsoft

when i try:

if magic.find("**/hand"):
print “allright”

I got allright printed. In magikCube.egg i got:

{ Z-up }

{ “Egg laid by Chicken for Blender v1.0” }

supMat {
diffr {1.0}
diffg {1.0}
diffb {1.0}
specr {0.105865746737}
specg {0.105865746737}
specb {0.105865746737}
shininess {104.5}
}
supMat {
“magik_pass1.tga”
}
casca {
{ 1 }
magikCube {
hand { Sphere keep descend }
magikCube {
0 {
0.500000 -0.500000 -1.000000
{ 0.589411 0.305665 }
{ 0.171089 -0.171089 -0.970287 }

I put the collide tag in file because i don´t know how to make Chiken (i use blender for modelling) put collide in EGG files. I ever see this topic in Chiken Help then i think put the Collision tag by myself. This could be wrong :frowning:
How to solve this?
Thanks for advice :slight_smile:

find() still returns a NodePath when it’s not found, but an empty one. This code will fail:

if not magic.find("**/hand").isEmpty():
  print "allright

find() only finds nodes, not nodes, I think. Try find(“magikCube”) or so, depending on what you want to do.

This sort of mistake is often made:

if magic.find("**/hand"):
  print "allright"

As pro-rsoft points out, the result of find() is always a NodePath, so it always evaluates true, whether or not the find() succeeded. So the above code will always print “allright” in every case.

Another developer pointed out that this common mistake can be reduced by the simple expedient of making an empty NodePath (such as is returned by a failed find) evaluate to false. So I’ve just checked in the necessary code to do this, and it will presumably become a part of 1.6.0. This will make the code above behave as expected.

Of course, if you write code like this:

if magic.find("**/hand") != None:
  print "allright"

This change won’t help you. You do still need to be careful what assumptions you make about the return values of functions. :slight_smile:

David

Hey dudes thanks but still does´nt work

When i do:

if self.magik.find("**/casca"):
print “allright”
else:
print “Not Yet”

It´s all right ´cos the casca group exist. But when…

if self.magik.find("**/casca").node() != None:
print “Allright”
else:
print “still not yet”

i got the assertion error:

if self.magik.find("**/casca").node() !=None:
AssertionError: !is_empty() at line 269 of c:\p\panda3d-1.5.4\panda\src\pgraph\nodePath.I

And then the quest continues … :confused: I´m very confusing …[/b]

This Dart tag here blocks the search :

If it’s not an animated character, you can safely remove that tag.

Actually, as drwr pointed out, even if the node doesn’t get found it returns a NodePath object, and thus in all cases it will print out “allright”. You should use this instead:

if not self.magik.find("**/casca").isEmpty():
  print "allright"
else:
  print "Not Yet"

Perhaps the dart tag blocks the search indeed, as ynjh_jo pointed out.

hi dudes , i guess i´ve good news

i try this:

print self.magik.node()

it return “casca” … it´s allright. But self.magik is not a Model but a Actor (animed), then i:

    camera.setPos(0,-20,0)
    self.actor=Actor.Actor("models/magikCube",{"cmon":"models/animDead-cmon"})
    self.actor.reparentTo(render)
    self.actor.setPos(0,20,0)
    self.actor.loop("cmon")
    [b]self.actor.node().setIntoCollideMask(BitMask32.bit(0))[/b]

Okay !! Works :laughing:

In magikCube.egg i put away the collide tag created by myself.

It seens i try use a Actor like a Model and (i guess) this is the origin of all trouble. I compare my magikCube.egg and ralph.egg (from Roaming Ralph tutorial) and see the ralph got no … i guess this tag is only for static Models.

When i load a static model named Floresta.egg:

floresta=loadModel(“scenes/floresta”)
floresta.find("**/mato").node().setIntoCollideMask(BitMask32.bit(3)).show()

where “mato” is a group with defined runs fine!! :slight_smile:

Well that´s it. Thanks PandaPeople :wink:

Hello, I think I’m having a similar problem and still can’t manage to get it working.

I’m trying to attach a collisions to an actor. I’ve managed to do this fine with a static model (by taking out the { 1 } in the .egg file) but using the same method with an actor thats loaded with animation and interactivity doesnt work, it requires the tag to function correctly it would seem.

so ive got my actor:

self.glad = Actor.Actor("Game\spear\gladThrow")
    self.glad.reparentTo(self.cart2)
    self.glad.setPos(0,0,18)
    self.glad.setH(90)

and then in a collision function:

   self.playerCol = self.glad.find("**/GladiatorMesh")
    self.playerCol.node().setIntoCollideMask(BitMask32.bit(0))
    self.playerCol.show()

Many thanks

Collision structures aren’t supported within an animated model, at least not directly. If you really want animated collisions, you can load the collision structures separately, then expose the joints that should animate them, and parent the collision structures to the appropriate joint nodes.

David

Yeah I realised I could do something like that but hoped there was a better solution, thanks

Ok i’ve tried to implement using the method suggested above but can’t quite get it working.

I’ve got:

self.glad = Actor.Actor("Game\spear\gladThrow")
self.gladCol = Actor.Actor("Game\spear\gladCol")

...missing some code...

self.gladTest =  self.glad.exposeJoint(None, 'modelRoot', 'rightArm')
self.gladControl = self.glad.controlJoint(None, 'modelRoot', 'rightArm')

...missing some code...

self.gladColc = self.gladCol.find("**/GladiatorArm")
self.gladColc.node().setIntoCollideMask(BitMask32.bit(0))
self.gladColc.show()
    
#self.gladColc.reparentTo(self.gladTest)

gladCol and glad are essentially the same .egg file but I’ve removed the tag in gladCol and created the GladiatorArm collide group of the vertixes of the gladiator’s arm to create the collision mesh. This will successfully create a collision mesh of the arm. If i try to reparent it to the arm geometry (##self.gladColc.reparentTo(self.gladTest)##) I get ‘isEmpty’ error. Any way round this?

“isEmpty” means that one of the NodePaths involved in the operation is an empty NodePath. An empty NodePath is like a NULL pointer, it doesn’t have any data in it.

Two common ways to get an empty NodePath is as the result of a failed loadModel() operation, or as the result of a failed find() operation. So, it seems that you didn’t find the node you were looking for.

You can check node.isEmpty() after a find() operation to verify that the find was successful.

David

Could we make empty node paths evaluate to False? We can still have it a nodepath for backward compatability but overload stuff like emptyNP == False to be true just like [] {} are false.

Way ahead of you. This is already on the trunk, has been for a couple of weeks.

David