b7cd4ba7 |
1 | puts "========" |
2 | puts "OCC24307 Objects clipping algorithm using BVH performance test: Simple boxes test" |
3 | puts "========" |
4 | |
5 | # object characteristics |
6 | set BOXES_NUM 10 |
7 | set BOX_SIZE 100 |
8 | set PERCENT_OF_INNER_BOXES 30 |
9 | |
10 | # window parameters |
11 | set SMALL_WIN_WIDTH 512 |
12 | set SMALL_WIN_HEIGHT 512 |
13 | |
14 | # other |
15 | array set aBoxNames {} |
16 | |
17 | set aWithoutClippingSnapshot $imagedir/${casename}_without.png |
18 | set aWithClippingSnapshot $imagedir/${casename}_with.png |
19 | set aDiffImage $imagedir/${casename}_diff.png |
20 | |
21 | pload VISUALIZATION MODELING |
22 | vinit name=small_wnd l=32 t=32 w=$SMALL_WIN_WIDTH h=$SMALL_WIN_HEIGHT |
23 | vactivate small_wnd |
24 | vfrustumculling 0 |
25 | vautozfit 0 |
26 | vviewparams -scale 1.953125 -eye 0.57735026918962573 -0.57735026918962573 0.57735026918962573 |
27 | vzrange 1 512 |
28 | vclear |
29 | vremove -all -noinfo |
30 | |
31 | set aInnerBoxesNum [expr $BOXES_NUM * $PERCENT_OF_INNER_BOXES / 100] |
32 | puts "" |
33 | set aDebugInfo "Total number of visible objects: " |
34 | append aDebugInfo $aInnerBoxesNum |
35 | puts $aDebugInfo |
36 | puts "" |
37 | |
38 | puts "Start boxes generation..." |
39 | set aInnerWidthStep [expr $SMALL_WIN_WIDTH / (2 * ($aInnerBoxesNum + 1))] |
40 | set aInnerHeightStep [expr $SMALL_WIN_HEIGHT / (2 * ($aInnerBoxesNum + 1))] |
41 | set aOuterStep [expr $BOX_SIZE * 3 / ($BOXES_NUM - $aInnerBoxesNum + 1)] |
42 | for {set i 0} {$i < $aInnerBoxesNum} {incr i} { |
43 | set aCurrName "inner_box" |
44 | append aCurrName $i |
45 | set aX [expr - $SMALL_WIN_WIDTH / 4 + ($i + 1) * $aInnerWidthStep ] |
46 | set aY [expr - $SMALL_WIN_HEIGHT / 4 + ($i + 1) * $aInnerHeightStep ] |
47 | box $aCurrName $aX $aY 0 $BOX_SIZE $BOX_SIZE $BOX_SIZE |
48 | set aBoxNames($i) $aCurrName |
49 | } |
50 | for {set i $aInnerBoxesNum} {$i < $BOXES_NUM} {incr i} { |
51 | set aCurrName "outer_box" |
52 | append aCurrName $i |
53 | set aX [expr - $SMALL_WIN_WIDTH - $BOX_SIZE * 3 + ($i - $aInnerBoxesNum + 1) * $aOuterStep] |
54 | set aY [expr - $SMALL_WIN_HEIGHT - $BOX_SIZE * 3 + ($i - $aInnerBoxesNum + 1) * $aOuterStep] |
55 | box $aCurrName $aX $aY 0 $BOX_SIZE $BOX_SIZE $BOX_SIZE |
56 | set aBoxNames($i) $aCurrName |
57 | } |
58 | puts "$BOXES_NUM boxes generated." |
59 | puts "" |
60 | |
61 | puts "Start displaying boxes without clipping..." |
62 | for {set i 0} {$i < $BOXES_NUM} {incr i} { |
63 | vdisplay -noupdate $aBoxNames($i) |
64 | } |
65 | puts [vfps] |
66 | vdump $aWithoutClippingSnapshot |
67 | puts "All boxes were displayed." |
68 | puts "" |
69 | |
70 | verase |
71 | |
72 | vfrustumculling 1 |
73 | puts "Start displaying boxes with clipping..." |
74 | for {set i 0} {$i < $BOXES_NUM} {incr i} { |
75 | vdisplay -noupdate $aBoxNames($i) |
76 | } |
77 | puts [vfps] |
78 | vdump $aWithClippingSnapshot |
79 | puts "All boxes were displayed." |
80 | |
81 | set aDiffImageResult [diffimage $aWithClippingSnapshot $aWithoutClippingSnapshot 0.1 0 0 $aDiffImage] |
82 | if {$aDiffImageResult != 0} { |
83 | puts "ERROR : Test failed: there is a difference between images rendered with and without clipping" |
84 | } |
85 | |
86 | verase |