저는 현재 Fine Art에서 BA 과정을 밟고 있으며, 최근 Greg Borenstein의 'Making Things See'를 읽음으로써 프로그래밍을 배우려고 시작했습니다.Kinect. 함수에서 서로 영향을 미치지 않으면 서 다중 질량 중심으로 어떻게 작업합니까?
내가 개발중인 작품은 시청자가 Kinect를 사용하여 갤러리 공간을 돌아 다니면서 여러 개의 질량 중심을 추적하려는 시도입니다. 시청자가 화면에 흔적을 남길 수 있기를 바랬습니다. 또한 특정 지역에 가까워지면 선이나 기타 등으로 그 근접이 표시됩니다. 나는 하나의 흔적을 남길 수 있었지만, 다른 사람이 시야에 들어 오자마자 그들의 점수가 갑자기 연결됩니다. '근접선'은 또한 현재 사용자가 아닌 이전 사용자에게만 작용하는 것처럼 보입니다.
내 질문에 정말 내 모든 사용자에게 적용 할 수있는 함수 또는 클래스를 만들 수 있도록 각 새 사용자를 분리하는 방법에 오는 것 같아요하지만 서로 간섭하지 ..? 어떤 도움은 대단히 감사하겠습니다
class Hotpoint {
PVector center;
color fillColor;
color strokeColor;
int size;
int pointsIncluded;
int maxPoints;
boolean wasJustHit;
int threshold;
Hotpoint(float centerX, float centerY, float centerZ, int boxSize) {
center = new PVector(centerX, centerY, centerZ);
size = boxSize;
pointsIncluded = 0;
maxPoints = 1000;
threshold = 0;
strokeColor = color(random(255), random(255), random(255));
fillColor = 0;
}
void setThreshold(int newThreshold){
threshold = newThreshold;
}
void setMaxPoints(int newMaxPoints){
maxPoints = newMaxPoints;
}
void setColor(float red, float blue, float green){
fillColor = strokeColor = color(red, blue, green);
}
boolean check(PVector point) {
boolean result = false;
if (point.x > center.x - size/2 && point.x < center.x + size/2) {
if (point.y > center.y - size/2 && point.y < center.y + size/2) {
if (point.z > center.z - size/2 && point.z < center.z + size/2) {
result = true;
pointsIncluded++;
}
}
}
return result;
}
void draw() {
pushMatrix();
translate(center.x, center.y, center.z);
shapeMode(LINES);
noFill();
stroke(red(strokeColor), blue(strokeColor), green(strokeColor), 255);
box(size);
popMatrix();
}
float percentIncluded() {
return map(pointsIncluded, 0, maxPoints, 0, 1);
}
boolean currentlyHit() {
return (pointsIncluded > threshold);
}
boolean isHit() {
return currentlyHit() && !wasJustHit;
}
void clear() {
wasJustHit = currentlyHit();
pointsIncluded = 0;
}
}
여기에 프로그램이 지금까지의 ...
import processing.opengl.*;
import SimpleOpenNI.*;
import peasy.*;
PeasyCam cam;
SimpleOpenNI kinect;
ArrayList<PVector> trails;
Hotpoint piece;
PVector currentPosition;
PVector previousPosition;
int pieceX = 0;
int pieceY = 0;
int pieceZ = 2000;
int pieceSize = 500;
void setup() {
size(1280, 680, OPENGL);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);
kinect.setMirror(true);
trails = new ArrayList();
piece = new Hotpoint(pieceX, pieceY, pieceZ, pieceSize);
cam = new PeasyCam(this, 0, 0, 0, 1000);
}
void draw() {
background(255);
kinect.update();
rotateX(radians(180));
lights();
stroke(0);
strokeWeight(3);
IntVector userList = new IntVector();
kinect.getUsers(userList);
piece.draw();
for (int i=0; i<userList.size(); i++) {
int userId = userList.get(i);
PVector positionCenter = new PVector();
kinect.getCoM(userId, positionCenter);
trails.add(positionCenter);
createTrail();
piece.check(positionCenter);
if(piece.check(positionCenter) == true) {
stroke(255, 0, 0);
line(positionCenter.x, positionCenter.y, positionCenter.z,
pieceX, pieceY, pieceZ);
stroke(0);
}
}
}
void createTrail() {
for (int e=1; e < trails.size(); e++) {
currentPosition = trails.get(e);
previousPosition = trails.get(e-1);
if (currentPosition.z < 1) {
trails.clear();
}
else {
stroke(0);
line(previousPosition.x, previousPosition.y, previousPosition.z,
currentPosition.x, currentPosition.y, currentPosition.z);
}
}
}
그리고 이것은 트리플 클래스 부분입니다 ...!
는편집 :
이 당신의 시간과 응답 @의 jesses.co.tt 주셔서 너무 감사하지만 예를 들어 ... 그것을 이해하는 데 문제가 있었어요은을 통해 루프 userList는 사용자 배열과 다릅니다. 한 번에 두 가지 이상을 묻는 것이 걱정됩니다. 그래서 사람들이 연결되지 않은 상태에서 여러 개의 산책로를 그리는 방법을 먼저 이해하려고 노력했습니다.import processing.opengl.*;
import SimpleOpenNI.*;
import peasy.*;
SimpleOpenNI kinect;
PeasyCam cam;
ArrayList<PVector> trails1;
ArrayList<PVector> trails2;
PVector currentPosition;
PVector previousPosition;
void setup() {
size(1280, 800, OPENGL);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableUser(SimpleOpenNI.SKEL_PROFILE_NONE);
kinect.setMirror(true);
trails1 = new ArrayList();
trails2 = new ArrayList();
cam = new PeasyCam(this, 0, 0, 0, 1000);
}
void draw() {
kinect.update();
rotateX(radians(180));
background(255);
IntVector userList = new IntVector();
kinect.getUsers(userList);
//println(userList);
for (int i=0; i<userList.size(); i++) {
int userId = userList.get(i);
//println(userId);
PVector positionCenter = new PVector();
kinect.getCoM(userId, positionCenter);
stroke(0);
strokeWeight(10);
point(positionCenter.x, positionCenter.y, positionCenter.z);
if (userId == 1) {
trails1.add(positionCenter);
createTrail1();
}
else if (userId == 2) {
trails2.add(positionCenter);
createTrail2();
}
}
}
void createTrail1() {
for (int e=1; e < trails1.size(); e++) {
currentPosition = trails1.get(e);
previousPosition = trails1.get(e-1);
if (currentPosition.z < 1) { // [possibly x or y or all?]
trails1.clear();
}
else {
// if (currentPosition.x != 0 || previousPosition.x != 0) { // [not working]
stroke(0);
line(previousPosition.x, previousPosition.y, previousPosition.z,
currentPosition.x, currentPosition.y, currentPosition.z);
//trails.clear();
}
}
}
void createTrail2() {
for (int e=1; e < trails2.size(); e++) {
currentPosition = trails2.get(e);
previousPosition = trails2.get(e-1);
if (currentPosition.z < 1) { // [possibly x or y or all?]
trails2.clear();
}
else {
// if (currentPosition.x != 0 || previousPosition.x != 0) { // [not working]
stroke(0);
line(previousPosition.x, previousPosition.y, previousPosition.z,
currentPosition.x, currentPosition.y, currentPosition.z);
//trails.clear();
}
}
}
그래서,이 두 사람을 위해 일 것이다, 나는 많은 사람들 한정된 수의 작업 끔찍하게 긴 프로그램을 쓸 수 있지만, 동적으로 무엇 난 정말 싶습니다 ... 입니다 'if (userId == 1) {'인 경우, 모든 사람들을 위해 일하기를 원합니다. 그런 다음 흔적 부분에서 새 사람이 등장 할 때마다 새로운 길을 따라야합니다. 보기 'void onNewUser (int userId) {'또는 뭔가 사용하는 줄 ..?
아차, 내가, 트리플 클래스를 포함하는 것을 잊었을 거라고는 현재 편집되고 그래서! – basicallyright