I just finished a project that needs to use Kinect in order to animate the main character and I want to share some of my code that I made to integrate Kinect into irrlicht. The project was started the last year, so the code is working with the earliest SDK of Kinect (OpenNI 1.0.0 & Primesense-NITE 1.3.0). The Kinect was setup following the next article How-to: Successfully Install Kinect on Windows (OpenNI and NITE) . The model I used to test was made in 3D Studio Max and exported in .X object format with Panda Exporter. One of the restrictions of my code is that the bones must be named as in the CPlayer class are named, otherwise it will crash. You can also rename the bone names in the code so they match with you're object. Feel free to adapt this code into any other object file format, I can imagine that other exporters / programs for modelling will use other axis orientation, but this should be minor changes into the code.
The class CPlayer is the responsible of drawing the object and animate it, meanwhile Kinect class will take care about the connection with Kinect, and do all the calculations necessary to return the correct angle of rotation. The class Kinect, was programed using the Singleton pattern, and must be initialized in the beginning of the program.
Code: Select all
bool bKinectOK = CKinect::GetInstance()->Init();
if ( !bKinectOK )
{
cout << "Kinect or device not correctly initialized" << endl;
return false;
}
Code: Select all
scene::CPlayer* mNodePepin;
scene::IAnimatedMesh* prov = mSmgr->getMesh("Media/Objs/NinoKinectTexture.X");
mNode = (scene::CPlayer *) mSmgr->addAnimatedMeshSceneNode(prov);
mNode->Init();
Code: Select all
CKinect::GetInstance()->Update();
mNode->Move();
Enjoy!