How do I generate image from Kinect's point cloud in ofx?

Hi,

I am trying to create an image with point cloud just using x,y.

What is the best approach that I can do in openframeworks?

I am just trying to use something like below…

if(kinect.getDistanceAt(x, y) < 1000) {
    // draw dot with black color on x, y of the dynamically created image
}
else
{
    // draw dot with white color on x, y of the dynamically created image
}

anybody?

did you see the ofxkinect example and how it draws point clouds?

/Applications/of_v0.9.3_osx_release/examples/addons/kinectExample

void ofApp::drawPointCloud() {
	int w = 640;
	int h = 480;
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_POINTS);
	int step = 2;
	for(int y = 0; y < h; y += step) {
		for(int x = 0; x < w; x += step) {
			if(kinect.getDistanceAt(x, y) > 0) {
				mesh.addColor(kinect.getColorAt(x,y));
				mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
			}
		}
	}
	glPointSize(3);
	ofPushMatrix();
	// the projected points are 'upside down' and 'backwards' 
	ofScale(1, -1, -1);
	ofTranslate(0, 0, -1000); // center the points a bit
	ofEnableDepthTest();
	mesh.drawVertices();
	ofDisableDepthTest();
	ofPopMatrix();
}