# 规则示例

# 基本示例

生成的房子是平顶,四面围墙是同样贴图,屋顶是一个贴图:

version "2019.0"

@StarRule

attr height = rand(2,10)


attr surround_facade_tex = fileRandom("MyTexture/surround/" + "*.jpg")
attr top_facade_tex = fileRandom("MyTexture/top/" + "*.jpg")

Lot-->
   extrude(world.up.flatTop, height)
   building
   
building-->
   comp(f) { 
              front : frontfacade |
              back : backfacade |
              left : leftfacade |
              right :rightfacade |
              top : topfacade
           }
         
frontfacade-->
   surroundTexture

backfacade-->
    surroundTexture

leftfacade-->
    surroundTexture
   
rightfacade-->
    surroundTexture
 
topfacade-->
    topTexture
    
surroundTexture-->
#   setupProjection(0,scope.xy,scope.sx,scope.sy)
   setupProjection(0,scope.xy,6,6)
   texture(surround_facade_tex)
   projectUV(0)
topTexture-->
   setupProjection(0, scope.xy,5,5)
   texture(top_facade_tex)
   projectUV(0)
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48