Attaching to empty nodes

Hello!

After a few years’ hiatus, then a toe dip in the Babylon pool back in march, then a not so long (but still too long hiatus) I am back with another simple question that I should have learned long ago.

How do I go about structuring a blender file (pick your favorite format) and Babylon script to attach an arbitrary object to a specific point on a mesh that may or may not have animation?

Obviously this is a fairly common thing (attaching “guns” to a player in an FPS, lights and cameras to a fixed frame viz scene, ext… ). Somehow, I embarrassingly forgot the process. I remember long ago not having an issue with this. It was strait forward. Sadly, I forgot and I can no longer a working tutorial.

Also props on the 4.0 release! Looks amazing.

Hi Calsa, welcome back! Don’t feel embarrassed… Blender-Land is an ever-changing world. I can only tell you a little about the BabylonJS side, and almost nothing about Blender.

https://doc.babylonjs.com/how_to/pivot

Visit that… and maybe this transformNode playground. Notice lines 39-41, where an “empty” transformNode is being parented-to. Yes, the animation and demo talks about pivots/rotation, but the same general stuff applies to POSITION.

In that doc, you can also read that a basic mesh shape (which generally has a transformNode) can also be a parent, and can be set parent.visibility = 0. But the main thing… parenting, sometimes to a transformNode, which, inside a modeler or when imported FROM a modeler… is sometimes called a root.

Basically, after setting somemesh.parent to anything, THEN set somemesh.position to ANY distance/placement (displacement) AWAY FROM the parent. If the central “root” is in the belly of the snowman, then parent the broomstick to the belly parent, and then set broomstick.position.x = -5; (or similar)… to position the broomstick to one/other side of the snowman. Offsetting from the parent. Easy. Rarely does anyone animate the “master root” of the model… unless they want the entire model to move.

If you wanted to spin the snowman’s belly WHILE spinning the broomstick differently, make sure they are BOTH parented to a master root, and NOT to each other in any way. Then the belly can have animation, and the broomstick can have different animation, and they don’t affect each other… because they have no parent-child relationship between them. They ONLY have the same parent.

That’s about all the info I have. It might be wise to read Blender - Babylon.js Documentation exporter doc, especially the Object section. Stay tuned for comments from more-informed folks than myself.

PS: If you want to click on any model, and have a second model “mount” to the clicked-upon surface of the first model, that is a slightly different subject… but can be done. Let’s call that act… “mounting”… so we can easily refer to it in future comments, if you wish. Parenting at point-of-click… yuh, yuh, yuh, somewhat related-to “snapping”. :slight_smile:

Thanks Wingnut, as always your help is invaluable.

You have exposed a broadness in my question I did not anticipate.

I’m more interested in setting up in blender the actual nodes (what “object” to use, how to name it to find it again, how to rig it for export, constraints on usage). Then, how do I go about finding those reference nodes when loading models in the engine and referencing them to be parents of little baby meshes of their own.

Truth be told I am much more able bodied in MAX, and a complete Blender noob. Eventually I will be needing to understand how to do the same thing from Max, but the exporter was just busted by autodesk releasing Max 2020. While I am waiting on a fix from Autodesk, I figured I would give Blender a whirl. I feel so inadequate in blender land, its different.

Yeah, me too… I’m far more of a Max pilot than Blender. But Blender “stands for something good” although I haven’t been able to precisely find it, yet. “commune-ity”, I guess. It’s probably a 1 year learn… dedicating almost all free-hours to it… but… what a powerful learn.

I think… you need to read some Blender docs… try some basic exports of .babylon files… and inspect the .babylon files and/or the scene created with it. .babylon file format is JSON, so… you can drill it like a tree-view… using MANY available online JSON inspectors… or with Windows Wordpad or similar. Start with a cube… export it (get to know the knobs and switches on the exporter panels… well)… look at the .babylon file… perhaps publish it on your free github account and import it into a playground.

There, you can open the scene “inspector” that is built-into the playground… and easily see what parented to what… during the export… and if “root” nodes were included. I think there is a “exportSelectedOnly” on the Blender-to-Babylon export panel, too.

And the playground’s scene inspector… runs at your house, too, if wanted. It can be installed into ANY scene. Handy… but takes time and a bit of patience… to learn how to drive it.

SO much to familiarize-with, eh? Yeah, esp with that monster Blender sitting there… ready to suck every free hour from us all… forever. :slight_smile:

Give yourself a little time to experiment… try not to be rushed. I think you’ll be surprised at how fast you can learn everything you need… to become a Babylon pro. Don’t let Blender scare ya… its just a “modes” fest. Change its themes/colors… it might start feeling better, doing that. Put a 3D max theme on Blender… it might help you clear one of your worries. :slight_smile:

https://playground.babylonjs.com/#QY1WYT#0

There’s a good playground to go “node inspecting” with. Ok, not really THAT good, because the modeler used poor names. Anyway, click that “gear” symbol and choose Inspector… click-around in that “node tree” of mesh… watch for “root” nodes on the models… and notice their child nodes and sub-mesh. See if your basic Blender exports… have hierarchies like THESE models.

Getting “references” to the imported models… IN the BJS scene… is fairly easy, in multiple ways. It is best to name the models… in Blender. In BJS, scene.getMeshByName() is nearby. Keep the names simple for now, too.

1 Like