Thank you all for your great help! As you surly observe: I am a bloody beginner with the framework.
Sorry @maxxim that I was not able to state my problem so that you can understand it. I give it a new try.
I created an example: https://github.com/tom-010/panda_python_cpp_call
To summarize the repo:
The python part (from the onboarding tutorial; walking panda)
# see onboarding tutorial on the website
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.scene = self.loader.loadModel("models/environment")
self.scene.reparentTo(self.render)
self.scene.setScale(0.25, 0.25, 0.25)
self.scene.setPos(-8, 42, 0)
self.taskMgr.add(self.spinCameraTask, "SpinCameraTask")
# self.addPandaVaiCpp() How?
# Instead:
self.addPanda()
def addPanda(self):
self.pandaActor = Actor("models/panda-model",
{"walk": "models/panda-walk4"})
self.pandaActor.setScale(0.005, 0.005, 0.005)
self.pandaActor.reparentTo(self.render)
self.pandaActor.loop("walk")
def addPandaViaCpp(self):
pass # How? <---------------------------------
def spinCameraTask(self, task):
.... # see onboarding tutorial on website
app = MyApp()
app.run()
The same example (the walking panda) in C++
// ... see onboarding tutorial on the website
// I want to call this method from python
// The interface does not matter as long it works functionally
void addPanda(PandaFramework& framework, WindowFramework *window) {
// Load our panda
NodePath pandaActor = window->load_model(framework.get_models(), "models/panda-model");
pandaActor.set_scale(0.005);
pandaActor.reparent_to(window->get_render());
// Load the walk animation
window->load_model(pandaActor, "models/panda-walk4");
window->loop_animations(0); // bind models and animations
//set animations to loop
}
// ... see onboarding tutorial on the website
int main(int argc, char *argv[]) {
// ... see onboarding tutorial on the website
addPanda(framework, window);
// ... see onboarding tutorial on the website
framework.main_loop();
// ... see onboarding tutorial on the website
}
So the concrete question: How to implement the python method
def addPandaViaCpp(self):
pass # How?
that it calls this C++ function?
void addPanda(PandaFramework& framework, WindowFramework *window) {
NodePath pandaActor = window->load_model(framework.get_models(), "models/panda-model");
pandaActor.set_scale(0.005);
pandaActor.reparent_to(window->get_render());
window->load_model(pandaActor, "models/panda-walk4");
window->loop_animations(0);
}
The signature in the last listing describes my problem. How to get a reference/pointer for (PandaFramework& framework, WindowFramework *window)
and how to call the function?