To better understand how children inherit properties from their parents, we're going to add two more models to our scene and see how they mingle.
We need to add six more lines of code to our file in order to load two more models, add them to the Scene Graph, and position them in view:
Save the file as "
chp02_07.py
" and run it.The cycles look like white blobs because they are untextured and unlit. We don't need to worry about that right now. Next, let's parent the second cycle to the first, instead of to
render
. Change line 13 toself.cycle2.reparentTo(self.cycle1).
Save the file as "
chp02_08.py
" and run it.
Notice how the left cycle changed position. This is because child NodePaths
inherit the coordinate system of their parent. That means that originally, when it was a child of render
, the left cycle was positioned at (-2,15,0), relative to render
. When we changed the parent, the left cycle moved to (-2,15,0) relative...