BOB的基本程式架構如下所示:
----------------------------
// ........標題....... /* 注解
#include color.bc /* 外部程式--顏色檔
#include textures.bs /* 外部程式--材質庫
//工作環境的設定
studio {........
........ (相機)
}
light {........ (燈光)
........
}
surfaace {........
........ (表面材質)
}
//各種物體
sphere {........
........
}
cone {........
........
}
ring {........
........
}
polygon {........
........
}
//取得外部物體
surface {........
........
}
transform { scale x y z } //縮放比例
transform { rotate 0 0 35 } //Z軸轉35度
#include column.bo
transform_pop
transform { rotate 90 0 0
translate 27 20 12 }
#include column.bo
transform_pop
transform_pop
輸入檔(.B)的格式:
Studio影像處理工作坊(整體環境設定)的格式:
antialias mode
threshold dist
jitter
aperture size
focal_length dist
samples n
no_shadows
no_exp_trans
caustics
depth max_depth
}
Lights
【point】:一個點光源在空間中佔據一點,它有position(位置)、color(顏色)、
falloff(衰減)等屬性來決定光源的距離及強度,一個點光
源就像在三度空間中,放了一個燈泡,其光源可設定為隨
著距離長度而減少亮度,也可以設定為不受距離影響而亮
度一致。
例: light {
type point //燈光型式為point。
falloff f //燈光的衰減量。
position x y z //燈光放置的位置。
color r g b //燈光的顏色。
}
(※燈光強度的改變是根據下列公式:
I = I。/(dist^f)
I。:基本燈光強度。
dist:燈源到物體表面的距離。
f:若 f=0 -- 不衰減。
若 f=1 -- 與距離成反比。
若 f=2 -- 自然物理現像,與距離平方成反比。
依此我們可計算物體表面的顏色。※)
【directional】:有方向性的平行光源,它有兩種敘述方式
型式1:
light {
type directional //燈光型式為directional。
color r g b //可設定顏色。
direction dx dy dz //方向性以X,Y,Z三軸的向量值表示其方向
}
型式2:
light {
type directional
color r g b
from x y z //以光線的起點與終點表示光的方向。
at x y z
}
【spherical】:球形燈光。
light {
type spherical //燈光型式為spherical。
position x y z //燈光的位置。
radius r //球形燈光的半徑。
color r g b //燈光的顏色。
falloff f //陰暗區的衰減量。
samples n //samples這個參數是來控制陰影區產生
陰影的光束量(其內定值為16)。
}
【spot】:聚光燈。
light {
type spot //燈光型式為 spot。
position x y z //燈光的位置。
direction dx dy dz //方向性的向量(也可用at x y z表示)。
min_angle angle1 //強光區。
max_angle angle2 //弱光區。
color r g b //燈光的顏色。
falloff f //弱光區光的衰減量。
}
(※若物體是在min_angle之內,則物體可得到完全的照明,就有如點光源一樣。 若物體是在min_angle與max_angle之間,則表面的照明會隨下列公式而衰減
Primitives基本元件center x y z是定義此圓的中心於三度空間(x y z軸)的位置,radius r是定 義此圓的半徑大小。
例:正方形polygon {
例:三角形polygon {
例:正方體:正方體則需8個點,組成6個面。
格式: polygon {
points n
vertex x y z
.
.
.
}
points 4
vertex 1 1 0
vertex 1 -1 0
vertex -1 -1 0
vertex -1 1 0
}
points 3
vertex 0 0 0
vertex -1 -1 0
vertex -1 1 0
}
polygon {
points 8
vertex 1 1 0
vertex 1 -1 0
vertex -1 -1 0
vertex -1 1 0
vertex 1 1 2
vertex 1 -1 2
vertex -1 -1 2
vertex -1 1 2
}
此指令可製作一圓環。
格式: ring {
center x y z
normal a b c
min_radius r0
max_radius r1
}
Transformations轉移
例:
transform {translate 0 0 10}
transform {rotate 90 0 0}
#include TEST.BO
transform_pop
transform_pop
Clipping修剪
格式:
平面修改 clip {
center x y z
normal x y z
}
球形修改 clip {
center x y z
radius r
inside or outside
}
柱形修改 clip {
apex x y z apex_radius r
base x y z base_radius r
inside or outside
}
例:要製作半圓的圖,我們可先做出一個圓,再用clip修改,如下列所示:
sphere {
center 0 0 0
radius 1
clip {
center 0 0 0
normal 0 0 1
}
}
