FindChild()

Blitz3D Forums/Blitz3D Programming/FindChild()

Jerome Squalor(Posted 2007) [#1]
Hey everyone can someone give me an example of how to use the FindChild() command.
My main problem is i can't figure out what i'm supposed to put for the second parameter.


Gabriel(Posted 2007) [#2]
The name of the child you're trying to find. It's case-sensitive, if I recall correctly.


Mortiis(Posted 2007) [#3]
Player = LoadAnimMesh("Player.b3d")
PlayerRightHand = FindChild(Player,"RightHandBone")


It's case sensitive. You can use it to retrieve bones or childs to animate them seperately or just to attach them some objects like swords.


Jerome Squalor(Posted 2007) [#4]
where do you get the name of the child entity though?


Dreamora(Posted 2007) [#5]
In your modelling application where you named them or by iterationg through the childs using countChilds() etc


Jerome Squalor(Posted 2007) [#6]
so does the findchild become an entity that can be edited individually?


Rob Farley(Posted 2007) [#7]
It does if you go:

L_Arm = FindChild(MyMesh,"LeftArm")

Then you have a new entity of L_Arm which is parented to MyMesh


Jerome Squalor(Posted 2007) [#8]
that's what i'm doing but when i do any of rthe entity commands on it it says it doesn't exist.


Dreamora(Posted 2007) [#9]
Then you looked for a child that did not exist or is not a child to this entity.

Did you use LoadAnimMesh?
LoadMesh will remove any hierarchy.


Mortiis(Posted 2007) [#10]
Dreamora is right, I've been using LoadMesh as my boned meshes didn't have any animation, I was just using the bones for particle placement. So they didn't work until I find I had to use LoadAnimMesh command.

By the way, use b3d viewer to see the bones in your mesh. It's way easier than anything else.

Here is the b3d viewer; http://www.blitzbasic.com/Community/posts.php?topic=72765#813477


cash(Posted 2007) [#11]
Kip
I used to have issues with this as well and what the guys above saying is correct.

findchild looks for the name of a joint on a mesh.

Example

If I create a model im Milkshape then the names in the model cannot be found as individual entities as Milkshape only exports a single ROOT entity. However if I add joints and name them logically. Like leftwrist then assign the relevant vertex`s to the joint I can use the findchild command to locate and work on this joint within code.

You need to load the model with loadanimmesh
then use Lwrist=findchild(modelname,"leftwrist").

You may need to use global infront if it is outside the main loop.

Once this is done you should not get any errors.

Next thing is to make sure any action performed on the joint
is carried out after Updateworld and before Renderworld else it wont show.

Hope this helps.