www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: nathan on April 11, 2013, 12:40:47 am

Title: Child/Parent relationship
Post by: nathan on April 11, 2013, 12:40:47 am
Why is there no method like
Code: [Select]
Object3D[] getChildren()but there is
Code: [Select]
Object3D[] getParents()
I have a group of objects (From another example, it is a car and its 4 wheels).  I want them all to move together, so I add them as children to another object, which is a collision mesh.  And, now I would like to pass the reference to the outer object around, and change all the children simultaneously.  For instance, I want to change visibility, or remove them from the world.

All I can think of doing is extend the Object3D class, override the addChild() function to also add the child to a list.  Then add a getChildren() function that just returns that list as an array and use this in my own functions. 

I just don't understand why there is no getChildren() function?
Title: Re: Child/Parent relationship
Post by: EgonOlsen on April 11, 2013, 07:48:02 am
Because there's no cyclic reference. A child knows its parent(s). A parent has no idea about its child(s). If you need that, you can extend Object3D and add it yourself.
Title: Re: Child/Parent relationship
Post by: nathan on April 11, 2013, 07:13:06 pm
Thank you,
I will do just that