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.
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 )
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.