Making better use of Ogre's capbilities?

Everything about development and the OpenMW source code.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Definitely something I should look into, I have been using release mode on everything. Need to set up a debug mode environment.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Chris wrote: The ancestor ghost is mostly correct. The face is positioned wrong, but that's not a skinning problem because it isn't skinned, it's attached directly to the bone like the werewolf head (funny enough the werewolf head works now without needing extra rotations, though Hircine's spear and the ghost
Some bones do not have a keyframecontroller. For these you have to make a keyframe on a track at time 0 with the bone position and orientation. Ancestor ghosts head works for me.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Chris, I am having trouble getting the new changes to work. I made a commit on my animexperimental2 branch ("not working"), can you look at it?

The most relevant functions are in the ogre_nif_loader.cpp, SkeletonNIFLoader::buildBones() and NIFLoader::handleNiTriShape().

Also instead of the bones->GetWorldTransform() I am using the _getDerivedPosition() and _getDerivedOrientation() of the actual bone. I figured this would be okay since the initial positions of the bones are the same as the nodes. Will change this if it is not.

EDIT: Left something out, made another commit
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

jhooks1 wrote:Also instead of the bones->GetWorldTransform() I am using the _getDerivedPosition() and _getDerivedOrientation() of the actual bone. I figured this would be okay since the initial positions of the bones are the same as the nodes. Will change this if it is not.

I don't think you can rely on the bone's position when the mesh is being loaded, since there's no telling when that will happen in relation to the skeleton.

As for the code, I notice that you're not handling the bone scale in a number of places. The bone->setInheritOrientation(false); call is incorrect. The weights seem to be forced to 1, which will mess up blended vertices.

Another thing is, this:

Code: Select all

newNorms[verIndex][j] += mat[j][0]*vertexPosOriginal[verIndex][0] * ind.weight;
newNorms[verIndex][j] += mat[j][1]*vertexPosOriginal[verIndex][1] * ind.weight;
newNorms[verIndex][j] += mat[j][2]*vertexPosOriginal[verIndex][2] * ind.weight;
// Should be this:
newNorms[verIndex][j] += mat[0][j]*vertexNormalOriginal[verIndex][0] * ind.weight;
newNorms[verIndex][j] += mat[1][j]*vertexNormalOriginal[verIndex][1] * ind.weight;
newNorms[verIndex][j] += mat[2][j]*vertexNormalOriginal[verIndex][2] * ind.weight;
(you're using the position instead of the normal, and I originally had the matrix indices reversed).
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

Made another commit. Changed the weighting (had it set at 1 when I was trying different things), the normals, and the inherit orientation call. I need to address the scaling and the world transform procedure.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

Code: Select all

kframe->setScale(Ogre::Vector3(node->trafo->scale - startscale.x, node->trafo->scale - startscale.y, node->trafo->scale - startscale.z));
That's incorrect.

Code: Select all

kframe->setScale(Ogre::Vector3(node->trafo->scale) / startscale);
should do it.
jhooks1
Posts: 780
Joined: 06 Aug 2011, 21:34

Re: Making better use of Ogre's capbilities?

Post by jhooks1 »

One more question, would the world transform on nodes be correct with different resources used for the skeleton and mesh? For example, using glove.nif as a mesh and base_anim.nif as a skeleton. Mainly for npcs.

EDIT: Got your last change committed.

EDIT2: Also the reason that I was ignoring scale on a lot of things, I have yet to see a morrowind NIF with scales in its key frame data. Have seen scales in trafos though. Going to handle scale keyframes though, following your code as a guide.
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

jhooks1 wrote:One more question, would the world transform on nodes be correct with different resources used for the skeleton and mesh? For example, using glove.nif as a mesh and base_anim.nif as a skeleton. Mainly for npcs.
I'm not quite sure. You would need to use the glove mesh's skinning data for the data->GetBoneTransform(b), and you could use the base_anim.nif skeleton for the bones->GetWorldTransform()... though that would mean the glove mesh would need to be loaded once per skeleton it uses (e.g. once for the normal skeleton, and again for the beast skeleton, and again for its own). Probably not a big deal in the grand scheme of things, but it'd be a bit more work for managing it.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Making better use of Ogre's capbilities?

Post by scrawl »

I'm looking into hardware skinning right now. Dual Quaternion Skinning seems to be the best method available as it eliminates the skin collapsing artifacts that a lot of character models in MW suffer from.

Questions:
1. in the createMaterial NIF loader method, how can I check if the material for this mesh should be skinned?
2. Do we have any information how many blend weights per vertex do NIFs use?
3. Do NIFs use scaling of bones?
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: Making better use of Ogre's capbilities?

Post by Chris »

scrawl wrote:1. in the createMaterial NIF loader method, how can I check if the material for this mesh should be skinned?
Probably the easiest way to check is if the NiTriShape has any skinning data (!shape->skin.empty()). This would be per-submesh, like the material itself.
2. Do we have any information how many blend weights per vertex do NIFs use?
I don't think NIFs themselves impose a limit, but you shouldn't expect more than 4. Anything more than that isn't expected to be hardware skinned since that would require more than 64 (4*4*4) float shader constants. I'm not sure if Ogre imposes an internal limit before falling back to software skinning, but I know earlier versions of the lib would log a warning if vertices had more than 4 weights.
3. Do NIFs use scaling of bones?
It's probably best to assume they do. Even if Morrowind doesn't, there's nothing to say mods won't.
Post Reply