[2.1] Strange bone weight behaviour

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
SamiTheGreat
Bronze Sponsor
Bronze Sponsor
Posts: 102
Joined: Sat Aug 30, 2008 11:57 am
Location: Finland
x 8

[2.1] Strange bone weight behaviour

Post by SamiTheGreat »

Hi! I am doing animation system where you can mix 2 animations. We have two groups (upper body and lower body). I want system to work that I can player one animation for top group and second one for lower group. Currently I have list of bones and which group they belongs. Setting bone weight to 0 should disable animation for lower/upper group. There is something very strange behaviour.. I tried to set all bone weight to 0 to test what is going on and some parts of the mesh are still animated! :?:

This is how I iterate all the bones and set weight to 0.

Code: Select all

Ogre::SkeletonInstance* skelIns = item->getSkeletonInstance();

	if (skelIns)
	{
		Ogre::IdString idString = Ogre::IdString(animationName);

		if (skelIns->hasAnimation(idString))
		{
			Ogre::SkeletonAnimation* animation = skelIns->getAnimation(idString);
			if (animation)
			{
				//set bone weights to 0 as default
				for (unsigned int i = 0; i < skelIns->getNumBones(); i++)
				{
					Ogre::Bone* iBone = skelIns->getBone(i);
					Ogre::IdString boneIDString = Ogre::IdString(iBone->getName());
					animation->setBoneWeight(boneIDString, 0.0f);
				}

				mAnimationMap.insert(std::pair<std::string, Ogre::SkeletonAnimation*>(animationName, animation));
			}
		}
	}
Bone class has 2 methods to get bone id (getId() and getName()). If I use getName() function, some bones are animated but if I use getId() there is still animation but in different bones. Is this a bug or am I doing somethign wrong?
I tried this with legacy animations and with the new one but same happens on both.

EDIT: Having overloaded function for setBoneWeight that takes Bone pointer as input would be nice also. I could check the source and try to implement that.

EDIT2: It seems that all bones after depth level 2 doesn't get affected by set bone weight.

EDIT3: Okay, I've double checked that all weights are set to 0 now but it is not working yet.

Code: Select all

//Check that all weights are zero
				unsigned int numZeroBone = 0;
				for (unsigned int i = 0; i < skelIns->getNumBones(); i++)
				{
					Ogre::Bone* iBone = skelIns->getBone(i);
					Ogre::IdString boneIDString = Ogre::IdString(iBone->getName());
					float bWeight = animation->getBoneWeight(boneIDString);
					if (bWeight == 0)
					{
						numZeroBone++;
					}
				}
				if (numZeroBone < skelIns->getNumBones())
				{
					Ogre::LogManager::getSingleton().logMessage("All bone weights were not zero! All animation bone weights should be zero at creation!", Ogre::LogMessageLevel::LML_CRITICAL);
				}
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: [2.1] Strange bone weight behaviour

Post by frostbyte »

maybe try playing with Skeleton->setBlendMode values...( ANIMBLEND_CUMULATIVE, ANIMBLEND_AVERAGE )
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Strange bone weight behaviour

Post by dark_sylinc »

Can you send me your skeleton & mesh via PM? (+ the name of animation so I know what to play)
This is likely an Ogre bug.

Edit: Nevermind I managed to repro it with jaqua mesh.
User avatar
SamiTheGreat
Bronze Sponsor
Bronze Sponsor
Posts: 102
Joined: Sat Aug 30, 2008 11:57 am
Location: Finland
x 8

Re: [2.1] Strange bone weight behaviour

Post by SamiTheGreat »

dark_sylinc wrote:Can you send me your skeleton & mesh via PM? (+ the name of animation so I know what to play)
This is likely an Ogre bug.

Edit: Nevermind I managed to repro it with jaqua mesh.
Okay, good to know. Have you yet managed to get idea what might be broken? I tried to spot the bug from source code but I didn't have any clue where it might be because boneweights are packed.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Strange bone weight behaviour

Post by dark_sylinc »

Fixed.

Thanks for the report.
User avatar
SamiTheGreat
Bronze Sponsor
Bronze Sponsor
Posts: 102
Joined: Sat Aug 30, 2008 11:57 am
Location: Finland
x 8

Re: [2.1] Strange bone weight behaviour

Post by SamiTheGreat »

dark_sylinc wrote:Fixed.

Thanks for the report.
Thanks for the fix! I will try today if our animation mixing is working. :D
Post Reply