reparenting the Camera

so in my code i wrote:

root is a moving object. the camera moves with it.

then somewhere else i wrote

the camera didn’t change position.
I did this just to try it out. It’s weird.
The way i see it is that once you assign a parent to the camera you can’t change it unless you add some other code.

You can reparent whenever you want. If it didn’t change position, it must have had a position of (0, 0, 0) relative to its parent.

so i can’t reparent whenever i want…
can u tell me more? or a link?

I said that you can reparent whenever you want. I don’t have a link other than the manual page about the Scene Graph.

well thx.
ill try to figure it out by reading the scene graph page.


I think maybe like rdb said, that your camera is positioned at 0,0,0; when you attached that to a moving node the camera view results are transformed by the moving node’s transform, if you then remove your camera that has its own transform ( still pos at 0,0,0 ) and attach it to another node, it will only be transformed by that new parent’s transformation matrix.
Transformation matrices will combine down the family tree.

If you want your camera to remain where it was last when attached to the moving node, I think you need to camera.setPos(root.getPos()); that is if you are reparenting to render which is positioned at 0,0,0