CollisionPolygon

Greetings.

I was reading in the Manual where it said a model could be used as a CollisionPolygon (which is better than defining it by codes).

Code wise, how would you tell Panda that a model file/model should be used as a CollisionPolygon?

You can add a “” tag to the .egg file to indicate that geometry should be loaded as collision polygons.

Look up the egg documentation (panda/src/doc/eggSyntax.txt in the source) for more information.

Wouldn’t it be the same thing if I just did this?

self.CollideGeom.setCollideMask(BitMask32(0x01));

No, that’d collide with the visible geometry instead, which is slower than colliding with CollisionPolygons.

I keep getting a non displaying page for panda/src/doc/eggSyntax.txt.

I’m guessing the tag insertion for an egg file is done on export somehow?

There’s no simple way, like tacking on to the file path during exporting with Chicken, like:

/game/collsionmods/collision1.egg <Collide>

or does it have to been done by opening up the exported .egg file into some editor and manual inserting some info?

I am using the Chicken Exporter…if that helps.

Yeaahhhh!!! Figured it out!!! It can be done usin g the Chicken Exporter! Thanks for the Tip Off RDB!

Now I have to go back and change all the visible geometry to the collision polygon (sigh).

I just hope this means even more game speed…please tell me it will mean more game speed RDB…or someone? :frowning:

Lol

UPDATE======================

I made some of the changes and tested the Frame Rate with v-sync off to see if it was much higher. To my delight it was much higher. :smiley:

Can’t wait to see what the fps looks like after I’ve made all the changes. I’m using a good system to develop this app, so keeping the fps around 100 means alot. so far so good.

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()