0030592: Draw Harness, ViewerTest - provide vbackground command unifying vsetbg,...
[occt.git] / samples / tcl / materials.tcl
CommitLineData
44c7c33e 1# Script displays properties of different materials available in OCCT
2
ab91ab6f 3#Category: Visualization
4#Title: Material properties in viewer
5
44c7c33e 6set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
7set THE_COLORS {default red green blue1}
8set THE_ROW_DIST 35
9
10proc drawLabels {} {
11 set x 20
12 set y 15
29e2c6d2 13 set r 0.098
14 set g 0.098
15 set b 0.098
44c7c33e 16 foreach aMatIter $::THE_MATERIALS {
29e2c6d2 17 vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color $r $g $b -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
44c7c33e 18 incr y 10
19 }
20 set x 40
21 set y 5
22 foreach aColIter $::THE_COLORS {
23 if { $aColIter == "red" } {
29e2c6d2 24 set r 1.0
25 set g 0.0
44c7c33e 26 set b 0
27 } elseif { $aColIter == "green" } {
29e2c6d2 28 set r 0.0
29 set g 1.0
30 set b 0.0
44c7c33e 31 } elseif { $aColIter == "blue1" } {
29e2c6d2 32 set r 0.0
33 set g 0.0
34 set b 1.0
44c7c33e 35 }
29e2c6d2 36 vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color $r $g $b -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
44c7c33e 37 incr x $::THE_ROW_DIST
38 }
39}
40
41proc drawObjects {theRow theColor} {
42 set aSize 4
43 set aCtr -2
44 set aCounter 0
45 set x [expr 30 + $theRow * $::THE_ROW_DIST]
46 set y 15
47 foreach aMatIter $::THE_MATERIALS {
48 set aSph s${theRow}_${aCounter}
49 set aBox b${theRow}_${aCounter}
50 uplevel #0 psphere $aSph $aSize
51 uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
52 uplevel #0 ttranslate $aSph $x $y 0
53 uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
f2b42160 54 uplevel #0 vdisplay -noredraw -dispMode 1 $aSph $aBox
44c7c33e 55 uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
56 if {$theColor != ""} {
57 uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
58 }
59 incr aCounter
60 incr y 10
61 }
62}
63
64# setup 3D viewer content
65pload MODELING VISUALIZATION
66
44c7c33e 67vclear
f2b42160 68vclose ALL
69vinit View1 w=768 h=768
44c7c33e 70vtop
71vglinfo
293211ae 72vbackground -gradient 0.705882 0.784314 1 0.705882 0.705882 0.705882 -gradientMode VERTICAL
992ed6b3 73
74vlight -change 0 -dir 0.577 -0.577 -0.577
63fad07e 75vrenderparams -msaa 8
44c7c33e 76
77# adjust scene bounding box
78box bnd 0 0 0 180 210 1
f2b42160 79vdisplay -noredraw -dispMode 0 bnd
44c7c33e 80vfit
81vremove -noredraw bnd
82
83# draw spheres and boxes with different materials
84drawLabels
85drawObjects 0 ""
86drawObjects 1 red
87drawObjects 2 green
88drawObjects 3 blue1