Entity Child Recursive Search

Blitz3D Forums/Blitz3D Programming/Entity Child Recursive Search

Craig H. Nisbet(Posted 2004) [#1]
Anyone have any good code for finding all the children of an entity, and their children?


BlackD(Posted 2004) [#2]
type child
field child ;yes you can do this
end type

if countchildren(entity)>0 then
    for childcount = 1 to countchildren(entity)
        child=getchild(entity,childcount)
            if child>0 then
                 for i = 1 to countchildren(child)
                      entity.child = new child
                      entity\child=getchild(child,i)
                      next
                 end if
        next
    end if
untested. At work :(

+BlackD


Difference(Posted 2004) [#3]
Here is one way
Function core()
	; do it here
End Function


Function doMesh(m,xoff#,yoff#,zoff#)

	Local c
	Local childcount=CountChildren(m)
	
	If childcount
		For c=1 To childcount
			core m,xoff#,yoff#,zoff#
			doMesh GetChild(m,c),xoff#,yoff#,zoff#
		Next
	Else
		core m,xoff#,yoff#,zoff#
	EndIf
End Function



Beaker(Posted 2004) [#4]
This is my very handy solution (to many things):
http://www.blitzbasic.com/codearcs/codearcs.php?code=796