Attaching one mesh to another with animation?

Blitz3D Forums/Blitz3D Beginners Area/Attaching one mesh to another with animation?

TheSkyIsUp(Posted 2009) [#1]
I need help.

I want to load an animated mesh, then attach other meshes to parts of it, and have it move along with the animation. For example: Say I made a human character with a walking animation, then I wanted to put a glove on the character's hand. I'd want that glove to stay on the hand even though the hand is moving through an animation.

I planned to try this by positioning the mesh I want attached at a vertex on the animated mesh with the Vertex X, Y, and Z commands, but for some reason those commands don't seem to take other frames of the mesh into account. The mesh is only placed where the vertex should be in the main frame of the animated mesh...

So my question is. How can I attach or position one mesh on another mesh and have it follow alone in the animation as if they were both the same mesh? How can I 'put the glove on the hand'?


Matty(Posted 2009) [#2]
Parent the glove to the 'bone' in the hand.
You will need to use findchild / getchild to get the relevant bone, and may need to do so recursively if the bone itself is a child of another bone (most likely).

Note however, if the fingers in the hand flex / bend then the glove which is parented to the hand bone will not.

If the glove's fingers need to flex/follow the fingers on the base mesh then an alternative is to model the glove also to have animation based on the animation sequences of the fingers, then parent as above, and animate glove as well


TheSkyIsUp(Posted 2009) [#3]
I see. So bones are child's of other bones and the root bone is the child of the mesh? So I have to find the child of the mesh to find the first bone, then find the child of that bone, and keep doing that how ever many times needed until I find the hand bone. Right?

Thanks, I'll try that. I'll come back here if I need more help.

EDIT: I just tried it out, it works perfect for what I need. Thanks again.


PowerPC603(Posted 2009) [#4]
If you know the name of the bone (you can set a name in your modelling tool), you can use FindChild on your animated model.
Then you don't have to search the children of your model to find it yourself.


TheSkyIsUp(Posted 2009) [#5]
Cool, I'll try that too.


jfk EO-11110(Posted 2010) [#6]
As far as I remember the entity handle of an AnmMesh is not the mesh itself. The mesh of an animated mesh entity is on the 2nd level of the hierarchy. I think the top level is only a pivot. This is why you cannot use Mesh commands on an animated Mesh, but you have to parse the children recursively and apply it to all chldren of type "Mesh".

This may also vary between animated B3D and 3ds/x.

See also EntityClass$(entity).

global s=1
...
Function EntityInfo(m)
 Print string$("-",s) + EntityClass$(m) + " : " + Entityname$(m)
 For i=1 to CountChildren(m)
  s=s+1
  ww=GetChild(m,i)
  EntityInfo(ww)
 Next
 s=s-1
End Function



Kryzon(Posted 2010) [#7]
As far as I remember the entity handle of an AnmMesh is not the mesh itself. The mesh of an animated mesh entity is on the 2nd level of the hierarchy. I think the top level is only a pivot. This is why you cannot use Mesh commands on an animated Mesh, but you have to parse the children recursively and apply it to all chldren of type "Mesh".


You can change that (with the B3D Pipeline at least).

If you link every element in the scene to the mesh, the "Scene Root" checkbox in the exporter dialog will be active and you can uncheck it, thus making the mesh your "scene root".

When you load this animmesh, the handle will be the mesh directly.