Modification due to behavior changes after integration for issues CR26138 and CR24923
[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
13 set r 25
14 set g 25
15 set b 25
16 foreach aMatIter $::THE_MATERIALS {
17 vdrawtext "$aMatIter" $x $y 0 $r $g $b 2 1 000 0 14 1 Arial
18 incr y 10
19 }
20 set x 40
21 set y 5
22 foreach aColIter $::THE_COLORS {
23 if { $aColIter == "red" } {
24 set r 255
25 set g 0
26 set b 0
27 } elseif { $aColIter == "green" } {
28 set r 0
29 set g 255
30 set b 0
31 } elseif { $aColIter == "blue1" } {
32 set r 0
33 set g 0
34 set b 255
35 }
36 vdrawtext "$aColIter" $x $y 0 $r $g $b 1 1 000 0 14 1 Arial
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
73vlight change 0 pos -1 1 1
74vsetdispmode 1
75
76# adjust scene bounding box
77box bnd 0 0 0 180 210 1
78vdisplay -noredraw bnd
79vsetdispmode bnd 0
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
89#vfit
90vzfit