[X3D-Ecosystem] Converting X3D to glTF via Blender

John Carlson yottzumm at gmail.com
Mon Oct 21 14:51:43 PDT 2024


I thought it would be easier to generate .glTF and .glb from Blender!

But first, I need a generalized importer, not only HAnim stuff.  I’m hoping
to modify the existing importer—Apparently I broke my version adding HAnim.
  WIP.

I am developing an external Blender X3D loader for practice (installing
into Blender for each change is a pain).  This loader will load stuff with
names like Transform.theTransformDEF.0 (0 for DEF, higher numbers for
USE).  This will allow me to store Inlines and other X3D nodes in the
Blender hierarchy.  As Objects of type EMPTY, if course.  One might develop
“extensions” to glTF transforms to store X3D.  If you would like to
collaborate on such extensions, we can discuss.

I plan for the “X3DV” exporter to consume these names and produce real X3D
nodes, perhaps by providing custom properties to Blender from the importer
as well, to add fields from X3D.

I’m not sure if this will extend to PROTOs or not.  I’m not aware that
.glTF or Blender itself supports PROTOs after they are imported.
Information requested!

On Mon, Oct 21, 2024 at 11:15 AM Michalis Kamburelis <
michalis.kambi at gmail.com> wrote:

> Sure. X3D to glTF conversion using Castle Game Engine will definitely
> come,  https://castle-engine.io/roadmap#gltf_save :)
>
> Regards,
> Michalis
>
> pon., 21 paź 2024 o 17:59 John Carlson <yottzumm at gmail.com> napisał(a):
> >
> > I'm trying to convert the attached X3D file to .glb and have a single
> button to animate.
> >
> > Feel free to do .x3d to .glb conversion so I'm not the only guy doing it.
> >
> > Thanks,
> >
> > John
> >
> > On Mon, Oct 21, 2024 at 10:47 AM Michalis Kamburelis <
> michalis.kambi at gmail.com> wrote:
> >>
> >> To be clear, I know the original model you reported in this thread was
> >> GLB and I know why the "Enable Multiple Simultaneous Animations"
> >> didn't work for you -- it seems you had multiple TimeSensors (well,
> >> "animations in glTF" which come down to "TimeSensor nodes" for us)
> >> trying to affect the same thing.
> >>
> >> I'm a bit confused, you have answered me with a few posts, some of
> >> this information seems unconnected, at least for me -- I don't know
> >> what you're doing, how you use Blender, what is your goal etc. It
> >> doesn't help that there seem to be a few interconnected threads with a
> >> different subset of people.
> >>
> >> If you believe you have found a bug in Castle Model Viewer, please
> >> just report it to https://github.com/castle-engine/castle-model-viewer
> >> , along with (as simple as possible) testcase to reproduce it. I'll be
> >> sure to fix it then :) Thanks!
> >>
> >> Regards,
> >> Michalis
> >>
> >> pon., 21 paź 2024 o 17:08 John Carlson <yottzumm at gmail.com> napisał(a):
> >> >
> >> > BTW, I don't know if you guys say this version of Joe Kick with a
> *single* animation.  No, I don't have to clicky clacky on multiple
> animations checkbox or press a lot of buttons.  Just the two buttons in CGE
> Model Viewer, Animations, and then the actual, single animation. No extra
> X3D file required either.
> >> >
> >> > Note that I still need to work on Weight/Animation import in the
> Blender importer.
> >> >
> >> > Holger, I think your .glb import needs some work.
> >> >
> >> > Thanks!
> >> >
> >> > Attached.
> >> >
> >> > On Mon, Oct 21, 2024 at 9:57 AM John Carlson <yottzumm at gmail.com>
> wrote:
> >> >>
> >> >> Here's the "magical" Blender python export to get all TimeSensors
> playing in a .glb, without having to clicky clicky on all the NLA track
> animations in Castle Model Viewer   (which doesn't work) or have an X3D
> wrapper. This is also the instructions for including more than 4 weights
> (40) per vertex in the .glb! One still needs a TimeSensor to kick
> everything off, but it's a relief not to click an animation for every bone!
> >> >>
> >> >> Thanks to Don McCurdy for taking me through this.  Success!
> >> >>
> >> >> Blender Python script for exporting glb as a single, combined
> animation:
> >> >>
> >> >> bpy.ops.export_scene.gltf(
> >> >>     filepath=os.path.join("YourFolderHere", f"YourGLBfileHere.glb"),
> >> >>     export_yup=False,
> >> >>     # export_format="GLTF_SEPARATE",
> >> >>     export_format="GLB",
> >> >>     export_nla_strips_merged_animation_name='Animation',
> >> >>     export_animation_mode="ACTIVE_ACTIONS", #"SCENE",
> >> >>     export_influence_nb=40,
> >> >>     export_all_influences=True,
> >> >>     use_active_collection=True
> >> >> )
> >> >>
> >> >> Note that I left Joe off the CC because of the "export_yup=False" he
> already complained about it on another thread.
> >> >>
> >> >> On Mon, Oct 21, 2024 at 8:50 AM Michalis Kamburelis <
> michalis.kambi at gmail.com> wrote:
> >> >>>
> >> >>> Sorry for delay in answering, just got back from 2 conferences.
> >> >>>
> >> >>> 1. The general way to play multiple animations in Castle Model
> Viewer
> >> >>> is no different from any other X3D viewer -- you can have multiple
> >> >>> TimeSensor nodes active at the same time.
> >> >>>
> >> >>>     From Castle Model Viewer UI, you can select "Enable Multiple
> >> >>> Simultaneous Animations" in the "Animations" panel, and then running
> >> >>> an animation -- it's really just starting another TimeSensor. By
> >> >>> default "Enable Multiple Simultaneous Animations" is false, but this
> >> >>> is just a convenience following what people usually need from Castle
> >> >>> Model Viewer -- they want to see one animation. But you can have
> both
> >> >>> ways, play only one animation, or play multiple at the same time.
> >> >>>
> >> >>>     You can also define an X3D "wrapper" file that uses Inline to
> >> >>> reference a file (glTF or X3D, it works in any case) and uses IMPORT
> >> >>> to reference the animations (really, just TimeSensor nodes) and runs
> >> >>> them. I see Holger from X_ITE answered along these lines too.
> >> >>>
> >> >>> 2. That said, to make it work, all the TimeSensor nodes must modify
> >> >>> disjoint parts of the X3D graph (whether it's loaded from X3D or
> >> >>> glTF). This doesn't happen in this case, from what I see -- even
> your
> >> >>> "NLATRACK SBall" animation (TimeSensor name
> >> >>> "CastleEncoded_NLATRACK$32$SBall") has a ROUTE to
> >> >>>
> "CastleEncoded_CoordSkinInterpolator_NLATRACK$32$SBall_Joe_Shape_IndexedFaceSet_Primitive0"
> >> >>> which then modifies "Coordinate.point".
> >> >>>
> >> >>> Regards,
> >> >>> Michalis
> >> >>>
> >> >>> pon., 14 paź 2024 o 23:02 John Carlson <yottzumm at gmail.com>
> napisał(a):
> >> >>> >
> >> >>> > Michalis, see attached. .glb.  Can we get all three animations
> playing at the same time in the CGE viewer?  Instructions?
> >> >>> >
> >> >>> > Others, see below.
> >> >>> >
> >> >>> > I'll try getting the non-animated version of JinLOA4 into Blender.
> >> >>> >
> >> >>> > On Mon, Oct 14, 2024 at 10:28 AM Joe D Williams <
> joedwil at earthlink.net> wrote:
> >> >>> >>
> >> >>> >> > bpy.ops.import_scene.x3d(filepath="JoeKick.x3d",
> axis_forward='Y', axis_up='Z')
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> This has to be wrong.
> >> >>> >>
> >> >>> >> You want:
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> axis_forward='Z', axis_up='Y'
> >> >>> >
> >> >>> >
> >> >>> > I do what works.  Plus, if you import like the above, be sure to
> turn off +Y for .glb export.
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> Seems to me that you have to tell it what you want correctly.
> >> >>> >>
> >> >>> >> Don't forget to try and set the host root coordinate system to
> be the same:
> >> >>> >>
> >> >>> >> axis_forward='Z', axis_up='Y'
> >> >>> >>
> >> >>> >> Unknown how X is defined, should be +X to model left, that is
> user/viewer +X toward right.
> >> >>> >>
> >> >>> >> right.
> >> >>> >
> >> >>> >
> >> >>> > I don't know if there's other options for .glb.  Unless you can
> find something, uncheck +Y. up
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> Good Luck,
> >> >>> >>
> >> >>> >> Joe
> >> >>> >>
> >> >>> >> -----Original Message-----
> >> >>> >> From: John Carlson <yottzumm at gmail.com>
> >> >>> >> Sent: Oct 14, 2024 6:22 AM
> >> >>> >> To: Joe D Williams <joedwil at earthlink.net>, Myeong Won Lee <
> myeongwonlee at gmail.com>
> >> >>> >> Subject: Re: JinLOA4.x3d skin/skeleton don't line up?
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> Apologies, apparently, I was loading them into Blender
> differently:
> >> >>> >>
> >> >>> >> bpy.ops.import_scene.x3d(filepath="JoeKick.x3d",
> axis_forward='Y', axis_up='Z')
> >> >>> >>
> >> >>> >> bpy.ops.import_scene.x3d(filepath="JinLOA4.x3d",
> axis_forward='Z', axis_up='Y')
> >> >>> >>
> >> >>> >>
> >> >>> >> This seems to be what works, as previously discussed.
> >> >>> >>
> >> >>> >> importJin.py:bpy.ops.import_scene.x3d(filepath="JinLOA4.x3d",
> axis_forward='Y', axis_up='Z')
> >> >>> >> importJoe.py:bpy.ops.import_scene.x3d(filepath="JoeKick.x3d",
> axis_forward='Y', axis_up='Z')
> >> >>> >>
> >> >>> >> Oops!
> >> >>> >>
> >> >>> >> John
> >> >>> >>
> >> >>> >> On Mon, Oct 14, 2024 at 7:58 AM John Carlson <yottzumm at gmail.com>
> wrote:
> >> >>> >>>
> >> >>> >>> Hi guys.  I am very sorry, but there's a potential problem with
> the Humanoid archive, I was just loading in JinLOA4.x3d into Blender, with
> some minor modifications.  It looks like the skeleton and the skin don't
> line up.  skeleton is +Y up, Skin is +Z up.
> >> >>> >>>
> >> >>> >>> Can you double check and correct the archives?
> >> >>> >>>
> >> >>> >>> I'd mistrust my loader, but JoeKick (with modified
> TextureCoordinate) is loading OK.
> >> >>> >>>
> >> >>> >>> Also, JinLOA4.x3d also has complaints from Castle Game Engine
> Re: coordinates.
> >> >>> >>>
> >> >>> >>> No wonder I am confused.
> >> >>> >>>
> >> >>> >>> It's probably important to get this right for the archives.
> >> >>> >>>
> >> >>> >>> Thanks,
> >> >>> >>>
> >> >>> >>> John
> >> >>> >>
> >> >>> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-ecosystem_web3d.org/attachments/20241021/2d5d851f/attachment-0001.html>


More information about the X3D-Ecosystem mailing list