We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I created a Kinect user depth map and drew with a Point class (for manipulating the particles) that will be going into Resolume through Spout. The problem arose when I previewing the resulting code. It seemed that there is another screen at the upper right screen. I am not quite sure how to go around it. The following are a part of the codes:
void draw(){
bodyJam.update();
background(0,0,0);
translate(width/2,height/2,0);
rotateX(rotX);
rotateY(rotY);
scale(zoomF);
strokeWeight(3);
int[] userMap=bodyJam.userMap();
int[] depthMap=bodyJam.depthMap();
int steps=5;
int index;
PVector realWorldBlurp;
translate(0,0,-1000);
PVector[] realWorldMap=bodyJam.depthMapRealWorld();
beginShape(TRIANGLES);
for(int i=0; i<nodes.size(); i++){
MovingNode currentNode = nodes.get(i);
currentNode.setNumNeighbors( countNumNeighbors(currentNode,maxDistance) );
}
for(int i=0; i<nodes.size(); i++){
MovingNode currentNode = nodes.get(i);
if(currentNode.x > width || currentNode.x < 0 || currentNode.y > height || currentNode.y < 0){
nodes.remove(currentNode);
}
}
for(int i = 0; i < nodes.size(); i++){
MovingNode currentNode = nodes.get(i);
for(int j=0; j<currentNode.neighbors.size(); j++){
MovingNode neighborNode = currentNode.neighbors.get(j);
}
currentNode.display();
}
for(int y=0;y<bodyJam.depthHeight();y+=steps){
for(int x=0;x<bodyJam.depthWidth();x+=steps){
index=x+y*bodyJam.depthWidth();
if(depthMap[index]>0){
translate(width/2,height/2,0);
realWorldBlurp=realWorldMap[index];
if(userMap[index]==0)
noStroke();
else
addNewNode(realWorldBlurp.x,realWorldBlurp.y,realWorldBlurp.z,random(-dx,dx),random(-dx,dx));
}
}
}
endShape();
spout.sendTexture();
}
void addNewNode(float xPos, float yPos, float zPos, float dx, float dy){
MovingNode node = new MovingNode(xPos+dx,yPos+dy,zPos);
node.setNumNeighbors( countNumNeighbors(node,maxDistance) );
if(node.numNeighbors < maxNeighbors){
nodes.add(node);
}
}
int countNumNeighbors(MovingNode nodeA, float maxNeighborDistance){
int numNeighbors = 0;
nodeA.clearNeighbors();
for(int i = 0; i < nodes.size(); i++){
MovingNode nodeB = nodes.get(i);
float distance = sqrt((nodeA.x-nodeB.x)*(nodeA.x-nodeB.x) + (nodeA.y-nodeB.y)*(nodeA.y-nodeB.y) + (nodeA.z-nodeB.z)*(nodeA.z-nodeB.z));
if(distance < maxNeighborDistance){
numNeighbors++;
nodeA.addNeighbor(nodeB);
}
}
return numNeighbors;
}
Some lines from the Point class are as following: MovingNode(float xPos, float yPos, float zPos){ x = xPos; y = yPos; z = zPos; numNeighbors = 0; neighbors = new ArrayList(); }
void display(){
move();
strokeWeight(3);
stroke(200);
point(x,y,z);
}
void move(){
xAccel = random(-accelValue,accelValue);
yAccel = random(-accelValue,accelValue);
zAccel = random(-accelValue,accelValue);
xVel += xAccel;
yVel += yAccel;
zVel += zAccel;
x += xVel;
y += yVel;
z += zVel;
}
void addNeighbor(MovingNode node){
neighbors.add(node);
}
void setNumNeighbors(int num){
numNeighbors = num;
}
void clearNeighbors(){
neighbors = new ArrayList<MovingNode>();
}
Any help is much appreciated. Thank you