[SOLVED] Understanding the local axes of a skeleton

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
hinashah
Gnoblar
Posts: 14
Joined: Fri Jul 18, 2014 9:31 pm

[SOLVED] Understanding the local axes of a skeleton

Post by hinashah »

Hello,

I am trying to debug a mesh that I have exported from Maya. However the local axes for the rigged skeleton do not look the same as in Maya. I am using the following code to draw the local axes. Can somebody please tell me if I am doing something wrong?

Code: Select all

m_pAxes =  m_pSceneManager->createManualObject("LocalAxes"); 
	Ogre::MaterialPtr axesMaterial = Ogre::MaterialManager::getSingleton().create("AxesMaterial","General"); 
	axesMaterial->setReceiveShadows(false); 
	axesMaterial->getTechnique(0)->setLightingEnabled(false); 
	axesMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,1); 
	
	m_pAxes->begin("AxesMaterial", Ogre::RenderOperation::OT_LINE_LIST); 
	auto boneIterator = m_pSkeletonInstance->getBoneIterator();

	while(boneIterator.hasMoreElements())
	{
		Ogre::Bone *curBone = boneIterator.getNext();
		
			Ogre::Vector3 pos = curBone->_getDerivedPosition();
			Ogre::Matrix3 local= curBone->getLocalAxes();
			Ogre::Real scale=15.0;
			m_pAxes->position(pos);
			m_pAxes->colour(1,0,0);
			m_pAxes->position(pos + scale*(local.GetColumn(0)));

			m_pAxes->position(pos);
			m_pAxes->colour(0,1,0);
			m_pAxes->position(pos + scale*(local.GetColumn(1)));

			m_pAxes->position(pos);
			m_pAxes->colour(0,0,1);
			m_pAxes->position(pos + scale*(local.GetColumn(2))); 
		
	}
	m_pAxes->end(); 
	m_pSceneManager->getRootSceneNode()->createChildSceneNode("LocalAxes_node",Ogre::Vector3(160.0f, 0.0f, 0.0f))->attachObject(m_pAxes); 	
Last edited by hinashah on Sun Jul 27, 2014 9:23 pm, edited 1 time in total.
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: Understanding the local axes of a skeleton

Post by madmarx »

The information of the bone are in the "skeleton system", not in the "worl system", even if you used _getDerivedPosition.
So you will need to take into account the matrix of the skeleton too.

We should do a wiki on this, because this question comes up so often.

EDIT : but there are already plenty on the forum on that subject. http://www.ogre3d.org/forums/viewtopic.php?f=1&t=55259
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
hinashah
Gnoblar
Posts: 14
Joined: Fri Jul 18, 2014 9:31 pm

Re: Understanding the local axes of a skeleton

Post by hinashah »

So if I understand you correctly even to display the local axes at every joint, I'll have to apply the hierarchical composite transformation, right? I am not worried about the positions right now (I think), because the positions of bones look right. I need to figure out conversions between two different versions of local-axes at every joint.


Thanks!!
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: Understanding the local axes of a skeleton

Post by madmarx »

Yes, you are right!

There are sample codes in the link I gave you on that subject.

Best regards,

Pierre
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
hinashah
Gnoblar
Posts: 14
Joined: Fri Jul 18, 2014 9:31 pm

Re: Understanding the local axes of a skeleton

Post by hinashah »

Cool that worked like a charm.

Thanks a lot!
Hina
Post Reply