Making better use of Ogre's capbilities?
Re: Making better use of Ogre's capbilities?
Definitely something I should look into, I have been using release mode on everything. Need to set up a debug mode environment.
Re: Making better use of Ogre's capbilities?
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.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
Re: Making better use of Ogre's capbilities?
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
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
Re: Making better use of Ogre's capbilities?
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;
Re: Making better use of Ogre's capbilities?
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.
Re: Making better use of Ogre's capbilities?
Code: Select all
kframe->setScale(Ogre::Vector3(node->trafo->scale - startscale.x, node->trafo->scale - startscale.y, node->trafo->scale - startscale.z));
Code: Select all
kframe->setScale(Ogre::Vector3(node->trafo->scale) / startscale);
Re: Making better use of Ogre's capbilities?
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.
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.
Re: Making better use of Ogre's capbilities?
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.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.
Re: Making better use of Ogre's capbilities?
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?
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?
Re: Making better use of Ogre's capbilities?
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.scrawl wrote:1. in the createMaterial NIF loader method, how can I check if the material for this mesh should be skinned?
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.2. Do we have any information how many blend weights per vertex do NIFs use?
It's probably best to assume they do. Even if Morrowind doesn't, there's nothing to say mods won't.3. Do NIFs use scaling of bones?