OpenGEX as .Nif alternative for OpenMW

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
unelsson
Posts: 227
Joined: 17 Mar 2018, 14:57

Re: OpenGEX as .Nif alternative for OpenMW

Post by unelsson »

I exported OpenMWDude_01 from Blender to dae with Godot's Better Collada Exporter ( https://github.com/unelsson/collada-exp ... tch11_2020 works on Blender 2.83 and possibly too on 2.9). OSG dae plugin has problems understanding the skeleton structure of that particular model, and I've come to the conclusion that it's because multiple "root" nodes. OSG believes that "root" and "DEF-root" are base skeletons, and can only handle one of these "base skeletons". It tries to load joints that belong to "DEF-root" from "root" and vice versa. Switching node structure doesn't seem to make any difference. I wonder if the export from Blender fails, or if the model can be changed, or if the dae loader needs some work. It may be so that the dae loader should understand that "rig" is the actual skeleton, but I'm not sure why it decides to read only the first node under "rig" as the main skeleton.

I've noticed that the model has small gaps between body parts. I believe this is intentional, but what is required to make a solid body from that base model? Is it just a matter of moving vertices or making some new faces in the model?

I also tested OpenMWDude_01.fbx in osganimationviewer. All animations are loaded to OSG properly. The bad stuff is that osganimationviewer just loads the model once from the hard drive, whereas OpenMW uses caching and virtual file system and therefore requires a method for loading file from memory. This doesn't seem to be implemented in OSG's fbx plugin yet.

Scale of the model is extremely small for OpenMW. In general, scaling it up is required. I'm not sure which factor though, linking this scale discussion here for convenience viewtopic.php?t=3495 .

Some other details are:
- There's incompatibility between Better Godot Exporter and OSG in that animation_clip shouldn't have name="something", but id="something". This is easily fixed in text editor.
- Collada file could have all of the required animations listed, but animation start and end times for looping animations may require text editor at this stage. Exporter seems to do decent job in setting the actual start and end times for animations in general though.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: OpenGEX as .Nif alternative for OpenMW

Post by AnyOldName3 »

I was under the impression that usually osgDB just gives the loader plugins an istream and they don't need to care whether it's a file or an in-memory stream. I'd just double-check that it's breaking how you think it's breaking.
unelsson
Posts: 227
Joined: 17 Mar 2018, 14:57

Re: OpenGEX as .Nif alternative for OpenMW

Post by unelsson »

AnyOldName3 wrote: 15 Nov 2020, 15:21 I was under the impression that usually osgDB just gives the loader plugins an istream and they don't need to care whether it's a file or an in-memory stream. I'd just double-check that it's breaking how you think it's breaking.
Thanks for the tip. I've come to the conclusion by reading the source, but I haven't traced far what happens after the readNode is called. Anyway, ReaderWriterDAE has separate functions for istream and std::string whereas ReadWriterFBX has method only for std::string.

https://github.com/openscenegraph/OpenS ... AE.cpp#L42

https://github.com/openscenegraph/OpenS ... E.cpp#L111

https://github.com/openscenegraph/OpenS ... X.cpp#L210
unelsson
Posts: 227
Joined: 17 Mar 2018, 14:57

Re: OpenGEX as .Nif alternative for OpenMW

Post by unelsson »

OSG only understands dae-models with one root. Moving "torso" bone and "DEF-root" bone to childs of "root" bone fixes the OpenMWDude_01, and animations run like they should in osganimationviewer, then it can also be loaded in OpenMW.
unelsson
Posts: 227
Joined: 17 Mar 2018, 14:57

Re: OpenGEX as .Nif alternative for OpenMW

Post by unelsson »

I got OpenMWDude animating in OpenMW via dae: https://www.youtube.com/watch?v=b8Vdw-jSv6Y

Steps required in Blender:
- scale up by 70
- group everything under "root" bone
- move the animation keyframes so that animations don't share keyframes (e.g. animation1 0 - 10, animation2 11 - 15...)

Blender / Better Collada Exporter, select the model to be exported in 3d view, export with the following settings:
- selected objects
- apply modifiers
- exclude armature modifier (?)
- triangulate
- export animation
- all actions
- skip (-noexp) actions
- optimize keyframes

Steps required after export (all of these can be done either in Blender or by updating the exporter code):
- setting the id="root" for the root bone in text editor (default better collada exporter gives names like id="id-bone-3")
- changing animation clip name attribute to id
- renaming animations to "idle" and "walkforward"

OpenMW-CS
- make a new creature, set health to make the creature alive, set wander package, make instance of the creature somewhere

Further work needed for models:
- For creatures and npcs we probably need a collision box node, for just overriding base animations maybe not
- Use default model body part naming scheme
- More animations are needed
- Movement animations should have a root node that moves, that root movement is tied to actor movement in-game

edit: here another one https://youtu.be/yvQBS29UNGc that is scaled inside collada, using <scale> collada node. I animated the root to move in this one, but the scaling probably loses the movement.
Lamoot
Posts: 176
Joined: 22 Apr 2016, 12:03

Re: OpenGEX as .Nif alternative for OpenMW

Post by Lamoot »

cc9cii wrote: 14 Nov 2020, 23:46 Animations list bones multiple times because of animation groups (e.g. upper body, arms, etc) That would be my guess, without knowing from where you've extracted the bone names.
Could be the case as well. Either way, bone names (and their hierarchy) are the only thing I was after, so it's all good.
unelsson wrote: 15 Nov 2020, 19:54 OSG only understands dae-models with one root. Moving "torso" bone and "DEF-root" bone to childs of "root" bone fixes the OpenMWDude_01, and animations run like they should in osganimationviewer, then it can also be loaded in OpenMW.
Yeah, I was sloppy on my end. The previous file works for FBX and GLTF but for collada I didn't have the time to thoroughly test it. Collada is rather picky with these sort of things, but is workable.

I changed the hierarchy and bone naming in the new file and also updated the run animation. I didn't go through testing the scale yet. Just to make it clear from the start, I'm releasing the model, rig and animations as CC0 (public domain).
Attachments
OpenMWDude_02.zip
(672.69 KiB) Downloaded 236 times
Lamoot
Posts: 176
Joined: 22 Apr 2016, 12:03

Re: OpenGEX as .Nif alternative for OpenMW

Post by Lamoot »

And this is the current hierarchy of bones. Since the controls and deformation bones are separate, it won't break the animations when we add more deformation bones. (weapon bones, arm twist bones, skirt bones etc.)

Image
Lamoot
Posts: 176
Joined: 22 Apr 2016, 12:03

Re: OpenGEX as .Nif alternative for OpenMW

Post by Lamoot »

Here's the first test file from out discussion on Discord.

The model now faces +Y in Blender's viewport by default, like it's in your edited OpenMWDude_01 file.
default_orientation.jpg
Both files have identical animations in blender as well as in export. One difference is the default orientation of the root bone.

Root0 is aligned with the world.
root0.jpg
Root180 is rotated and points in the opposite direction.
root180.jpg
Checking the export in Godot, the only difference is that the root moves along either its positive or along its negative value.


And the .zip with both source blend files and exports. It's a wetransfer link. The forum gives me an error when I try to upload it here.
https://we.tl/t-YfcssoAItY
unelsson
Posts: 227
Joined: 17 Mar 2018, 14:57

Re: OpenGEX as .Nif alternative for OpenMW

Post by unelsson »

Well, unfortunately the 03-version won't work.

The Better Collada Exporter doesn't understand non-linear animation editor. Therefore, animation keyframes in actions need to be moved so that animations don't share the same times. Otherwise the animations in .dae file share the same time. I haven't yet figured out a good way to cope with this in the engine, it would require modifying the sampler/channel data. As it is, it's just easier to move the keyframes of the actions (e.g. 1 - 16 for animation A, and 17 to 32 for animation B). Because of this, I can't test any of the exported dae-files, and I'm not sure what has happened between versions 02 and 03, but in the latest, moving the keyframes in action editor seems to breaks the animation (leg and arm movement isn't moved, but stays on place).
Lamoot
Posts: 176
Joined: 22 Apr 2016, 12:03

Re: OpenGEX as .Nif alternative for OpenMW

Post by Lamoot »

Oh right. It's good that you mention this. Everything seemed to work fine in Godot so I didn't even realize the specifics of the setup for OpenMW. It seemed to be ok if they are offset in the NLA editor. I'll set up the animations so they are offset in the actions themselves and send the files again.

EDIT: Here are the updated files. The keyframes in each action have been offset so they don't overlap.
https://we.tl/t-R4ZsfNyUlg

Testing in Godot, they appear to have a section where nothing is happening, but is still regarded as a part of the animation, so not sure if this is the export we need. Perhaps Godot import the file in a different way? I already know the likely reason where to fix this if it indeed turns out to be a problem, but can only look at it later today/tomorrow.

The issue when you tried to offset the clips and having problems with the arms/legs was because those bones were hidden and didn't show in the action editor.
Post Reply