Applying ofxBox2d to a Kinect Puppet

Hi,

I am trying to create a 2D puppet using ofxOpenNi. I used png images for body parts and came up with the following.

Now I want to add Box2D support for this app and let the user interact with few virtual objects… (circles, boxes etc…). My problem is that I can’t figure out how to convert the body parts into box2D objects.

Do I need to create invisible b2_staticBodys for each body part? If so, can I move them along with the body parts by mapping them to the ofxOpenNi skeleton joints?

I really appreciate your help on this.
Thanks!
-Lahiru.

![](http://forum.openframeworks.cc/uploads/default/2102/Screen shot 2012-01-16 at 6.51.11 PM.png)

Hi,

Basically, I want to something like this with the above puppet. Please help. :slight_smile:

http://www.youtube.com/watch?feature=player-detailpage&v=aIUkoRihT4w#t=90s

I think the trick would be to create regular box2d objects, then every frame set their position and rotation to be based on your model. your box2d model could be mostly rectangles with a circle for the head.

I think in box2d there is a way to tell objects to ignore each other by putting them in a group or setting a collision mask - that way you don’t have to worry about the limbs exploding when they hit each other. ( http://www.cocos2d-iphone.org/forum/topic/14546 )

Hope that helps!

Thank you so much for the reply!

I managed to do it using few b2_staticBody boxes. The outcome is not accurate to the last pixel, but somewhat satisfactory for the moment. :slight_smile:

Hey Lahiru, do you have some sample code to share?
I also have a puppet that I want to animate using coordinates coming from a skeleton tracked used ofxOpenNI.
Thanks!

I was thinking about rotating the image using the slope from the begin and end joints, but I think you just can rotate an image 90, 180, 270 degrees.
There’s not a method in ofxImage to rotate using an arbitrary number, so maybe with push/translate/rotate/pop this can be achieved too.