mercoledì, settembre 28, 2011

Just for fun! Kinect + Maya


Kinect + Processing + Maya from Davide Madeddu on Vimeo.
A skeleton setup in Maya controlled with Kinect. Processing sends xyz coordinates of the joints to Maya with the UDP protocol. Unfortunately there is a small lag between Processing and Maya, but it works!


A simple HowTo!

**Premise: This is a very simple test, maybe you can find an easy way to do this or a more fast code.

I used SimpleOpenNI and UDP libraries in Processing and Python UDP Socket in Maya.
The code in Processing and Python is very simple, and implement UDP commands to send xyz coordinates to Maya via UDP protocol with Python.

In Processing you can start from scratch or open a basic SimpleOpenNI example and edit it. Basically, I followed these steps:
First of all you will need to install the UDP libraries in Processing ;-)
Define UDP object
Create the PVector to store the joint coordinates
Define the UDP message with the values of PVector.x,PVector.y,PVector.z
Use void drawSkeleton from SimpleOpenNI libraries.

You can download the Processing sketch <here>

In Maya was very simple too!
I scripted in Python (I am learning it!) and I used the UDP protocol to receive the coordinates from Processing. You can find all UDP commands searching UDP python over Internet and you will apply the same syntax to Maya.
First I created a series of locators (you can also script this step) named as bones, then I created the skeleton and constrained the joints to the locators.
On the "script side" I imported socket, I defined UDP IP, PORT, etc (must be the same as in Processing). I used a simple syntax found in UDP help reference, splitted the incoming message and assigned xyz to the locators with setAttr.
A boolean stop the streaming when is pressed the "q" key.

You can download the Python script for Maya <here>

Have fun and feel free to contact me if you want! Bye