if you want it to be 3d i would look for a voxel engine. for example you could try voxlap by ken silverman.

if you want it to be polygon based then it would be like writing a modeling application. with functions like extrude and so on.