I agree with all the other responders: to attach a weapon to the avatar’s hand, you should create an attachment node for the hand bone and attach the weapon model to the attachment node. This is the usual way, the easy way, the quick way, the way JME’s designers intend you to do this.
On the other hand, I can sympathize with inventing new ways of doing things, also known as “doing things the hard way”. I’ve learned a lot of interesting facts by doing things this way. So …
Assuming there’s a
Material specific to the avatar’s hand, then there must be a
Geometry with that material applied. You could find that
Geometry (which is also a
Spatial) by an exhaustive search of the model’s spatials using
Spatial.depthFirstTraversal(). For each
Spatial that’s an instance of
Geometry, you’d compare
When a match is found, you’d copy the (world) coordinate transform from
geometry to the sword model. But unless the sword and avatar models were designed to fit this way, you’d probably have to adjust (rotate, translate, and/or scale) the
Transform to make the sword fit the avatar’s hand. After that, if the hand ever moved, you’d need to update the
Transform each time.