entitycolor(a,#,#,#) for all children entities

Blitz3D Forums/Blitz3D Beginners Area/entitycolor(a,#,#,#) for all children entities

Which method would you use to color 0,0,0 an entity and all of its children?

Perhaps a recursive function ?
function setcolor(ent, r, g, b)
 for i = 1 to countchildren(ent) - 1
   setcolor getchild(ent, i), r, g, b
 next
 entitycolor ent, r, g, b
end function


It should be

for i = 1 to countchildren(ent)


Of course the children can also have children, so I use a recursive routine:

;-------------------------------------------
Function EntityColor_(mesh,r,g,b)
;-------------------------------------------
Local i,ww

If mesh<>0
If EntityClass$(mesh)="Mesh"
EntityColor mesh,r,g,b
EndIf
For i=1 To CountChildren(mesh)
ww=GetChild(mesh,i)
EntityColor_(ww,r,g,b)
Next
EndIf
End Function