Forums > MaxMSP

Shapes reacting against the movement tracked by kinect?

April 21, 2012 | 4:43 pm

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

Attachments:
  1. val5.maxpat

April 22, 2012 | 10:40 am

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

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

– Pasted Max Patch, click to expand. –

Viewing 2 posts - 1 through 2 (of 2 total)