VRML編程練習
第一彈:IndexedLineSet線集合
注:學習階段,不喜勿噴!
編譯軟件:VrmlPad
**
線集合語法:
IndexedLineSet{
coord Coordinate {
point [ #裏面存放各個頂點,頂點編號從0開始依次相加
]
}
coordIndex [ #裏面指出哪些點連成一條直線
]
color Color {
color [ #裏面給出顏色,每個顏色用,分隔開,顏色數目和線段數目相同
]
}
colorIndex [ #給出線段編號對應上面的顏色
]
colorPerVertex #指明着色方式是基於端點還是基於線段(TRUE/FALSE),默認基於端點(TRUE)
}
示例代碼
**
#VRML V2.0 utf8
Shape {
appearance Appearance {}
geometry IndexedLineSet {
coord Coordinate {
point [
0 0 0, #index=0
1 0 0, #index=1
1 -0.5 0.75, #index=2
0 -0.5 0.75, #index=3
0 -1.5 0.75, #index=4
1 -1.5 0.75, #index=5
1 -2.5 0.75, #index=6
0 -2.5 0.75, #index=7
0 -3.0 1.5, #index=8
1 -3.0 1.5, #index=9
]
}
coordIndex [
0 1 2 3 0 -1,
2 3 4 5 2 -1,
4 5 6 7 4 -1,
6 7 8 9 6 -1,
]
color Color {
color [
1 1 1,
1 1 1,
1 1 1,
1 1 1,
]
}
colorIndex [0 1 2 3]
colorPerVertex FALSE
}
}
**
運行效果展示
**