Hello. Can anyone tell me how to re-attach a NodePath
after the detachNode
function is called?
It’s simply done in exactly the same way as you attached it in the first place. There should be nothing terribly special for a NodePath that was “detached”–it should act pretty much like a NodePath that hadn’t yet been attached at all.
So should I do:
myNodePath = base.render.attachNewNode(myNodePath)
or
myNodePath.reparentTo(base.render)
?
The latter.
Then what is the former used for?
Generally speaking, I would say that it’s for attaching a node (not a NodePath) to a NodePath, and then gaining a new NodePath (that points to the original node) out of it.
NodePaths tend to be more convenient to work with than nodes, so it’s handy to get a NodePath that points to them when attaching them to the scene-graph.
For example, when creating collision-objects it’s not uncommon, I think, to manually create CollisionNodes. These by themselves aren’t NodePaths, just nodes. But one generally wants a NodePath, and so one attaches them via “attachNewNode”.
The words node and node path have now got confusing for me since I learned Panda3D . Anyway, thanks for the clarification.
Not a problem!
As to nodes and NodePaths, I go into this a bit in my tutorial, I think–perhaps the relevant lesson will be of help to you:
This should be in the “More panda resources” section of the panda manual!
Thank you!
As it happens, it is! It’s the first entry under “Panda3D Tutorial Series”, I believe.