Location of collision

Hi, i have a basic collision system working between the mouse pointer and a 3d object. I would like to know the point in space where the 3d object and mouse ray intersect. What class/method would I use to find this information? I tried the collision traverser getCollider method but it returns a collision node that has an x,y,and z location of 0.

Thank you!

You need to get position of thing relative to some object like render or like the intoNode.

panda3d.org/manual/index.php/Collision_Entries

point = collisionEntry.getSurfacePoint(collisionEntry.getIntoNodePath())

what you’r looking for is called “picking” 3d objects. there are many forum threads about it. there is also an example amongst panda’s sample which demonsrates this.

it boils down to doing collisions, as you may have done already. then there are collisionentries (in your collision queue). you can querry those for the position of the collision aswell as the surface-normal of the contact point.

Collision entry! Yes, that’s what I was hoping to find!

Thank you so much!

I have some sample code here for a ray intersecting with the shoe model. The model is tagged correctly in the egg file and the collision shows up in 3d, but the collision handler doesn’t seem to pick up on the event. The direct object does not call the in or out collision event functions. I think this is where my code is broken:

pickerNode=CollisionNode('mouseraycnode')
pickerNP=base.camera.attachNewNode(pickerNode)
pickerRay=CollisionRay()
pickerNode.addSolid(pickerRay)
base.cTrav.addCollider(pickerNP, collisionHandler)
base.cTrav.showCollisions(render)


shoeModel = loader.loadModel('models/shoe1_collide')
otherModel = loader.loadModel('models/shoe1')
otherModel.reparentTo(render)
otherModel.setPos(0,2,0)
shoeModel.reparentTo(render)
shoeModel.setPos(0, 2,0)
shoeNode = CollisionNode('shoecnode')
shoeCollider = shoeModel.attachNewNode(shoeNode)
base.cTrav.addCollider(shoeCollider, collisionHandler)

I have copied the code from a collision example that adds in and out patterns to the collision handler and a direct object to accept collision events.