osgb/osgt animation format support

Everything about development and the OpenMW source code.
User avatar
scrawl
Posts: 2085
Joined: 18 Feb 2012, 11:51
Contact:

Re: osgb/osgt animation format support

Post by scrawl » 18 Oct 2017, 10:49

The spheres are used to set a bounding box for the whole rig depending on its current pose. You should be able to compute a bone sphere at runtime by taking all the vertices influenced by that bone then measuring the maximum distance of any vertex from that bone's bind position.

Alternatively, or as a temporary solution, we can make the bone spheres optional and instead compute the rig bounding box based on all vertices every frame. This will be a bit slower though.

User avatar
AnyOldName3
Posts: 566
Joined: 26 Nov 2015, 03:25

Re: osgb/osgt animation format support

Post by AnyOldName3 » 18 Oct 2017, 14:08

Or possibly just the current bounding sphere for all children. I'll make some bullet points;
  • It could be the bounding sphere for influenced vertices with the bone in its current position. Computing the bounding sphere would be fine.
  • It could be the bounding sphere for influenced vertices under all possible rotations. Computing the bounding sphere but with the centre manually positioned at the bone's root would get this.
  • It could be the bounding sphere for influenced vertices under all possible transformations. If the bone is of fixed length and won't detach from its parent, this is the same as above. If not, then it's infinite and there's no way to compute it.
  • It could be something else.

crassell
Posts: 49
Joined: 26 Aug 2017, 21:10
Github profile: https://github.com/crussell187

Re: osgb/osgt animation format support

Post by crassell » 20 Oct 2017, 05:53

scrawl wrote:
18 Oct 2017, 10:49
The spheres are used to set a bounding box for the whole rig depending on its current pose. You should be able to compute a bone sphere at runtime by taking all the vertices influenced by that bone then measuring the maximum distance of any vertex from that bone's bind position.
I think I can implement this instead of the temporary option. Any way to wireframe view these bound spheres both before and after in game? I can also just check the serialization result.

On another note, I've found a bug in the osgt animation export when using nif assets as the base. The TargetName string is exported from Blender without being wrapped in quotes so if you have a TargetName with a space such as "Bip01 Pelvis", the osgDB read into openmw gets confused because it tokenizes the 2 strings separately.

I'm going to try a fix in the python code for the blender export.

User avatar
scrawl
Posts: 2085
Joined: 18 Feb 2012, 11:51
Contact:

Re: osgb/osgt animation format support

Post by scrawl » 20 Oct 2017, 12:27

Any way to wireframe view these bound spheres both before and after in game?
I had just that when I initially coded this... tried digging up from the git history, didn't find it, possibly never got committed. Anyway, it's pretty simple: use an osg::ShapeDrawable to represent the sphere, set it to wireframe mode, update its position according to bone position in a callback.

Should look like this: https://www.youtube.com/watch?v=JFgQs2ltpJ8

crassell
Posts: 49
Joined: 26 Aug 2017, 21:10
Github profile: https://github.com/crussell187

Re: osgb/osgt animation format support

Post by crassell » 21 Oct 2017, 23:53

scrawl wrote:
20 Oct 2017, 12:27
I had just that when I initially coded this... tried digging up from the git history, didn't find it, possibly never got committed. Anyway, it's pretty simple: use an osg::ShapeDrawable to represent the sphere, set it to wireframe mode, update its position according to bone position in a callback.
ok I will try this. Thanks for the tip.

Next problem I have is that there are a lot of diffs on bone transform matrices being exported from blender for nixhound.osgt vs. the serialized transforms I get directly from the nif format. I'm not sure if this is some sort of normalization that the osgt export does or not. If so, I may have to stop relying on trying to match all of the floating point data with serialization compares and just start fixing problems the hard way.

I get the identity matrix from blender export to osgt for a particular bone's MatrixTransform matrix:

Code: Select all

 Matrix {
                1.00000 0.00000 0.00000 0.00000
                0.00000 1.00000 0.00000 0.00000
                0.00000 0.00000 1.00000 0.00000
                0.00000 0.00000 0.00000 1.00000
              }
In fact, all of my bone tranformation matrices from export have this matrix :). And anything not related to bind matrices seems to be in an equivalent state on each bone. I've shared the nixhound.osgt so you can see what i'm referring to:
https://drive.google.com/file/d/0B2rV-n ... sp=sharing

The nif equivalent has a different matrix for each bone so something seems off.

Suggestions?

crassell
Posts: 49
Joined: 26 Aug 2017, 21:10
Github profile: https://github.com/crussell187

Re: osgb/osgt animation format support

Post by crassell » 03 Nov 2017, 16:37

I was making good progress but a lot of stuff came up all at once in the past few months (funerals, weddings, etc.). I'll be on vacation for the next week but i'll be looking into finishing this task after that. Can anyone comment on my last issue? If it's just an expected difference in how the osgt export from blender handles the matrix transforms, i'll continue as if nothing is wrong when I get back :).

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests