accessing node returned through bullet picking


i am unsure how to access the node that’s returned by bullet’s picking routine.

basically I am aiming to pick a item with a mouse, and then dosomething like the item turn wireframe or print a label next to it. the picking works well. but i get an error message when trying to do anything with the returned node. the code i am using…

    def pick_object(self):
        # Get to and from pos in camera coordinates
        if base.mouseWatcherNode.hasMouse():
            pMouse = base.mouseWatcherNode.getMouse()
            pFrom = Point3()
            pTo = Point3()
            base.camLens.extrude(pMouse, pFrom, pTo)

            # Transform to global coordinates
            pFrom = render.getRelativePoint(, pFrom)
            pTo = render.getRelativePoint(, pTo)
            #print ("from is", pFrom)
            #print ("to is", pTo)
            result =, pTo)
            if result.hasHits() == True:

                print result.hasHits()
                print result.getClosestHitFraction()
                print result.getNumHits()

                for hit in result.getHits():
                    print hit.getHitPos()
                    print hit.getHitNormal()
                    print hit.getHitFraction()
                    print hit.getNode()
                    changeWire = hit.getNode()
                    #changeP = changeWire[1]
                    print ("hit is ", changeWire)

            return 0

and if i remove the comment from the setRenderModeWireframe line i get error of line 437, in pick_object
AttributeError: ‘libpandabullet.BulletRigidBodyNode’ object has no attribute ‘setRenderModeWireframe’

printing the node gives me

BulletRigidBodyNode spaceStation_node2 (1 shapes) static mass=0 [health] T:(scale 10)

but if i try select nodeName[1] i get

TypeError: 'libpandabullet.BulletRigidBodyNode' object does not support indexing

anyway to gain access this node? ultimately I’d like to attach a bounding box and label to it if clicked on. but first i need to be able to access it.

setRenderModeWireframe is a method of the class NodePath. NodePath is a lightweight handle to a node.

But hit.getNode() returns a node, that is a BulletRigidBodyNode which is derived from PandaNode.

You need to wrap the PandaNode with a nodePath:

node = hit.getNode()
np = NodePath(node)

that exactly solves it. thank you very much!