Picking

I have some picking code done by setting rendermode to select. It works in that my hit count = 1 (instead of 0) when I click on a 3d object. What doesnt work is…


String chooseNum = "";
if(hits > 0) {                                               // If There Were More Than 0 Hits
int choose = buffer[3];                                 // Make Our Selection The First Object
int depth = buffer[1];                                  // Store How Far Away It Is

for (int i = 1; i < hits; i++) {                // Loop Through All The Detected Hits
    // If This Object Is Closer To Us Than The One We Have Selected
    if (buffer[i * 4 + 1] < (int)depth) {
      choose = buffer[i * 4 + 3];                      // Select The Closer Object
      depth = buffer[i * 4 + 1];                       // Store How Far Away It Is
    }
}
            chooseNum = "#" + choose;
            //testMessage = "[HIT] choose: " + choose;

}

choose in the above code is always 0 regardles of how many items are on the screen. Any thoughts?