Team Member
Posts: 1591
Joined: Thu Mar 02, 2006 11:29 pm
Location: Boston, MA, USA
Ogre3D + Kinect
http://youtu.be/O6xdopI9su4
The Steward of Axiom
A place to ask questions or discuss issues relating to implementing applications with Axiom. If you are unsure of where to post, post here.
Team Member
Posts: 1591
Joined: Thu Mar 02, 2006 11:29 pm
Location: Boston, MA, USA
https://github.com/OpenNI/SampleAppSinbad/blob/master/Character/include/SinbadCharacterController.h
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);
//rotate the body
//mBodyNode->yaw(Degree(0),Node::TransformSpace::TS_WORLD);
Skeleton* skel = mBodyEnt->getSkeleton();
Ogre::Skeleton::BoneIterator bi = skel->getBoneIterator();
// populate our animation list
for (int i = 0; i < NUM_ANIMS; i++)
{
mAnims[i] = mBodyEnt->getAnimationState(animNames[i]);
mAnims[i]->setLoop(true);
mFadingIn[i] = false;
mFadingOut[i] = false;
// disable animation updates
Animation* anim = mBodyEnt->getSkeleton()->getAnimation(animNames[i]);
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Ulna.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Ulna.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Humerus.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Humerus.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Stomach")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Chest")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Thigh.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Thigh.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Calf.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Calf.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Root")->getHandle());
}
// start off in the idle state (top and bottom together)
setBaseAnimation(ANIM_IDLE_BASE);
setTopAnimation(ANIM_IDLE_TOP);
// relax the hands since we're not holding anything
mAnims[ANIM_HANDS_RELAXED]->setEnabled(true);
mSwordsDrawn = false;
}
//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));
https://github.com/OpenNI/SampleAppSinbad/blob/master/Character/include/SinbadCharacterController.h
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);
//rotate the body
//mBodyNode->yaw(Degree(0),Node::TransformSpace::TS_WORLD);
Skeleton* skel = mBodyEnt->getSkeleton();
Ogre::Skeleton::BoneIterator bi = skel->getBoneIterator();
// populate our animation list
for (int i = 0; i < NUM_ANIMS; i++)
{
mAnims[i] = mBodyEnt->getAnimationState(animNames[i]);
mAnims[i]->setLoop(true);
mFadingIn[i] = false;
mFadingOut[i] = false;
// disable animation updates
Animation* anim = mBodyEnt->getSkeleton()->getAnimation(animNames[i]);
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Ulna.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Ulna.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Humerus.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Humerus.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Stomach")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Chest")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Thigh.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Thigh.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Calf.L")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Calf.R")->getHandle());
anim->destroyNodeTrack(mBodyEnt->getSkeleton()->getBone("Root")->getHandle());
}
// start off in the idle state (top and bottom together)
setBaseAnimation(ANIM_IDLE_BASE);
setTopAnimation(ANIM_IDLE_TOP);
// relax the hands since we're not holding anything
mAnims[ANIM_HANDS_RELAXED]->setEnabled(true);
mSwordsDrawn = false;
}
//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));
Team Member
Posts: 1591
Joined: Thu Mar 02, 2006 11:29 pm
Location: Boston, MA, USA
Users browsing this forum: Google [Bot] and 1 guest