CityEngine CGA語法之 隨機點函式 scatter
概要
scatter(domain, nPoints, distributionType) { operations }
scatter(domain, nPoints,gaussian, scatterMean, scatterStddev) { operations }
引數
domain (selstr):指定隨機點產生的位置,有三個選項:surface、volume、scope。
nPoints (float):指定點的數量
distributionType (selstr):指定點分佈的型別,有兩個選項:uniform、gaussian
scatterMean (selstr):可選的引數,指定隨機點群的中心相對於當前的scope的位置,有七個選項center、front、back、left、right、top、bottom,預設為center
scatterStddev (float):可選的引數,指定標準差,預設值是0.16.
注意
只有在幾何體是閉合的形狀時,domain才能使用volume,如果不是閉合的,則會採用surface
產生的每一個點的scope的尺寸為0
產生的每一個點只包含一個節點,可以使用替換函式i()來插入模型
示例
一、在表面生成隨機點,型別為uniform
attr height =10 Lot--> extrude(height) scatter(surface,1000,uniform) {A.}
二、在體內生成隨機點,型別為uniformattr height =10 Lot--> extrude(height) scatter(volume,1000,uniform) {A.}
三、在表面生成隨機點,型別為gaussian
attr height =10 Lot--> extrude(height) scatter(surface,1000,gaussian) {A.}
四、在體內生成隨機點,型別為gaussian
attr height =10 Lot--> extrude(height) scatter(volume,1000,gaussian) {A.}
五、在scope生成隨機點,型別為uniform
attr height =10 Lot--> extrude(height) scatter(scope,1000,<span style="font-size:14px;">uniform</span>) {A.}
六、在scope生成隨機點,型別為gaussian
attr height =10 Lot--> extrude(height) scatter(scope,1000,gaussian) {A.}
七、在scope生成隨機點,型別為uniform,設定scatterMean引數scatterMean為front
\attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,front,0.9) {A.}
scatterMean為left
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,left,0.9) {A.}
scatterMean為bottom
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,bottom,0.9) {A.}
scatterMean為right
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,right,0.9) {A.}
scatterMean為back
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,back,0.9) {A.}
scatterMean為top
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,top,0.9) {A.}
八、設定標準差
標準差越大,點越分散
設定標準差為0.2
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,top,0.2) {A.}
設定標準差為2
attr height =10 Lot--> extrude(height) scatter(scope,20,gaussian,top,2) {A.}