collisions in egg files

Hi guys

The first cry for help!

I’ve looked through the forum and couldn’t find an answer to this so am posting this problem here.

I’m trying to set up collision nodes within my environment to stop my character walking through trees and things.

I’ve edited my environment.egg file as below (only the code that matters I’ve included!):

<Group> TreeTrunk {
  <Collide> TreeTrunkCollision { polyset keep }
  <VertexPool> TreeTrunk.verts {
    <Vertex> 1 {
      21.4707 -78.7459 0.0441827
      <Normal> { 0.461362 0.0371902 -0.0615218 }
      <UV> { 0.726553 0.0298222 }
    }

I’m using this code below in the main file (again, only the code that matters I’ve included!):

	# Load an environment 
	self.environ = loader.loadModel("Environments/Environment.egg") 
	self.environ.reparentTo(render)
	self.environ.setScale(0.25,0.25,0.25)  
	self.environ.setPos(-8,42,0)


    def EnvironmentCollide(self):

	#This sets up the collisions as edited in the environment.egg file

	# this tells panda its a geom collision node
	TreeTrunk = self.environ.find("**/TreeTrunkCollision")
	# Set the collision bit in the IntoCollideMask
	TreeTrunk.node().setIntoCollideMask(BitMask32.bit(0))

    # end EnvironmentCollide

And I’m getting this error:

Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(3 aux display modules not yet loaded.)
:display:windisplay(warning): SetForegroundWindow() failed!
Assertion failed: !is_empty() at line 270 of c:\temp\mkpr\panda3d-1.2.1\panda\sr
c\pgraph\nodePath.I
Traceback (most recent call last):
  File "main.py", line 190, in ?
    w= World()
  File "main.py", line 35, in __init__
    self.EnvironmentCollide()
  File "main.py", line 185, in EnvironmentCollide
    TreeTrunk.node().setIntoCollideMask(BitMask32.bit(0))
AssertionError: !is_empty() at line 270 of c:\temp\mkpr\panda3d-1.2.1\panda\src\
pgraph\nodePath.I

It looks like the names of everything is ok and that I’m calling the right things in the right places, so I don’t quite get it to why it is claiming that it is empty.

I’m assuming that the way the above code works is it looks in the environment.egg file for matches of the collisionnode and sets it up as a collision (and apologies if that makes no sense or is explained poorly)

I have no doubt as usual I’ve named one thing wrong, but any help is appreciated!

Tony

I think find() looks for the group tag name, not the collide tag name.


TreeTrunk = self.environ.find("**/TreeTrunk") 

if you still are having problems, change the tag to TreeTrunk { polyset keep } to match the name

Russ i tried that and whilst it loads now i can still walk straight through the tree

any more ideas? something else must be wrong!

Just a few may stupid questions to think of:
*) did you check for the collisions for every movement of your model
*) did you setup your model as a from object?

You have to setup a from object, in your case this would be a playermodel and into objects. Seting up from objects means to setup collision handlers, traversers,…
Then you can check for any occured collisions.

Martin

Also, I don’t see any mention base.cTrav or any other traverser in the code. Are the collision solids being traversed? Check the manual on how to do this, or there is a well documented collision tutorial in the samples folder.

oh right didn’t realise that. thought the above code done it automatically :blush:

i’m building on my example game (found at discourse.panda3d.org/viewtopic.php?t=1421)

i already have collision nodes set up, but some advice on the best way to do this would be great, as i’m a bit stuck and confused now!

thanks again.

The manual has almost exactly what you need:

http://www.panda3d.org/manual/index.php/Collision_Handlers
go to the part that talks about CollisionHandlerPusher.
there is also an example here:
http://www.panda3d.org/manual/index.php/Pusher_Example

All of that gives a better explanation than I would be able to in a forum post.

You will need to create a collision sphere around the character that moves. Then you will need to add that character to the pusher.