BindingMatrix?
Seven193
Posts: 1,083
How is the BindingMatrix used in figures?
Where does it fit within the transformation order of vertices?
Everything I load, G8F, clothes, hair, etc.., the binding matrix is identity for every bone.
If the binding matrix is identity, then how are a skin's vertices being transformed?
function doIt() { var node = Scene.getPrimarySelection(); var obj = node.getObject(); if(!node.inherits("DzFigure")) return; print( "name: " + obj.getName() + "\n" ); var numMods = obj.getNumModifiers(); print( "numMods: " + numMods + "\n" ); for(var i=0; i < numMods; i++) { var mod = obj.getModifier(i); if(mod) { if(mod.inherits("DzSkinBinding")) { print( "mod: " + i + ": " + mod.getName() ); var skin = mod; var num_binds = skin.getNumBoneBindings(); print( "num_binds: " + num_binds ); for(var k=0; k < num_binds; k++) { var bind = skin.getBoneBinding(k); var P = bind.getBindingMatrix(); print( "P " + k + ": " + P + ", " + bind.getName() ); } } } }}doIt();
Executing Script...name: Genesis8FemalenumMods: 8760mod: 8758: SkinBindingnum_binds: 170P 0: [1,0,0,0,1,0,0,0,1,0,0,0], lIndex3P 1: [1,0,0,0,1,0,0,0,1,0,0,0], lMid3P 2: [1,0,0,0,1,0,0,0,1,0,0,0], lRing3P 3: [1,0,0,0,1,0,0,0,1,0,0,0], lPinky3...P 167: [1,0,0,0,1,0,0,0,1,0,0,0], pelvisP 168: [1,0,0,0,1,0,0,0,1,0,0,0], abdomenLowerP 169: [1,0,0,0,1,0,0,0,1,0,0,0], hipResult: Script executed in 0 secs 250 msecs.
Comments
It looks like the bindingMatrix is being superseded on by a joint transform set by:
setOrigin()
setEndPoint()
setOrientation()
Which makes everything a little bit more confusing. bindingMatrix should be the inverse of this transform, and not identity. Otherwise, it serves absolutely no purpose here.
I just found a shocking discovery. The bindingMatrix is not saved to the scene .duf file. So even if I set it on import, it gets set back to identity the next time the scene .duf file is loaded, and everything gets lost. I guess it really is, a do-nothing matrix.
So, how exactly am I suppose to import animation without a bindingMatrix? Doesn't every 3D game engine in existence require binding matrices for animation? You can't transform an animation key without one.
Redacted
Well, both. The mesh is skinned, so the bones drive it. The main problem I'm having right now, is that my animation keys have this dependency on a binding Matrix that brings the mesh back to bonespace, before they get transformed to worldspace. So, I'm not quite sure how to re-calculate the keys to work in Daz Studio.
What I have figured out so far:
- DS has a bindingMatrix for each joint, but it's not actively used. The matrix is part of the transformation, but the data isn't saved when the program exits. So, this will have to be ignored for now.
- DS has a joint transform, set by these methods:
setOrigin()
setEndPoint()
setOrientation()
- Then finally, DS has a node transform, usually set by:
setLocalTransform()
Which is actually where the animation key data goes for each time frame. But, without a bindingMatrix, this looks a bit funky.
I guess you could write it like:
v' = v * BindingMatrix * JointMatrix * NodeMatrix
This is just an over-simplified version. I'm well aware of this, which is much more complex:
http://docs.daz3d.com/doku.php/public/dson_spec/object_definitions/node/start
I mentioned elsewhere DS is flipping all of my rotations, so I'm not entirely sure about anything. Not just with Eulers, but it also does it with every function that accepts a quaternion, setLocalTransform(), etc...