File: raytrace.tcl

package info (click to toggle)
opencascade 7.8.1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 293,924 kB
  • sloc: cpp: 1,249,635; tcl: 15,974; cs: 5,173; java: 1,554; sh: 1,354; ansic: 821; xml: 737; makefile: 26; javascript: 22
file content (44 lines) | stat: -rw-r--r-- 1,070 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Script demonstrating ray tracing in 3d view

#Category: Visualization
#Title: Ray tracing

# Ray-Tracing doesn't work with Compatible Profile on macOS
pload VISUALIZATION
if { $::tcl_platform(os) == "Darwin" } { vcaps -core }

# make bottle by calling another script
source [file join [file dirname [info script]] bottle.tcl]

# make table and a glass
box table -50 -50 -10 100 100 10
pcone glass_out 7 9 25
pcone glass_in 7 9 25
ttranslate glass_in 0 0 0.2
bcut glass glass_out glass_in
ttranslate glass -30 -30 0

# show table and glass
vinit w=1024 h=1024
vsetmaterial bottle aluminium
vdisplay table
vsetmaterial table bronze
vsetmaterial table plastic
vsetcolor table coral2
vdisplay glass
vsetmaterial glass plastic
vsetcolor glass brown
vsettransparency glass 0.6

# add light source for shadows
vlight spot -type SPOT -pos -100 -100 300

# set white background and fit view
vbackground -color WHITE
vfit

# set ray tracing
puts "Trying raytrace mode..."
if { ! [catch {vrenderparams -raytrace -shadows -reflections -fsaa -rayDepth 5}] } {
  vtextureenv on 1
}