2015-03-13 2 views
0

Проблема, с которой я сталкиваюсь, заключается в том, что альфа изображения не вычисляется. Я пробовал все все режимы наложения и все. Вот файл PNG, если вам нужно внимательно его осмотреть. imageAlpha класса, не показывающего

lines[] mylinesArray = new lines[1000]; 
import processing.opengl.*; 
import SimpleOpenNI.*; 
SimpleOpenNI kinect; 
import peasy.*; 

PeasyCam cam; 
void setup() { 
    size(1028, 768, OPENGL); 
    ambientLight(0, 0, 255); 

    for (int i = 0; i<mylinesArray.length; i++) { 
    float prp = -1000; 
    float vrp = -1000; 
    float z = random(prp, 1000); 
    float x = random(vrp, 800); 
    float y = -655; 
    float u =random(-100, -200); 

    mylinesArray[i] = new lines(x, y, z, u); 
    } 
    kinect = new SimpleOpenNI(this); 
    kinect.enableDepth(); 
    kinect.enableUser(); 
    kinect.setMirror(true); 
    frameRate(30); 
    cam = new PeasyCam(this, 0, 0, 0, 1000); 
} 
void draw() { 
    kinect.update(); 
    background(255, 255, 255, 1000); 
    translate(width/2, height/2, 0); 
    rotateX(radians(180)); 
    IntVector userList = new IntVector(); 
    for (int i=0; i<mylinesArray.length; i++) { 
    // println(i); 
    mylinesArray[i].draw(); 

    //println("still doing it"); 
    } 

    kinect.getUsers(userList); 
    if (userList.size() > 0) { 
    int userId = userList.get(0); 
    if (kinect.isTrackingSkeleton(userId)) { 
     PVector leftHand = new PVector(); 
     kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_LEFT_HAND, leftHand); 
     PVector rightHand = new PVector(); 
     kinect.getJointPositionSkeleton(userId, 
     SimpleOpenNI.SKEL_RIGHT_HAND, 
     rightHand); 
     PVector leftFoot = new PVector(); 
     kinect.getJointPositionSkeleton(userId, 
     SimpleOpenNI.SKEL_LEFT_FOOT, 
     leftFoot);         
     //PVector differenceVector = PVector.sub(leftHand, rightHand); 
     //float magnitude = differenceVector.mag(); 
     //differenceVector.normalize(); 
     kinect.drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HAND, SimpleOpenNI.SKEL_RIGHT_HAND); 

     stroke(255, 0, 0); 
     strokeWeight(5); 
     drawSkeleton(userId); 
     pushMatrix(); 
     stroke(175); 
     strokeWeight(1); 
     println(leftFoot.x); 
     println(leftFoot.y); 
     println(leftFoot.z); 
     line(leftHand.x, leftHand.y, leftHand.z, rightHand.x, rightHand.y, rightHand.z); 
     //fill(250); 
     translate(rightHand.x, rightHand.y, rightHand.z); 
     popMatrix(); 
    } 
    } 
} 
void drawSkeleton(int userId) { 
    drawLimb(userId, SimpleOpenNI.SKEL_HEAD, SimpleOpenNI.SKEL_NECK); 
    drawLimb(userId, SimpleOpenNI.SKEL_NECK, 
    SimpleOpenNI.SKEL_LEFT_SHOULDER); 
    drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, 
    SimpleOpenNI.SKEL_LEFT_ELBOW); 
    drawLimb(userId, SimpleOpenNI.SKEL_LEFT_ELBOW, 
    SimpleOpenNI.SKEL_LEFT_HAND); 
    drawLimb(userId, SimpleOpenNI.SKEL_NECK, 
    SimpleOpenNI.SKEL_RIGHT_SHOULDER); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, 
    SimpleOpenNI.SKEL_RIGHT_ELBOW); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_ELBOW, 
    SimpleOpenNI.SKEL_RIGHT_HAND); 
    drawLimb(userId, SimpleOpenNI.SKEL_LEFT_SHOULDER, 
    SimpleOpenNI.SKEL_TORSO); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_SHOULDER, 
    SimpleOpenNI.SKEL_TORSO); 
    drawLimb(userId, SimpleOpenNI.SKEL_TORSO, 
    SimpleOpenNI.SKEL_LEFT_HIP); 
    drawLimb(userId, SimpleOpenNI.SKEL_LEFT_HIP, 
    SimpleOpenNI.SKEL_LEFT_KNEE); 
    drawLimb(userId, SimpleOpenNI.SKEL_LEFT_KNEE, 
    SimpleOpenNI.SKEL_LEFT_FOOT); 
    drawLimb(userId, SimpleOpenNI.SKEL_TORSO, 
    SimpleOpenNI.SKEL_RIGHT_HIP); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, 
    SimpleOpenNI.SKEL_RIGHT_KNEE); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_KNEE, 
    SimpleOpenNI.SKEL_RIGHT_FOOT); 
    drawLimb(userId, SimpleOpenNI.SKEL_RIGHT_HIP, 
    SimpleOpenNI.SKEL_LEFT_HIP); 
} 
void drawLimb(int userId, int jointType1, int jointType2) 
{ 
    PVector jointPos1 = new PVector(); 
    PVector jointPos2 = new PVector(); 
    float confidence; 
    // draw the joint position 
    confidence = kinect.getJointPositionSkeleton(userId, jointType1, jointPos1); 
    confidence = kinect.getJointPositionSkeleton(userId, jointType2, jointPos2); 
    line(jointPos1.x, jointPos1.y, jointPos1.z, 
    jointPos2.x, jointPos2.y, jointPos2.z); 
    //println(SimpleOpenNI.SKEL_RIGHT_KNEE); 
    println(SimpleOpenNI.SKEL_RIGHT_FOOT); 
} 
// user-tracking callbacks! 
void onNewUser(SimpleOpenNI curContext, int userId) { 
    println("start pose detection"); 
    kinect.startTrackingSkeleton(userId); 
} 


void onLostUser(SimpleOpenNI curContext, int userId) 
{ 
    //println("onLostUser - userId: " + userId); 
} 

void onVisibleUser(SimpleOpenNI curContext, int userId) 
{ 
    // println("onVisibleUser - userId: " + userId); 
} 

class lines { 

    color fillColor; 
    color strokeColor; 
    PVector dot1; 
    PVector dot2; 
    PImage photo; 

    lines(float xpos, float ypos, float zpos, float ypos2) { 
    dot1 = new PVector(500+xpos, ypos, 700+zpos); 
    dot2 = new PVector(500+xpos, ypos2, 700+zpos); 
    photo = loadImage("Bounce_00000.png"); 
    } 


    //} 
    void draw() { 
    pushMatrix(); 
    fill(255); 


    line(dot1.x, dot1.y, dot1.z, dot2.x, dot2.y, dot2.z); 
    image(photo, 0, 0); 
    blendMode(ADD); 

    stroke(0); 


    popMatrix(); 
    } 


} 
+0

Просьба указать трассировку стека исключения. –

+0

@ zsolt.kocsi Извините, что это был несчастный случай. –

+0

Это много кода без особого объяснения проблемы. – nobar

ответ

0

исправил: хитрость заключается в том, чтобы отключить тест глубины. hint (DISABLE_DEPTH_TEST);

Смежные вопросы