92ac0eb7 |
1 | # Generate set of boxes resembling OCC logo and arranged in the shape of |
2 | # Penrose triangle on perspective view. |
3 | # The sample shows how the viewer can be manipulated to produce required |
4 | # visual effect |
5 | |
6 | #Category: Visualization |
7 | #Title: Penrose triangle on perspective view |
8 | |
9 | pload MODELING VISUALIZATION |
10 | |
11 | # procedure to define box dimensions |
12 | set scale 1. |
13 | set ratio 0.94 |
14 | proc defbox {} { |
15 | global scale ratio |
16 | set scale [expr $scale * $ratio] |
17 | return [list 1.8*$scale 1.8*$scale 1.3*$scale] |
18 | } |
19 | |
20 | # make set of boxes |
21 | eval box b1 0 0 0 [defbox] |
22 | eval box b2 2 0 0 [defbox] |
23 | eval box b3 4 0 0 [defbox] |
24 | eval box b4 6 0 0 [defbox] |
25 | eval box b5 6 -1.5 0 [defbox] |
26 | eval box b6 6 -3 0 [defbox] |
27 | eval box b7 6 -4.5 0 [defbox] |
28 | eval box b8 6 -6 0 [defbox] |
29 | eval box b9 6 -6 1 [defbox] |
30 | eval box b10 6 -6 2 [defbox] |
31 | |
32 | # cut last box by prisms created from the first two to make impression |
33 | # that it is overlapped by these on selected view (see vviewparams below) |
34 | explode b1 f |
35 | explode b2 f |
36 | prism p0 b1_5 12.3 -14 6.8 |
37 | bcut bx b10 p0 |
38 | prism p1 b2_3 12 -14 6.8 |
39 | bcut bxx bx p1 |
40 | tcopy bxx b10 |
41 | |
42 | # make some boxes hollow |
43 | for {set i 1} {$i <= 1} {incr i} { |
44 | set dim [boundingstr b$i] |
45 | set dx [expr [lindex $dim 3] - [lindex $dim 0]] |
46 | set x1 [expr [lindex $dim 0] + 0.1 * $dx] |
47 | set x2 [expr [lindex $dim 1] + 0.1 * $dx] |
48 | set x3 [expr [lindex $dim 2] + 0.1 * $dx] |
49 | box bc $x1 $x2 $x3 0.8*$dx 0.8*$dx $dx |
50 | bcut bb b$i bc |
51 | tcopy bb b$i |
52 | } |
53 | |
54 | # prepare a view |
55 | vinit Penrose w=1024 h=512 |
56 | vsetcolorbg 255 255 255 |
57 | vrenderparams -rayTrace -fsaa on -reflections off -shadows off |
58 | |
59 | # set camera position and adjust lights |
60 | vcamera -persp -fovy 25 |
61 | vviewparams -eye 14 -14 6.8 -up 0 0 1 -at 4 -4 0 -scale 70 |
62 | vsetdispmode 1 |
63 | vlight def |
64 | vlight add directional direction 1 -2 -10 head 1 color white |
65 | vlight add directional direction 0 -10 0 head 1 color white |
66 | |
67 | # display boxes |
68 | vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 |
69 | |
70 | # set colors like in boxes of on OCC logo |
71 | vsetcolor b1 0.8671875 0 0.16015625 |
72 | vsetcolor b2 0.96484375 0.8671875 0 |
73 | vsetcolor b3 0.609375 0.97734375 0.09375 |
74 | vsetcolor b4 0.90234375 0 0.48046875 |
75 | vsetcolor b5 0 0.48046875 0.73828125 |
76 | vsetcolor b6 0.578125 0 0.48046875 |
77 | vsetcolor b7 0.93359375 0.609375 0 |
78 | vsetcolor b8 0 0.70703125 0.9296875 |
79 | vsetcolor b9 0 0.64453125 0.48046875 |
80 | vsetcolor b10 0 0.48046875 0.73828125 |
81 | |
82 | # set material to plastic for better look |
83 | for {set i 1} {$i <= 10} {incr i} {vsetmaterial b$i plastic} |
84 | |
29e2c6d2 |
85 | vdrawtext label "Which\nbox\nis\ncloser\nto\nyou?" -pos 0 -6 -2 -color 0 0 0 -halign left -valign bottom -angle 0 -zoom 0 -height 40 |