box2d kinect object movement question

I’m doing a kinect + box2d thing a bit like this:

http://www.vimeo.com/73763231

http://vimeo.com/49516871

(not mine)

a blob is turned into triangles, then into box2d triangles for falling objects to land on.

the things is, if i move fast, my arm always goes through the objects and often objects get stuck inside my body. if i move my arms up slowly, yes objects remain sitting on my arms, so the physics of my body is an obstacle to the objects.

however i want to be able to whack the objects with force so they change direction, not just get effected by gravity. anyone have any thoughts on how this could be done? use the motion vectors of the greyscale image maybe as applied forces?

also, every frame im destroying all triangles and generating new ones for the blobs. would it speed this up if i were to have a big fixed list of triangles and reuse them, so no destroy and create each frame? any complications of doing this with box2d?

thanks! :slight_smile:

I use a blurry version of the thing I want to repel away from here – ie, scale down the contour image, blur it, and turn that into a vector field that adds forces to your objects:

https://github.com/ofZach/algo2012/tree/master/week6/vectorField-video

if you imagine a blurry version of your silhouette, it’s basically saying feel a force right now that moves you from black to white. In the example I show both moving towards the object and moving away.

I wonder if you could scale this force in relationship to movement, the more movement you have, the more you use it? When you are moving slowly, you use the standard box2d way, but when you are moving quickly, this ramps up. Sometimes it’s a bit funky to add your own physics to box 2d, but I’ve got examples of that somewhere if you hit a snag.

ps: also, the more you blur it, the more reach your contour has… it’s great for achieving what you want (objects not falling through the moving body) but it means less landing directly on the body.

Have you investigated using KINEMATIC bodies? These are designed for user controlled elements where you set the velocities manually. They do not have collisions with each other but will collide with other DYNAMIC bodies. I’ve used them successfully but not in this context. . . I think the big complication here is continuity. You’d have to create geometry that can follow the form of the body itself rather than recreating the triangles each frame and maybe that’s too much to ask?

I had exactly the same problem…
Because you are creating the polygon (body shape) at a different position every frame, if you move fast it can be that you draw it around a rigid body…so it will be inside your silhouette…

To avoid that I just used a function to check in an object is inside your blob, and in that case you can decide what to do with it (I made the object start to fall down again).

Maybe it’s not the best solution, but it works…Some post processing on the img (like blur) it might help, but not solve the problem.

L

Hi Chris,

This is a common problem in 3D collision detection – the usual way to solve it, at least when dealing with an object that moves from fully outside an object’s 3D ‘perimeter’ (ie surface) to inside it is to calculate the dot product of the surface normal and a direction vector from the surface to the object. (You would need to find a single point on the surface to to use for this, perhaps the closest point on the surface to the average of the before/after position). If the dot product before and after changes sign then the object is has moved from one side of the surface to the other.

In 2D, you could do this by calculating a skeleton from the blob, then for each line segment in the skeleton calculate if the object you’re checking moves from the ‘left’ side of the line segment to the ‘right’ side, which would indicate it has passed through.

Complicated, I know…
HTH
D

see this: https://github.com/jasonrwalters/SmackTheSnowman