Indeed. It's actually quite easy.
1. Take two points of (x1, y1, z1) and (x2, y2, z2)
2. Translate each point to the 2D screen by dividing by the Z component. i.e.:
1 2 3 4
| int scrx1 = x1/z1; int scry1 = y1/z1; int scrx2 = x2/z2; int scry2 = y2/z2; |
3. Decide where the zero point is in the universe. Usually 0,0,0 is the center of the screen, so you need to translate by half the screenWidth. i.e.:
1 2 3 4 5 6 7
| int translatex = screenWidth/2; int translatey = screenWidth/2;
scrx1 += translatex; scry1 += translatey; scrx2 += translatex; scry2 += translatey; |
4. Draw the line from scrx1,scry1 to scrx2,scry2 using the standard drawLine() method.
Note that this technique produces weird results when one of the coordinates falls behind you. In those cases you need to clip on 3D bounds. :-)