[X3D-Ecosystem] Classical way of attaching object to a Blender bone
John Carlson
yottzumm at gmail.com
Fri Dec 20 18:41:08 PST 2024
Okay, this looks doable. Not how I would have done it.
https://blenderartists.org/t/find-all-object-type-children-of-a-bone/1230812
On Fri, Dec 20, 2024 at 8:34 PM John Carlson <yottzumm at gmail.com> wrote:
> Blender python to attach an object to armature and bone.
>
> import bpy
>
> # Get the object and armature
> obj = bpy.context.object
> armature = bpy.data.armatures["ArmatureName"]
> # Get the bone to parent to
> bone = armature.bones["BoneName"]
> # Set the parent
> obj.parent = armature
> obj.parent_type = 'BONE'
> obj.parent_bone = bone.name
>
>
>
> Note that the object’s parent is the armature, not the bone.
>
> It’s possible I used bone instead of bone.name.
>
> The XML nodes are traversed in order, typically.
>
> No one says if it’s possible to set child objects of objects to the
> armature as a parent . I don’t know if there’s a hierarchy of objects under
> the armature or not. Typically, I’m traversing a hierarchy of children,
> and I will have to know if the whether the parent is a bone or not. If the
> parent is a bone, then i do the above.
>
> Should I attach objects of nodes below obj’s XML node to the armature
> parent or obj?
>
> How do I tell if I should attach to armature or obj for grandchildren?
>
> Realize that i will be attaching empty objects, there’s no equivalent for
> site or segment in blender. This will mean that I will probably have a
> hierarchy of bones and a hierarchy of objects (sites, segments, transforms
> (as empty objects) and geometry). I am not prepared for this algorithm on
> export, where a bone hierarchy is “separate” from the object hierarchy with
> no known way of getting bone children, except other bones. That’s a huge
> problem I will have. To test for bone parents for each object (say under
> armature) and insert a joint above the armature children. Then, I won’t
> even know if they are Transforms, HAnimSites or HAnimSegments, because
> there’s only adhoc ways of determining x3d node type from empty objects
> (naming, custom properties). If it’s a foreign import, how do I render
> it’s object hierarchy under armature as X3D? I can’t put Transforms under
> HAnimJoints!
>
> If I’m adding joint objects, should I add both bones and objects?
>
> Realize none if this armature or bone stuff was in the exporter before and
> I’ve been adding it in addition to animations that need to work.
>
> I think the best I can hope for is a flat bone hierarchy. Maybe that’s
> what I’ll do.
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-ecosystem_web3d.org/attachments/20241220/8ece52cb/attachment.html>
More information about the X3D-Ecosystem
mailing list