Skip to content

Instantly share code, notes, and snippets.

@cjameshuff
Created August 23, 2013 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjameshuff/6314226 to your computer and use it in GitHub Desktop.
Save cjameshuff/6314226 to your computer and use it in GitHub Desktop.
auto tfn = fn_handle{new TerrainFn};
thickness = 10.0f;
layerIdx = 1;
tfn = fn_handle{new PlaneLayer(std::move(tfn), layerIdx++, elev, 100.0f)};
tfn = fn_handle{new Turbulate(std::move(tfn), turbScl, turbAmp)};
elev += thickness;
layerIdx = igneous;
for(int j = 0; j < 4; ++j)
{
tfn = fn_handle{new PlaneLayer(std::move(tfn), layerIdx++, elev, 100.0f)};
tfn = fn_handle{new Turbulate(std::move(tfn), turbScl, turbAmp)};
elev += thickness;
}
thickness = 5.0f;
layerIdx = metamorphics;
for(int j = 0; j < 8; ++j)
{
tfn = fn_handle{new PlaneLayer(std::move(tfn), layerIdx++, elev, 100.0f)};
tfn = fn_handle{new Turbulate(std::move(tfn), turbScl, turbAmp)};
elev += thickness;
}
layerIdx = sedimentary;
for(int j = 0; j < 8; ++j)
{
tfn = fn_handle{new PlaneLayer(std::move(tfn), layerIdx++, elev, 100.0f)};
tfn = fn_handle{new Turbulate(std::move(tfn), turbScl, turbAmp)};
elev += thickness;
}
tfn = fn_handle{new Fault(std::move(tfn), mk_vec4(0.0f, elev, 0.0f), mk_vec4(1.0f, 1.0f, 0.0f), 20.0)};
tfn = fn_handle{new Fault(std::move(tfn), mk_vec4(-200.0f, elev, 0.0f), mk_vec4(1.0f, 1.0f, 0.0f), 20.0)};
SimpleImage output(1024, 512, 3);
for(int ix = 0; ix < output.width; ++ix)
for(int iy = 0; iy < output.height; ++iy)
{
float x = ix - output.width/2.0f, y = iy - output.height/2.0f;
VolumeVal val = (*tfn)(mk_vec4<float>(x, y, 0.5f));
output.SetPixelRGB(ix, iy, colors[val.type]);
}
TargaFileInfo::Write("testout.tga", output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment