Ok, it seems like I’m getting somewhere with @serega-kkz’s suggestion.
I added more functionality for the cycle to do what it should actually do:
def switch_cameras():
if self.index_active_camera < len(self.list_cameras)-1:
self.index_active_camera += 1
else:
self.index_active_camera = 0
# Set the active camera
current_camera = self.list_cameras[self.index_active_camera]
self.camera.reparentTo(current_camera)
# Update the camera used for rendering
dr.setCamera(current_camera)
self.list_cameras = [self.cam, self.camera2, self.camera3]
self.index_active_camera = 0
self.accept('o', switch_cameras)
But the error I’m now getting is:
Assertion failed: Detected attempt to create a cycle in the scene graph: render/cam3/camera/cam : ModelNode camera at line 2637 of panda/src/pgraph/pandaNode.cxx
Assertion failed: reparented at line 406 of panda/src/pgraph/nodePath.cxx
Traceback (most recent call last):
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 49, in eventLoopTask
self.doEvents()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 43, in doEvents
processFunc(dequeueFunc())
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 99, in processEvent
messenger.send(eventName, paramList)
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/Messenger.py", line 337, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/Messenger.py", line 422, in __dispatch
result = method (*(extraArgs + sentArgs))
File "/home/user/panda3d/winter/test/shape.py", line 311, in switch_cameras
self.camera.reparentTo(current_camera)
AssertionError: Detected attempt to create a cycle in the scene graph: render/cam3/camera/cam : ModelNode camera at line 2637 of panda/src/pgraph/pandaNode.cxx
:task(error): Exception occurred in PythonTask eventManager
Traceback (most recent call last):
File "/home/user/panda3d/winter/test/shape.py", line 361, in <module>
app.run()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/ShowBase.py", line 3331, in run
self.taskMgr.run()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/task/Task.py", line 553, in run
self.step()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/task/Task.py", line 504, in step
self.mgr.poll()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 49, in eventLoopTask
self.doEvents()
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 43, in doEvents
processFunc(dequeueFunc())
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/EventManager.py", line 99, in processEvent
messenger.send(eventName, paramList)
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/Messenger.py", line 337, in send
self.__dispatch(acceptorDict, event, sentArgs, foundWatch)
File "/home/user/panda3d/winter/test/.venv/lib/python3.10/site-packages/direct/showbase/Messenger.py", line 422, in __dispatch
result = method (*(extraArgs + sentArgs))
File "/home/user/panda3d/winter/test/shape.py", line 311, in switch_cameras
self.camera.reparentTo(current_camera)
AssertionError: Detected attempt to create a cycle in the scene graph: render/cam3/camera/cam : ModelNode camera at line 2637 of panda/src/pgraph/pandaNode.cxx
It works the first 2 times, but once I start the cycle over on the third ‘o’ press, I get this error that I’m making a cycle. Are either of you familiar with this?