materials.tcl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Script displays properties of different materials available in OCCT
  2. #Category: Visualization
  3. #Title: Material properties in viewer
  4. set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
  5. set THE_COLORS {default red green blue}
  6. set THE_ROW_DIST 35
  7. proc drawLabels {} {
  8. set x 20
  9. set y 15
  10. foreach aMatIter $::THE_MATERIALS {
  11. vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color GRAY10 -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
  12. incr y 10
  13. }
  14. set x 40
  15. set y 5
  16. foreach aColIter $::THE_COLORS {
  17. set aLabColor "$aColIter"
  18. if { "$aColIter" == "default" } { set aLabColor BLACK }
  19. vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color "$aLabColor" -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
  20. incr x $::THE_ROW_DIST
  21. }
  22. }
  23. proc drawObjects {theRow theColor} {
  24. set aSize 4
  25. set aCtr -2
  26. set aCounter 0
  27. set x [expr 30 + $theRow * $::THE_ROW_DIST]
  28. set y 15
  29. foreach aMatIter $::THE_MATERIALS {
  30. set aSph s${theRow}_${aCounter}
  31. set aBox b${theRow}_${aCounter}
  32. uplevel #0 psphere $aSph $aSize
  33. uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
  34. uplevel #0 ttranslate $aSph $x $y 0
  35. uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
  36. uplevel #0 vdisplay -noredraw -dispMode 1 $aSph $aBox
  37. uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
  38. if {$theColor != ""} {
  39. uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
  40. }
  41. incr aCounter
  42. incr y 10
  43. }
  44. }
  45. # setup 3D viewer content
  46. pload MODELING VISUALIZATION
  47. vclear
  48. vclose ALL
  49. vinit View1 w=768 h=768
  50. vtop
  51. vglinfo
  52. vbackground -gradient B4C8FF B4B4B4 -gradientMode VERTICAL
  53. vlight -change 0 -dir 0.577 -0.577 -0.577
  54. vrenderparams -msaa 8
  55. # adjust scene bounding box
  56. box bnd 0 0 0 180 210 1
  57. vdisplay -noredraw -dispMode 0 bnd
  58. vfit
  59. vremove -noredraw bnd
  60. # draw spheres and boxes with different materials
  61. drawLabels
  62. drawObjects 0 ""
  63. drawObjects 1 red
  64. drawObjects 2 green
  65. drawObjects 3 blue1
  66. vrepaint