linking objects

Hey guys, I’ve got a question about how to best connect Panda3D objects with objects I’ve written myself.

I’m writing a library to handle logic and infrastructure for my game world. I’m now at a point where I need to connect Panda3D to my world engine, if you can call it that (still early development). Say I have a class Person(). What’s the best way to link a Panda3D Actor to a Person() instance?

I thought I remembered there being some extra field in PandaNode or Actor (or somewhere) that you could use for whatever you want, but I can’t seem to find it in the manual. The best thing would be if I can have a direct link so I can call something like pandaActor.getPerson() or pandaActor.extraField or whatever.

If that’s not possible, what is the recommended way to handle this (if there is one)? I’ve thought of a few workarounds, but a direct link would be optimal.

I’m also just curious how other people deal with this. It must be a common issue, right?

You can use setPythonTag to store an arbitrary Python object on a NodePath or PandaNode. (As Actor inherits from NodePath, it will work on Actor as well). If you search the website/forums for setPythonTag, it will show up many results.

I do it the opposite way. I simply store the panda node(s) in attributes of my class.
The class is where I create the Panda nodes so it works out pretty well.
Ex:

self.model = Actor()
self.model.loadModel('models/spider_food')

Thanks for the quick replies. I think setPythonTag() is what I was looking for.