Hello;
I´m trying to catch some 3d Particle captured from the ofKinect in order to trace them.
I´m stocked thinking how to:
- Make a 3D cube from the 4 ofPoints of the back of the cube.
- render just the ofPoint that are inside it
for now I just get this:
by:
---------- update
if (ptsCnt > 3){
ptsCnt = 0;
ofVec3f linA = surface[0] - surface[2];
ofVec3f loc = surface[2] + (linA/2);
cam.setTarget(loc);
ofVec3f distance = linA;
ofVec3f linB = surface[1] - surface[3];
linB.normalize();
distance.perpendicular(linB);
cam.setGlobalPosition(loc * distance);
cam.setDistance(100);
}
------ draw
// 3D POINTS
ofSetColor(255);
ofPoint p;
glBegin(GL_POINTS);
int step = panel.getValueF("definition");
for(int y = 0; y < h; y += step) {
for(int x = 0; x < w; x += step) {
p = kinect.getWorldCoordinateFor(x, y) * 400;
glVertex3f(p.x, p.y, p.z);
}
}
glEnd();
// 3D Surface
ofFill();
ofSetColor(250, 0, 0,100);
glBegin(GL_POLYGON);
for(int i=0;i<4;i++)
glVertex3f(surface[i].x,surface[i].y,surface[i].z);
glEnd();
ofSetColor(0, 0, 255,255);
ofLine(surface[0], surface[2]);
ofLine(surface[1], surface[3]);
the Point order is this:
[0] --- [1]
| |
[3] --- [2]
I usualy do something like:
if ( ( x > space->xLeft) )
& ( x < space->xRight)
& ( y > space->yTop)
& ( y < space->yBottom)
& ( z > space->zFront)
& ( z < space->zBack) )
But in this case seams imposible because I´ll have 8 points of the corners instad 8 positions of the walls.
I don´t have a mathematical knowledge background so this seems like something posible but really really complicated to me.
thanks
Patricio