I am developing a game with Panda3D using mostly Python but for some processor intensive code(path finding), i think it would be a better idea to use C++. I am just looking for a simple way to write some code in C++ and use it from within my Python files. I have searched online and on the Panda3D site but could not find anything that works for me.
Any help regarding this task would be greatly appreciated. Thanks.
I do not need to use the Panda3D code within my C++ code. I just want a way to use a C++ .dll or something similar so that I can pass an argument from a Python file to a C++ method and get something returned back to me.
Others know better than me when it comes to C++ and Panda, and I’m sure you’ll get a response from them. But, if you just have a couple of functions that you want to accelerate you could consider weave http://www.scipy.org/Weave - no idea if it plays nice with Panda, but I can’t see why not.
There are many, many tools, which have nothing to do with Panda, which are all useful to integrate C and C++ code with Python. To my knowledge, all of them play nice with Panda. In addition to the above-mentioned link, you might also be interested in swig or even the ctypes module in Python. Not to mention pyrex. If you don’t like any of these options, you can find a host more simply by Googling “Python C”.
Finally, you can follow the example laid out in the “skel” source directory within Panda, to use Panda’s existing tools to wrap C++ with Python wrappers. This is particularly useful if you want to make a call into one of the Panda C++ methods from your wrapped functions. But it may not be the easiest of your options.