[osg-users] Y up to Z up

Aitor Ardanza aitoraltube at terra.es
Mon Apr 4 08:42:35 PDT 2011


Hi,

I'm back again! I have been looking at the ogre example code, and I've noticed that initializes the bones with a specific angle...

Code:
void setupBone(const String& name,const Ogre::Quaternion& q)
	{
		Ogre::Bone* bone = mBodyEnt->getSkeleton()->getBone(name);
		bone->setManuallyControlled(true);
		bone->setInheritOrientation(false);
		
		bone->resetOrientation();
		bone->setOrientation(q);
	
		bone->setInitialState();
	}

	void setupAnimations()
	{
		// this is very important due to the nature of the exported animations
		mBodyEnt->getSkeleton()->setBlendMode(ANIMBLEND_CUMULATIVE);	

		String animNames[] =
		{"IdleBase", "IdleTop", "RunBase", "RunTop", "HandsClosed", "HandsRelaxed", "DrawSwords",
		"SliceVertical", "SliceHorizontal", "Dance", "JumpStart", "JumpLoop", "JumpEnd"};

		//set all to manualy controlled
		//Ogre::Bone* handleLeft = mBodyEnt->getSkeleton()->getBone("Hand.L");
		//handleLeft->setManuallyControlled(true);
		
		//Ogre::Matrix3 mat;
		Ogre::Quaternion q = Quaternion::IDENTITY;
		Quaternion q2,q3;
		Vector3 xAxis,yAxis,zAxis;
		q.FromAngleAxis(Ogre::Degree(90),Vector3(0,0,-1));
		q.ToAxes(xAxis,yAxis,zAxis);
		q2.FromAngleAxis(Ogre::Degree(90),xAxis);
		setupBone("Humerus.L",q*q2);
		q.FromAngleAxis(Ogre::Degree(90),Vector3(0,0,1));
		q.ToAxes(xAxis,yAxis,zAxis);
		q2.FromAngleAxis(Ogre::Degree(90),xAxis);
		setupBone("Humerus.R",q*q2);
		
		q.FromAngleAxis(Ogre::Degree(90),Vector3(0,0,-1));	 
		q2.FromAngleAxis(Ogre::Degree(45),Vector3(0,-1,0));
		
		setupBone("Ulna.L",q*q2);

		q.FromAngleAxis(Ogre::Degree(90),Vector3(0,0,1));	 	
		setupBone("Ulna.R",q*q2.Inverse());
		
		q.FromAngleAxis(Ogre::Degree(180),Vector3(0,1,0));
		setupBone("Chest",q);
		setupBone("Stomach",q);
		q.FromAngleAxis(Ogre::Degree(180),Vector3(1,0,0));	 	
		q2.FromAngleAxis(Ogre::Degree(180),Vector3(0,1,0));
		setupBone("Thigh.L",q*q2);
		setupBone("Thigh.R",q*q2);
		setupBone("Calf.L",q*q2);
		setupBone("Calf.R",q*q2);
		setupBone("Root",Degree(0),Degree(0),Degree(0));


In principle, I dont understand it... This is done to redirect the bones? If we orient correctly from a model editor(maya,blender), we wouldnt need to do this, right? In the model of sinbad for example, the Root bone is oriented with X up. Doing this, setupBone("Root",Degree(0),Degree(0),Degree(0)); will change anything?
[Image: http://img577.imageshack.us/img577/2/sinbadn.jpg ]

First I will review the orientation of the bones of my models ... and I will publish results ...

Thank you!

Cheers,
Aitor

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38200#38200








More information about the osg-users mailing list