Bone rotation

Problems building or running the engine, queries about how to use features etc.
Post Reply
cafe_ole
Halfling
Posts: 53
Joined: Fri Sep 04, 2009 9:16 am

Bone rotation

Post by cafe_ole »

Hi, I want to rotate an arm of a model made in Blender. In Blender it works fine with an armature definition but when if I export it to Ogre seems like shoulder bone has another pivot to rotate because the movement is not correct. Can I set pivot rotation in Ogre or I have to do it in Blender?? I have tried to put the shoulder axis on 0,0,0 in Blender but it doesn't work. Thanks!

Code:

Code: Select all

 //PITCH + (TECLA U)
		if(mKeyboard->isKeyDown(OIS::KC_U)){
			boneHombro->pitch(Degree(evt.timeSinceLastFrame*100), Node::TS_LOCAL);
		}
		//PITCH - (TECLA Y)
		if(mKeyboard->isKeyDown(OIS::KC_Y)){
			boneHombro->pitch(Degree(-evt.timeSinceLastFrame*100), Node::TS_LOCAL);	
		}

		//YAW + (TECLA J)
		if(mKeyboard->isKeyDown(OIS::KC_J)){
			boneHombro->yaw(Degree(evt.timeSinceLastFrame*100), Node::TS_LOCAL);
		}
		//YAW - (TECLA H)
		if(mKeyboard->isKeyDown(OIS::KC_H)){
			boneHombro->yaw(Degree(-evt.timeSinceLastFrame*100), Node::TS_LOCAL);	
		}
		
		//ROLL + (TECLA M)
		if(mKeyboard->isKeyDown(OIS::KC_M)){			
			boneHombro->roll(Degree(evt.timeSinceLastFrame*100), Node::TS_LOCAL);
		}
		//ROLL - (TECLA N)
		if(mKeyboard->isKeyDown(OIS::KC_N)){
			boneHombro->roll(Degree(-evt.timeSinceLastFrame*100), Node::TS_LOCAL);	
		}

INCORRECT MOVEMENT IN OGRE:
Ogre.JPG
Ogre.JPG (42.2 KiB) Viewed 1899 times
CORRECT MOVEMENT IN BLENDER:
Blender.JPG
Blender.JPG (36.64 KiB) Viewed 1899 times
cafe_ole
Halfling
Posts: 53
Joined: Fri Sep 04, 2009 9:16 am

Re: Bone rotation

Post by cafe_ole »

My problem si similar to this:

http://www.ogre3d.org/forums/viewtopic. ... ion#p81634

I have understood that it is a exporter problem...but I'm not sure :(
kraj0t
Halfling
Posts: 89
Joined: Sun Mar 15, 2009 7:34 pm
Location: Seville (Spain)

Re: Bone rotation

Post by kraj0t »

All I can tell you is... ouch, that seems to hurt ^__^U
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Bone rotation

Post by koirat »

Show us your armature in blender.

Are you sure your bones are parented correctly.
This bone rotation that you are showing us in blender is in edit or in pose mode ?
This is a block of text that can be added to posts you make. There is a 255 character limit.
cafe_ole
Halfling
Posts: 53
Joined: Fri Sep 04, 2009 9:16 am

Re: Bone rotation

Post by cafe_ole »

Bone rotation in Blender is in pose mode. I have solved the problem changing the orientation and the scale of body bone (bone that is the reference to rotate shoulder bone). Thanks :)
User avatar
pyClass
Gnoblar
Posts: 2
Joined: Sun Aug 29, 2010 7:22 am

Re: Bone rotation

Post by pyClass »

cafe_ole, I'm having exactly the same problem.

My simple Blender model behave strangely in Ogre when manually controlling bones. Some bones rotate as expected while others seems to have the pivot incorrectly positioned. I have tried to fix it by manually positioning the bone using Bone::_setDerivedPosition() but no matters what values I use, the bone still rotate as orbiting the entity center.

Some images showing the problem:

Ogre window: the arm rotates as if the center of ration is the entity center or near it. While the leg rotates as it must do.
Image

Blender
Image

Can I see a wire frame render of your model with all bones selected?
Also, can you tell exactly what you did to bones data? I have tried to rotate and scale the root bone and the bone parent to the conflicting ones, in edit mode, and nothing changed.
Ogre 1.7.1
cafe_ole
Halfling
Posts: 53
Joined: Fri Sep 04, 2009 9:16 am

Re: Bone rotation

Post by cafe_ole »

Hi, I have solved the problem rotating bone around another. For example, your bone arms need to have a parent pivot bone to rotate. So you have to join your arm bones to your body bone or add some pivot bone to rotate them.
model.JPG
User avatar
pyClass
Gnoblar
Posts: 2
Joined: Sun Aug 29, 2010 7:22 am

Re: Bone rotation

Post by pyClass »

Thank you, I have tried to change my armature design to be sure there is no disconnected bones (I parented my shoulder bones to a new small bone that connect to the body bone), not only unparented ones, but that didn't solve my problem. Also I found that legs bones are not rotating correctly after all, but as they are near the root bone I didn't notice the small error before.

I opened the skeleton.xml file generated by exporter and bone positions seems not correctly to me. I tried manually edit the values, taking into account that ogre y axis is blender z axis, but still the pivot used to rotate the bones is incorrect.

I will have to create a new thread as this problem seems to be a different one than yours after all.

Update: I have found the problem. It was similar to yours after all. During modeling I scaled my model in Object Mode, but the Exporter ignores Object Mode scaling. I placed bones of armature on top of the scaled model (bad idea). I used the Transform Properties Window (in Blender, press N key with model selected in Object Mode) and reset all axes scale to 1.0 then reposition bones on top of the bigger model. That's all. Anyway, the bones are still placed wrong in skeleton.xml, but it seems it is normal and do not prevent to get the expected deformation.
Attachments
Shows an Ogre render of the model with debug bones (a model of a bone of 1.0 long render as overlay, it is useful for show bone orientation, if you scale it to the head of the next bone you get size too, but I'm too lazy for that)
Shows an Ogre render of the model with debug bones (a model of a bone of 1.0 long render as overlay, it is useful for show bone orientation, if you scale it to the head of the next bone you get size too, but I'm too lazy for that)
Ogre 1.7.1
cafe_ole
Halfling
Posts: 53
Joined: Fri Sep 04, 2009 9:16 am

Re: Bone rotation

Post by cafe_ole »

Also you can do in Object Mode in Blender, Object->Clear/Apply->Apply Scale/Rotation to ObData with the mesh selected to export the bones scalled :)
Post Reply