Shapes reacting against the movement tracked by kinect?

silidin's icon

Hello,
I'm trying to make a moving graphic interacts with body movement tracked by Kinect.
I could make a group of shapes follows the movement but I cant make those shapes react against the movement. For example, 12 triangles bounced buy hand stroking.

I assumed there are 3 stages of this operation.
1. calculate distances between objects and body part.
2. If the distances are less then 0.2
3. trigger the reaction

there are several problems to solve.
I managed to calculated the distances from objects to body parts (not perfectly correct though)
but the rest of the part I have no idea how I could do it.
I have been experimenting but still I couldn't figure it out.
please, give me some help

3748.val5.maxpat
Max Patch
nnimar's icon

HI,

I'm working with slidin. The question is how to detect the collision between a line and a triangle. I found the following program (http://gamedev.stackexchange.com/questions/5585/line-triangle-intersection-last-bits) that I translated into Max. It's getting complicated, I hope someone can help !!

// Find Triangle Normal
Normal.cross( P2 - P1, P3 - P1 );
Normal.normalize(); // not really needed? Vector3f does this with cross.

// Find distance from LP1 and LP2 to the plane defined by the triangle
float Dist1 = (R1-P1).dot( Normal );
float Dist2 = (R2-P1).dot( Normal );

if ( (Dist1 * Dist2) >= 0.0f) {
return false;
} // line doesn't cross the triangle.

if ( Dist1 == Dist2) {
return false;
} // line and plane are parallel

Max Patch
Copy patch and select New From Clipboard in Max.

In order to do the dot.product, cross.product, I used Zachary's abstractions (http://www.zacharyseldess.com/z.abstractions.html).