DEF cyl (h::IsReal)(r::IsReal)(n::IsInt) = circle:r:<n,1> * Q:h;
DEF MyTrunCone (r1,r2,h::IsReal)(n::IsInt) =
MAP:[x*cos~S2,x*sin~S2,z]:(Q:1 * (Q~#:n):(2*PI/n))
WHERE
x= K:r1 + s1 * (K:r2 - k:r1),
y= k:0,
z= s1 * K:h
END;
%-- Color definition ------------------------------------%
DEF terrain = RGBCOLOR:<0.70,0.50,0.20>;
%-- Details modelling -----------------------------------%
DEF pathpoints = <<0,0>,<0.5,0>,<0.1,0.8>,<0.6,0.7>,<0.9,0.4>>;
DEF pathstripe = BezierStripe:<pathpoints,0.025,22>;
DEF mapping= T:<1,2,3>~(CONS:sup_c1_c2);
DEF mytree = STRUCT:<
t:3:5:(MyTrunCone:<8,0,12>:5) COLOR green,
cylinder:<2,8>:5 COLOR brown >;
DEF controlTrees = (STRUCT~CONS:(AA:mapping:pathpoints)):mytree;
DEF hutPlan = MKPOL:<<<5,-2>,<-5,-2>,<-5,2>,<5,2>,<2,-2>,
<-2,-2>,<-2,5>,<2,5>>,<1..4,5..8>,<1..2>>;
DEF hutSection= MKPOL:<<<5,2>,<-2,3>,<-2,-1>,<5,-1>,<0,5>>,<1..4,<2,4,5>>,<1..2>>;
DEF mountain_hut = COLOR:<hutPlan (<1,2,0> XX <0,1,2>) hutSection,brown>;
DEF hutmapped =(mapping:<0.90,0.30>):(S:<1,2,3>:<3,3,3>:(mountain_hut));
%-- Bezier Definition -----------------------------------%
DEF c1 = Bezier:S1:<c1a,<460,250,50>,<470,100,0>,<480,0,280>,<490,-200,200>>;
DEF m1 = Bezier:S1:<m1a,<325,200,80>,<330,150,80>,<335,50,170>,<340,-160,150>>;
DEF m2 = Bezier:S1:<m2a,<162,250,100>,<164,150,120>,<166,50,120>,<168,-130,200>>;
DEF c2 = Bezier:S1:<c2a,<0,300,100>,<0,150,150>,<0,50,150>,c2Last %<0,-100,400>%>;
DEF c1a = <450,400,0>; DEF m1a = <320,300,0>;
DEF m2a = <160,450,0>; DEF c2a = <0,400,0>;
DEF c2Last = <0,-100,400>;
DEF c0 = Bezier:S1:<c0a,<630,800,50>,<760,700,100>,<900,600,0>>;
DEF c3 = Bezier:S1:<c3a,<-400,250,200>,<-400,100,300>,<-400,0,150>>;
DEF m0 = Bezier:S1:<m0a,<800,200,0>,<900,0,0>,<1000,-200,0>>;
DEF m3 = Bezier:S1:<m3a,<-200,150,50>,<-200,50,150>,<-200,-50,150>>;
DEF c0a = <500,900,0>; DEF m0a = <600,400,0>;
DEF c3a = <-400,400,0>; DEF m3a = <-200,300,0>;
DEF sup_c1_c2 = Bezier:S2:<c1,m1,m2,c2>;
DEF sup_c0_c1 = Bezier:S2:<c0,m0,c1>;
DEF sup_c2_c3 = Bezier:S2:<c2,m3,c3>;
DEF b12 = Bezier:S1:<c1a,m1a,m2a,c2a>;
DEF b56 = Bezier:S1:<c0a, b56a>;
DEF sup_b12_b56 = Bezier:S2:<b12,m0a,b56>;
DEF sup_lake = Bezier:S2:<bLake1,bLakem,bLake2>;
DEF b56a = <200, 1000, 0>;
DEF l2 = <-400,1200,0>;
DEF l1 = <-100,1200,0>;
DEF bLake1 = Bezier:S1:<c2a,m0a,b56a>;
DEF bLakem = Bezier:S1:<m3a,l1>;
DEF bLake2 = Bezier:S1:<c3a,l2>;
%-- Colored Domains -------------------------------------%
%DEF SIMPLECOLOR(colour::IsSeq)=<colour,<0.2,0.2,0.2>,<0.2>,<0,0,0>,<0.2>,<0>>;%
DEF FLOATSCALE(n::IsInt)(begin,ending::IsReal)=AA:(K:begin+(ID*K:(1/(-:<n,1>))*K:(ending-begin))):(0..(-:<n,1>));
DEF SIMPLECOLORSCALE(n::IsInt)(startcol,endcol::IsRGBColor)=(TRANS:(AA:(FLOATSCALE:n):(TRANS:<<startcol.r,startcol.g,startcol.b>,<endcol.r,endcol.g,endcol.b>>)));
DEF COLORSCALE(n::IsInt)(startcol,endcol::isRGBcolor)=AA:RGBCOLOR:(SIMPLECOLORSCALE:n:<startcol,endcol>);
DEF COLORSCALESTRIP(a::IsReal)(num::IsInt)(startcol,endcol::isRGBcolor)=striplist
WHERE
striplist=struct:(cat:squarelist),
squarelist=(AA:[(COLOR~[k:(cuboid:<(a/num),(a/num)>),ID]),(K:(T:1:(a/num)))]:alist),
alist=COLORSCALE:num:<startcol,endcol>
END;
def colorsquarepol(a::IsReal)(n::IsInt)(a1,a2,b1,b2::isRGBcolor)=struct:(cat:squaresquare)
WHERE
squaresquare=AA:[(COLORSCALESTRIP:a:n)~(AA:RGBCOLOR),(K:(T:2:(a/n)))]:(TRANS:<leftscale,rightscale>),
leftscale=SIMPLECOLORSCALE:n:<a1,b1>,
rightscale=SIMPLECOLORSCALE:n:<a2,b2>
END;
%-- Colors ----------------------------------------------%
DEF acol1 = RGBCOLOR:<0,0.6,0>;
DEF acol2 = RGBCOLOR:<0.5,0.7,0>;
DEF acol3 = RGBCOLOR:<0.9,0.95,0.7>;
DEF acol4 = RGBCOLOR:<0.7,0.9,0.4>;
DEF acol5 = RGBCOLOR:<0.9,0.9,0.3>;
DEF acol6 = RGBCOLOR:<0.2,0.2,1>;
DEF acol7 = RGBCOLOR:<0.5,0.5,1>;
%-- High level assembly ---------------------------------%
DEF mountains=STRUCT:<MAP:sup_c1_c2:dom2d_s_c1_c2,
MAP:sup_c0_c1:dom2d_s_c0_c1,
MAP:sup_c2_c3:dom2d_s_c2_c3>
WHERE
dom2d_s_c0_c1=(colorsquarepol:1:16:<acol1, acol2, acol1, acol2>),
dom2d_s_c1_c2=(colorsquarepol:1:16:<acol1, acol2, acol1, acol3>),
dom2d_s_c2_c3=(colorsquarepol:1:16:<acol1, acol3, acol1, acol2>)
END;
DEF road =MAP:(CONS:sup_c1_c2):(pathstripe);
DEF beach=MAP:(CONS:sup_b12_b56):(colorsquarepol:1:16:<acol4, acol4, acol5, acol5>);
DEF lake=MAP:(CONS:sup_lake):(colorsquarepol:1:16:<acol6, acol7, acol6, blue>);
DEF scene4 = STRUCT:<
mountains TEXTURE SIMPLETEXTURE:'mountain.png',
(T:3:1:road) COLOR terrain TEXTURE SIMPLETEXTURE:'road.png',
beach TEXTURE SIMPLETEXTURE:'beach.png',
lake TEXTURE SIMPLETEXTURE:'water.png',
controlTrees%,hutmapped%>;
DEF out=scene4;