Collisions

How do I use the object called mesh_coll.egg instead of a collision sphere for the colliders for mesh.egg?

from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import * 
import sys, time
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import AmbientLight, DirectionalLight, PerspectiveLens, Spotlight
from pandac.PandaModules import TextNode, TransparencyAttrib, Vec3
from direct.task import Task
from direct.gui.OnscreenImage import OnscreenImage
from direct.gui.OnscreenText import OnscreenText
from direct.interval.IntervalGlobal import *
 
class MyApp(ShowBase):
 
    def __init__(self):
        ShowBase.__init__(self)
        
        #initialize traverser
	base.cTrav = CollisionTraverser()

    #initialize pusher
	pusher = CollisionHandlerPusher() 
	
	eggcollider = loader.loadModel('/home/benn/Games/mesh_coll.egg')
	eggcollider.reparentTo(render)
	eggcollider.setPos(0.5, 40, 0.5)

	box = loader.loadModel('/home/benn/Games/mesh.egg')
	box.reparentTo(render)
	box.setPos(0.5, 20, 0.5) 
	
	boxcnode = CollisionNode('box')
	boxcnode.addSolid (CollisionSphere(0.5, 20, 0.5, 7)) 
	
	boxn = box.attachNewNode(boxcnode) 
	boxn.show()
	
	
	box1 = loader.loadModel('/home/benn/Games/Physics/box.x')
	box1.reparentTo(render)
	box1.setPos(15, 50, 0.5)
	
	
	boxcnode1 = CollisionNode('box1')
	boxcnode1.addSolid (CollisionSphere(15, 50, 0.5, 7))  
	
	boxn1 = box1.attachNewNode(boxcnode1) 
	boxn1.show()    
	
	
	base.cTrav.addCollider(boxn1,pusher)
	pusher.addCollider(boxn1,box1, base.drive.node())     
        
 
    
        
         
app = MyApp()
app.run()

Thanks,
Benn

Anyone???

Here is the files:

4shared.com/file/z534amO4/test.html

I alsoways convert stuff from geometry to

panda3d.org/apiref.php?page=CollisionPolygon s before using them in collisions other wise panda has to do it every frame or so.

This fellow was helped on IRC, so the original question isn’t up to date anymore.

NEXT!

:slight_smile: