Don't know if this picture/link will work but I just posted one to the facebook page:
http://www.facebook.com/photo.php?fbid=344621935560331&set=a.218418391514020.54331.204533646235828Cave generation works in two phases:
1) random cave influencers are generated using a semi-complicated algorithm
2) when the terrain is generated, these influencers are used to roughly carve the caves/gorges out of the terrain
With the new caveSystemCreated hook, scripts can add their own caves between steps 1 and 2.
The one that made that picture looks like this:
import mythruna.db.cave.*;
on( [caveSystemCreated] ) {
type, event ->
event.generator.addPoint( 512, 512 ).setRadius(50).setStrength(10);
event.generator.addPoint( 512, 512 ).setRadius(20).setStrength(-20);
}
Caves are only carved out of where there would have been land, so you can't plop an arbitrary blob in the middle of space... but you can do all kinds of other weird things like the above with adding/subtracting negative areas.
Here is another script that makes a small crater around the spawn point connected to a deep angled tunnel that connects to a submerged gorge:
import mythruna.db.cave.*;
on( [caveSystemCreated] ) {
type, event ->
// Create a relatively smooth crater centered on the surface at the spawn point.
// Proper elevation is determined from the normal fractal terrain.
def p = event.generator.addPoint( 512, 512 ).setRadius(10).setStrength(10);
// This generates a cylindrical cave running from the center of that crater
// down and to the west. In world seed=100, this is a 60 meter deep tunnel.
event.generator.addLine( 512, 512, p.center.z, 500, 512, 20 );
// From there, this generates a long, roughly 12-15 meter high, 10 meter wide (diameter)
// unground "gorge"... basically a tunnel that is tall.
event.generator.addWall( 500, 512, 20, 490, 400, 30 );
}
By the time these scripts are run, all of the random caves have been generated for that area and so the scripts could technically look there and see what is already there.
And by the way, this is exactly the same way that dungeons and towns will be generated and they will allow for the same level of customization... though obviously they will be much different than simple caves are.