Skip to content

Instantly share code, notes, and snippets.

@heavyimage
Created April 7, 2024 10:21
Show Gist options
  • Save heavyimage/e9a1f0927711f77ead01cfa1a94f5f33 to your computer and use it in GitHub Desktop.
Save heavyimage/e9a1f0927711f77ead01cfa1a94f5f33 to your computer and use it in GitHub Desktop.
// Camera settings. Place these before first rule call.
set translation [0.113326 -0.461382 -20]
set rotation [0.678556 0.00381717 -0.734532 -0.369069 0.866368 -0.336443 0.635096 0.499391 0.589298]
set pivot [0 0 0]
set scale 0.55
set maxObjects 10000000
set raytracer::shadows false
set raytracer::samples 8
set raytracer::ambient-occlusion-samples 4
#define FLOORHEIGHT 1
#define FLOORCHUNK 2
#define FLOORSPERCHUNK 2
rule pyramid {
triangle[0,0,0;0,0,1;0.5,0.5,0.5]
triangle[0,0,1;1,0,1;0.5,0.5,0.5]
triangle[1,0,1;1,0,0;0.5,0.5,0.5]
triangle[1,0,0;0,0,0;0.5,0.5,0.5]
}
rule prism {
triangle[0,0,0;0,0,1;0,0.5,0.5]
triangle[0,0,1;1,0,1;0,0.5,0.5]
triangle[0,0.5,0.5;1,0,1;1,0.5,0.5]
triangle[1,0,0;1,0.5,0.5;1,0,1]
triangle[0,0.5,0.5;1,0,0;0,0,0]
triangle[0,0.5,0.5;1,0.5,0.5;1,0,0]
}
rule slant {
triangle[0,0,0;0,0,1;0,0.5,1]
triangle[1,0,0;1,0.5,1;1,0,1]
triangle[0,0,1;1,0,1;0,0.5,1]
triangle[0,0.5,1;1,0,1;1,0.5,1]
triangle[0,0.5,1;1,0,0;0,0,0]
triangle[0,0.5,1;1,0.5,1;1,0,0]
}
rule tall_slant {
triangle[0,0,0;0,0,1;0,1,1]
triangle[1,0,0;1,1,1;1,0,1]
triangle[0,0,1;1,0,1;0,1,1]
triangle[0,1,1;1,0,1;1,1,1]
triangle[0,1,1;1,0,0;0,0,0]
triangle[0,1,1;1,1,1;1,0,0]
}
rule sidewalk {
{s 1.1 0.01 1.1} box
//1 * {x -0.6 z -0.6 s 0.1} 11 * {x 1} 11 * {z 1} treescale
}
/*
rule treescale w 10 {{s 0.95} treescale}
rule treescale w 10 {{s 1.05} treescale}
rule treescale w 1{tree}
rule treescale w 1{}
rule tree {
{c brown y 0.25 s 0.05 0.5 0.05} box
{c green y 0.5 s 0.4 0.4 0.4} sphere
}
*/
rule blockrot {{ry 0} blockvol}
rule blockrot {{ry 90} blockvol}
rule blockrot {{ry 180} blockvol}
rule blockrot {{ry 270} blockvol}
rule blockvol w 1 {building_scale}
rule blockvol w 3 {1 * {s 0.333 x -2 z -2} 3 * {x 1} 3 * {z 1} building_scale}
rule blockvol w 3 {1 * {s 0.5 x -1.5 z -1.5} 2 * {x 1} 2 * {z 1} building_scale}
rule blockvol w 2 {1 * {s 0.25 x -2.5 z -2.5} 4 * {x 1} 4 * {z 1} building_scale}
rule blockvol w 2 {1 * {s 1 0.5 0.5 z -1.5} 2 * {z 1} building_scale}
rule blockvol w 2 {1 * {s 1 0.5 0.333 z -2} 3 * {z 1} building_scale}
rule building_scale w 2 {{s 0.95 1 0.95} building_scale}
rule building_scale w 1.5 {{s 1 1 0.8} building_scale}
rule building_scale w 1 {building_rot}
rule building_rot {{ry 0} floor}
rule building_rot {{ry 90} floor}
rule building_rot {{ry 180} floor}
rule building_rot {{ry 270} floor}
rule floor w 18 {boxfloor}
rule floor w 6 {decofloor}
rule floor w 1{crossfloor}
// floors //
// Boxfloor
rule boxfloor w 1 {boxroof}
rule boxfloor w 10 md 20 > boxroof {
1 * {s 1 FLOORHEIGHT 1} FLOORCHUNK * {y 1} box
{y FLOORSPERCHUNK} boxfloor
}
rule boxfloor w 1{{s 1.01 1 1.01} boxfloor}
rule boxfloor w 1{{s 0.95 1 0.95} boxfloor}
rule boxfloor w 1{{s 1 1 0.95} boxfloor}
rule boxfloor w 1{{s 1.01 1 1} boxfloor}
// Decofloor
rule decofloor w 1 {boxroof}
rule decofloor w 10 md 20 > boxroof {
1 * {s 1 FLOORHEIGHT 1} FLOORCHUNK * {y 1} box
1 * {x 0.333 z 0.5 s 0.2 FLOORHEIGHT 0.2} FLOORCHUNK * {y 1} box
1 * {x 0.000 z 0.5 s 0.2 FLOORHEIGHT 0.2} FLOORCHUNK * {y 1} box
1 * {x -0.333 z 0.5 s 0.2 FLOORHEIGHT 0.2} FLOORCHUNK * {y 1} box
{y FLOORSPERCHUNK} decofloor
}
rule decofloor w 1{{s 1.01 1 1.01} decofloor}
rule decofloor w 1{{s 0.95 1 0.95} decofloor}
rule decofloor w 1{{s 1 1 0.95} decofloor}
rule decofloor w 1{{s 1.01 1 1} decofloor}
rule crossfloor w 10 md 25 {
{s 0.33 FLOORHEIGHT 0.33 } box
{s 0.33 FLOORHEIGHT 0.33 x 1} box
{s 0.33 FLOORHEIGHT 0.33 x -1} box
{s 0.33 FLOORHEIGHT 0.33 z 1} box
{s 0.33 FLOORHEIGHT 0.33 z -1} box
{y FLOORHEIGHT} crossfloor
}
rule crossfloor {{s 1.01 1 1.01} crossfloor}
rule crossfloor {{s 0.9 1 0.9} crossfloor}
//TODO: rule crossfloor {crossroof}
// roof
rule boxroof w 10 {}
rule boxroof w 3 {
perimeter
tower
}
rule boxroof w 2 {{s 0.3 0.5 0.3} box}
rule boxroof w 2 {{s 0.4 0.35 0.4} box}
rule boxroof w 1 {{y 0.45} pyramid}
rule boxroof w 1{{y 0.45} prism}
rule boxroof w 1{{y 0.45} slant}
rule boxroof w 1{{y 0.45} tall_slant}
rule tower {{s 0.02 1 0.02} box}
rule tower {}
// perimeter
rule perimeter{}
rule perimeter {
{x 0.475 s 0.05 0.05 1} box
{x -0.475 s 0.05 0.05 1} box
{z 0.475 s 1 0.05 0.05} box
{z -0.475 s 1 0.05 0.05} box
}
rule block {
{s 0.85} blockrot
{s 0.85} sidewalk
}
rule city w 0.5 {block}
rule city w 16 md 3 > block {
{s 0.5 1 0.5 x 0.5 z 0.5} city
{s 0.5 1 0.5 x -0.5 z 0.5} city
{s 0.5 1 0.5 x -0.5 z -0.5} city
{s 0.5 1 0.5 x 0.5 z -0.5} city
}
{c white s 10 0.15 10} city
{c white y -0.05 s 12 0.0001 12} box
//{c white s 10 0.001 10} box
//{c white} block
//boxfloor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment