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

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

RGF(Posted 2008) [#1]
Which method would you use to color 0,0,0 an entity and all of its children?


Warner(Posted 2008) [#2]
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



Stevie G(Posted 2008) [#3]
It should be

for i = 1 to countchildren(ent)



John Blackledge(Posted 2008) [#4]
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