Kinect & Irrlicht

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Tekkai
Posts: 24
Joined: Tue Mar 30, 2010 2:02 pm
Contact:

Kinect & Irrlicht

Post by Tekkai »

Hi all,

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;
    }
 
To make the model animable by Kinect, you will have to initialize the model as you use to do in Irrlicht, but using the CPlayer class and calling to an Init function after the object is created.

Code: Select all

 
    scene::CPlayer* mNodePepin;
    scene::IAnimatedMesh* prov = mSmgr->getMesh("Media/Objs/NinoKinectTexture.X");
    mNode = (scene::CPlayer *) mSmgr->addAnimatedMeshSceneNode(prov);
    mNode->Init();
 
On your update loop, it's mandatory to call the Update function of the object. As well as the Update function for the Kinect class.

Code: Select all

 
    CKinect::GetInstance()->Update();
    mNode->Move();
 
Here you can download both classes: http://www.box.com/s/g60qqxjexkfuzmvtbn2k

Enjoy!
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: Kinect & Irrlicht

Post by Virion »

wow sounds cool. brb i go buy kinect.
Post Reply