Totally forgot how to do this. I'm working on a mock up POW/MIA memorial and want to keep everything in one .b3d file.
Anyone remember how to access children in a .b3d model?
My_level=LoadAnimMesh("Memorial.B3D")
Child=FindChild(My_level,"Child_I_AM_Looking_For_Name")
You may also use CountChildren and GetChild.
Naughty Alien...that's why I'm posting. That doesn't work...
I'll give GetChild and CountChildren a shot. Thanks.
Mr. Naughty will help...and if this not work, then somethings very wrong with your B3D file..
Const recursive_resize=1024
Global recursive_bank=CreateBank(recursive_resize),recursive_size=recursive_resize
Global recursive_entity,recursive_parent,recursive_id,recursive_start,recursive_total,recursive_offset
Graphics3D 1280,1024,32,1
camera=CreateCamera()
PositionEntity camera,150,90,150
mesh=LoadAnimMesh("My_Mesh.b3d")
Child=findchildentity(mesh,"Name_Of_The_Child_I'm_Looking_For")
PointEntity camera,child
While Not KeyDown(1)
UpdateWorld()
RenderWorld
Flip
Wend
End
Function findchildentity(entity,name$)
name$=Lower$(name$)
recursive_parent=entity
recursive_start=1
recursive_offset=0
.recursive_label
recursive_total=CountChildren(recursive_parent)
For recursive_id=recursive_start To recursive_total
recursive_entity=GetChild(recursive_parent,recursive_id)
If name$=Lower$(EntityName$(recursive_entity))
Return recursive_entity
Else
If recursive_offset+8 > recursive_size-1
ResizeBank(recursive_bank,recursive_size+recursive_resize)
recursive_size=recursive_size+recursive_resize
End If
PokeInt(recursive_bank,recursive_offset,recursive_id+1)
PokeInt(recursive_bank,recursive_offset+4,recursive_parent)
recursive_offset=recursive_offset+8
recursive_start=1
recursive_parent=recursive_entity
Goto recursive_label
End If
Next
If recursive_offset=0
Return 0
Else
recursive_start=PeekInt(recursive_bank,recursive_offset-8)
recursive_parent=PeekInt(recursive_bank,recursive_offset-4)
recursive_offset=recursive_offset-8
Goto recursive_label
End If
End Function
I had a similar problem only to find that because I was using Milkshape, you could only find the joint and not parts of the model.
Apparently Milkshape exports as a single root file for the mesh although the joints are "findable" and manageable.
Something like that anyway.