Getting a possible parentwithout getting an error
Blitz3D Forums/Blitz3D Programming/Getting a possible parentwithout getting an error
| ||
Hi, I want to camera pick a animated entity. I have recursed the mesh and set the pickmode on all the peices. Problem is, i need to find a way of returning the top of the tree and returning the master parent for the picked entity. I kinda assumed (foolishly) that the getparent() command would return a zero if no parent was available but it generates a entity not found. Anyone know of another command or (must be very fast) routine for finding the master mesh of a hireachy (without recursing every child of every single mesh in ram to see if its there? This is what i wanted to do: Function GetTopOfTree(child) parent=child Repeat par=GetParent(child) If par parent=par Until not par Return parent End Function |
| ||
A non-recursive way would be to store the master mesh in every child meshes entityname ... nameentity( child , mastermesh ) Then straight away you know the master by ... mastermesh = entityname( child ) Obviously this would be screwed if you already used the entityname for something else. Stevie |
| ||
You keep on finding the parent of the entity passed to the function...Do it like this:Function GetTopOfTree(child) parent = child par = GetParent(child) While par parent = par par = GetParent(parent) Wend Return parent End Function |
| ||
When did getparent() become a command? |
| ||
not sure, version1.9 i think Fredborg, hats off 2 u! That seems to work. silly me |