Import / Create an HAnimHumanoid

Hi Michalis,

I am doing my first steps to work with CGE in connection to my MovEngine software.

So far, I was able to setup an HAnimHumaniod model from my existing MovEngine model. I could save this as X3D and load it in Castle Model Viewer.

Now I am trying to import a model with skeleton from Collada and to create the HAnimHumanoid. I started to hack the CGE Collada import code for this, but now I am stuck with this problem:

The THAnimJointNode.RestCenter is strict private and setup in THAnimJointNode.ParseAfter. This means it will be called (as far as I understand) only when loading from x3d but not when importing from other formats or setting up a humanoid from code.

Or do I miss something?

Thanks, Henner

  1. As for functionality available now only in ParseAfter:

  2. As for doing skinning and H-Anim:

    • There is a big upcoming new development in this area: see Skinned animation using the Skin node | Castle Game Engine , where we introduce Skin node. It has some similarities and some differences from H-Anim, the page explains why and what are the next steps (including possible basing H-Anim on top of Skin in the future).

    • The work is right now on skinned-animation-gpu branch. Not merged yet, as it requires some fixes to cooperate better with shadow volumes (which require to fallback to CPU) and better reading of bbox from glTF.

    • But it already shows the new approach rocks :slight_smile:

      • It matches glTF perfectly, and we can import glTF models into X3D extended with the Skin node easily and perfectly, and the animation is done on GPU so it’s super-fast.
      • The glTF skinned animation already works cool on that branch, with much faster model loading and much less memory usage than for such animations in master. And we get ability to move joints at runtime (e.g. to make inverse kinematics). This is our future direction.
      • It has also been used in one sponsored job to import a motion-capture format for one company into X3D with a Skin node, and it worked very nice, proving in my eyes the design makes sense.
  3. As for Collada:

    • While I welcome PRs to extend Collada support…

    • …I admittedly do not want to invest much myself into Collada future development. Reason: From what I’ve seen, most Collada usage has been replaced at this point with glTF usage, as glTF addresses similar use-cases (including similar approach for skinning, according to one Khronos mention) but has a few things better (e.g. combination of JSON + binary making it efficient, and PBR with various great extensions to it, and glTF seems more “minimal but with right focus”, and the development of glTF in Khronos seems more active).

    • Which means that I would recommend at this point everyone who is using Collada → to migrate to glTF. Khronos provides a converter: GitHub - KhronosGroup/COLLADA2GLTF: COLLADA to glTF converter , though I don’t know myself how much it can handle (e.g. can it handle animations). But this would be my first thing to try.

Summary:

  • Why you can continue, using H-Anim nodes (with new exposed methods) and engine master and improving our Collada animation import…

  • I would actually recommend a different approach:

    • Try engine skinned-animation-gpu branch.

    • I realize that basing your work on top of non-master engine branch is making things complicated… but you really really should check out Skin node :), as I think it addresses some things that you would otherwise find problematic in our current H-Anim handling in master. And hopefully in ~2-3 weeks I will manage to fix everything and merge skinned-animation-gpu to master.

    • Ideally, just make a converter from your own format (MovEngine) into CGE’s nodes, with Skin for skinned animation. See engine RegisterModelFormat. If you have your own format, then maybe you don’t need any “proxy” files like Collada or glTF or X3D, and you can load it straight in our engine (thus creating X3D nodes with extensions, like Skin node)?

    • Or, if you want to use a proxy format, use glTF (not Collada) for this proxy. If you can convert MovEngine->glTF, you have a straightforward path.

    • Or, if you have to use Collada as a “proxy”, test COLLADA2GLTF.

    • Or, if you have to use Collada as a proxy and above COLLADA2GLTF doesn’t work for you, improve our Collada importer to generate Skin node (not H-Anim nodes) which hopefully should be trivial, since this is exactly what glTF importer src/scene/load/x3dloadinternalgltf.pas in that branch is already doing, and Collada is hopefully similar.

I hope this is clear and it helps :slight_smile: Sorry, it’s probably more information than you wanted :), but as it happens – what you’re doing touches something that we have just improved greatly in the engine (alas, not yet merged to master). It would be a waste if you base your design on something un-optimal.

2 Likes

Thanks a lot for the quick fix.

For the rest: Of course this is “too much” information, but I will happily digest all the details over time.
I see your points, but for the moment I am dealing only with a very specific use-case: I have some Collada models, that I want to access (with skeleton).

But all your information might be very useful in future considerations.

Understood, if you just have to read Collada, go for it.

I would still recommend to read my details :slight_smile: Because:

  1. Using GitHub - KhronosGroup/COLLADA2GLTF: COLLADA to glTF converter may be much simpler approach than extending our Collada importer.

  2. And if not, we already have glTF → Skin node import on the skinned-animation-gpu branch, which is much simpler than what we have in master (because Skin matches glTF in an obvious way and because we don’t precalculate it). So if you want to extend Collada importer, it should likely be extended in the same way.

    I’m basing this advise on information that Collada and glTF skinned animation spec is very similar.