0030580: Configuration, CMake - introduce BUILD_RELEASE_DISABLE_EXCEPTIONS option...
[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
54 uplevel #0 vdisplay -noredraw $aSph $aBox
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
67catch { vclose View1 }
68vinit View1 w=768 h=768
69vclear
70vtop
71vglinfo
72vsetgradientbg 180 200 255 180 180 180 2
992ed6b3 73
74vlight -change 0 -dir 0.577 -0.577 -0.577
44c7c33e 75vsetdispmode 1
63fad07e 76vrenderparams -msaa 8
44c7c33e 77
78# adjust scene bounding box
79box bnd 0 0 0 180 210 1
80vdisplay -noredraw bnd
81vsetdispmode bnd 0
82vfit
83vremove -noredraw bnd
84
85# draw spheres and boxes with different materials
86drawLabels
87drawObjects 0 ""
88drawObjects 1 red
89drawObjects 2 green
90drawObjects 3 blue1
91#vfit
92vzfit