Creating custom PandaNode


I have currently created a python class containing som geometry, plus some other functionality.
To render the geometry I use myObject.model.reparentTo(render), which works well for the time being.

The problem is that I want to randomly generate some geometry by generating objects of my class, which means I will lose the references to the objects.
I can find the geometry trough the collisions, but not the object and the needed functionality.
I’m thinking of making my class a subclass of a PandaNode, so that I can just write myObject.reparentTo(render), and get a nodepath to my object by finding the geometries parent from a collision.

What class should I inherit from? (I’m a bit confused about what classes are python, and what is C++, and kind of a newbie to python…)
Will I have to do something more to get a reference to a object of my class, once I have the nodepath? If I just get some kind of PandaNode, it doesn’t help unless I can cast it to my class…

Please help.



from pandac.NodePath import NodePath

class myNodePath(NodePath):

    def __init__(self,model):

That class would inherrit all the properties from NodePath, which I think is what you need.

To keep referrences to your object, you could store them all in a dictionary:

d[myObject] = myObject

then just retreive them as:

myObject = d[selectedObject]

Hope this helped.

Thanks a lot! :smiley:
I will try the dictionary. I just hope it doesn’t slow things down if it gets insanely big…