Collision in Egg Files - Errors

Ok still having problems with Collisions in Egg Files

My Code:

<Group> TreeTrunk {
  <Collide> TreeTrunkcoll { 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 }
    }

And

    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("**/TreeTrunkcoll")

	cNode = CollisionNode('TreeTrunk')
	cNode.addSolid(CollisionSphere(0,0,0,1.1))
	CNodePath = TreeTrunk.attachNewNode(cNode)
	cNodePath.setIntoCollideMask(BitMask32.allOff())
	cNodePath.show()


    # end EnvironmentCollide

Produces

C:\testgame>ppython main.py
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(3 aux display modules not yet loaded.)
Assertion failed: _error_type == ET_ok at line 488 of panda/src/pgraph/nodePath.
cxx
Traceback (most recent call last):
  File "main.py", line 195, in ?
    w= World()
  File "main.py", line 35, in __init__
    self.EnvironmentCollide()
  File "main.py", line 186, in EnvironmentCollide
    CNodePath = TreeTrunk.attachNewNode(cNode)
AssertionError: _error_type == ET_ok at line 488 of panda/src/pgraph/nodePath.cx
x

Even when I edit the code and do get into the game, I can’t see the collision nodes that are set up, so somewhere something is not being picked up.

(oh and btw

self.environ = loader.loadModel("Environments/Environment.egg")

loads the environment)

Please help! I don’t think it can take this much more – I’ve tried and tried but can’t get it working! :imp: :imp: :imp:

Tony

Try to change it to be :

<Group> TreeTrunk { 
  <Collide> TreeTrunk { polyset keep } 

and

   # this tells panda its a geom collision node 
   TreeTrunk = self.environ.find("**/TreeTrunk")

Check this again :

   CNodePath = TreeTrunk.attachNewNode(cNode) 
   cNodePath.setIntoCollideMask(BitMask32.allOff()) 
   cNodePath.show()

Look, you haven’t set the collision bitmask for it.

e.g


cNodePath.setIntoCollideMask(BitMask32.bit(1))

Udated code as above so now i have:

	cNodePath = TreeTrunk.attachNewNode(cNode)
	cNodePath.setIntoCollideMask(BitMask32.bit(1))
	cNodePath.show()

but get the error:

C:\testgame>ppython main.py
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(3 aux display modules not yet loaded.)
Traceback (most recent call last):
  File "main.py", line 198, in ?
    w= World()
  File "main.py", line 35, in __init__
    self.EnvironmentCollide()
  File "main.py", line 187, in EnvironmentCollide
    cNodePath.setIntoCollideMask(BitMask32.bit(1))
AttributeError: 'libpanda.NodePath' object has no attribute 'setIntoCollideMask'

HELP!

Try this :

cNodePath = TreeTrunk.attachNewNode(cNode) 
cNodePath.node().setIntoCollideMask(BitMask32.bit(1)) 
cNodePath.show()

Thanks for this,

but whilst it is working now, i still cannot see any sort of node around the treetrunk and can still walk through it (although to be honest getting the mode working first is my main priority!)

Hey, sorry, I made mistakes.

The setIntoCollideMask() should be applied to collision node itself. So the correct thing is :

cNode = CollisionNode('TreeTrunk') 
cNode.addSolid(CollisionSphere(0,0,0,1.1))
cNodePath = TreeTrunk.attachNewNode(cNode) 
cNode.setIntoCollideMask(BitMask32.bit(1)) 
cNode.show()

But, if you’re about to make your walking character stop when hit the environment, why do you use the collision sphere for the environment ?
You can just set the whole environment to collide with the character, coz the environment only consist of simple polygons.


TreeTrunk.setCollideMask(Bitmask32.bit(1))

About still walking through it :
have you create and set the from-node to collide with the into-node ?
The from-node and the into-node must have at least 1 bit in common, so that they are ‘visible’ to each other. In this case, you must set the bit(1) for the from-node. You must parent the from-node to your walking character. The next thing, you must check the collision entries, whether there are collisions, and then decide what will happen next. Will the character simply stop, or slide to the side. You may want to use the pusher traverser instead. But regarding to my own experience using pusher, sometimes the from-node passes through the into-node, even after using the setFluidPos() and setRespectPrevTransform(True).

Read this manual :
http://www.panda3d.org/manual/index.php/Rapidly-Moving_Objects

I believe you ever posted the same problem with the same case, the environment model, in HERE.