This is psuedocode

I'll try this out with a cube:

// Define vertices: for a cube, 8 vertices

Vector3[] vertices = new Vector3[8]; // An array of points with 3 coordinates (x, y, z);

vertices[0] = new Vector3(0, 0, 0);

vertices[1] = new Vector3(1, 0, 0);

vertices[2] = new Vector3(1, 1, 0);

vertices[3] = new Vector3(0, 1, 0);

vertices[4] = new Vector3(0, 0, 1);

vertices[5] = new Vector3(1, 0, 1);

vertices[6] = new Vector3(1, 1, 1);

vertices[7] = new Vector3(0, 1, 1);

// Draw line segments between vertices

drawLine(vertices[0], vertices[1]);

drawLine(vertices[0], vertices[4]);

drawLine(vertices[0], vertices[3]);

drawLine(vertices[2], vertices[6]);

drawLine(vertices[2], vertices[1]);

drawLine(vertices[2], vertices[3]);

drawLine(vertices[7], vertices[3]);

drawLine(vertices[7], vertices[4]);

drawLine(vertices[7], vertices[1]);

drawLine(vertices[5], vertices[4]);

drawLine(vertices[5], vertices[6]);

drawLine(vertices[5], vertices[1]);

That's the jist of it. Define your vertices, and draw line segments between the appropriate vertices.

This is even simplier with polygons as they lie on plane.

Someone who has actually done this with 3D volumes will probably come and point out everything I did wrong

.

I didn't mention anything about how you determine perspective (accounting for the third axis), face culling, other advanced topics. Not to mention the above psuedocode is too specific. But it got me thinking, so thanks for that.

For Java:

If I remember correctly, the Oracle SDK comes with packages for drawing 2d and 3d shapes.