ea764884 |
1 | puts "============" |
2 | puts "CR25760" |
3 | puts "============" |
4 | puts "" |
5 | ####################################################################### |
6 | # Visualization - precision factor added to ZNear, ZFar in method ZFitAll() of Graphic3d_Camera is not enough |
7 | ####################################################################### |
8 | |
9 | vinit View1 w=409 h=409 |
10 | vclear |
11 | |
12 | vclear |
13 | vautozfit 0 |
14 | |
15 | proc test3d {dstart} { |
16 | |
17 | set proj1 { 0.47243081629544409 -0.39335870920278265 -0.78871924644244684} |
18 | set proj2 {-0.31828216872577886 0.17649241059446089 -0.93142197208020105} |
19 | |
20 | for {set i 1} {$i <= 3} {incr i} { |
21 | for {set r 1} {$r <= 3} {incr r} { |
22 | |
23 | set x [expr pow(100, $i)] |
24 | set y [expr pow( 70, $i)] |
25 | set z [expr pow( 50, $i)] |
26 | set dist [expr pow(100, $r)] |
27 | |
28 | vclear |
29 | vertex v0 $x $y $z |
30 | vertex v1 [expr "$x + ($dist * [lindex $proj1 0])"] [expr "$y + ($dist * [lindex $proj1 1])"] [expr "$z + ($dist * [lindex $proj1 2])"] |
31 | vertex v2 [expr "$x + ($dist * [lindex $proj2 0])"] [expr "$y + ($dist * [lindex $proj2 1])"] [expr "$z + ($dist * [lindex $proj2 2])"] |
32 | |
33 | for {set d [expr $dstart * {max ($x,$y,$z,$dist)}]} {$d <= 1e7} {set d [expr "abs ($d) * 1.2E5"]} { |
34 | for {set p 1} {$p <= 2} {incr p} { |
35 | set proj [set proj$p] |
36 | |
37 | vremove -all |
38 | vdisplay v0 |
39 | vdisplay v$p |
40 | vviewparams -eye [expr "$x - ($d * [lindex $proj 0])"] [expr "$y - ($d * [lindex $proj 1])"] [expr "$z - ($d * [lindex $proj 2])"] -at $x $y $z |
41 | vzfit |
42 | |
43 | vremove -all |
44 | vdisplay v0 |
45 | if { [checkcolor 204 204 1 1 0] != 1 } { |
46 | puts "Error: 3D projection test failed with the following parameters:" |
47 | vviewparams |
48 | vzrange |
49 | puts "" |
50 | puts "v1 x: $x" |
51 | puts "v1 y: $y" |
52 | puts "v1 z: $z" |
53 | puts "v2 x: [expr $x + ($dist * [lindex $proj 0])]" |
54 | puts "v2 y: [expr $y + ($dist * [lindex $proj 1])]" |
55 | puts "v2 z: [expr $z + ($dist * [lindex $proj 2])]" |
56 | puts "" |
57 | return 0 |
58 | } |
59 | |
60 | vremove -all |
61 | vdisplay v$p |
62 | if { [checkcolor 204 204 1 1 0] != 1 } { |
63 | puts "Error: 3D projection test failed with the following parameters:" |
64 | vviewparams |
65 | vzrange |
66 | puts "" |
67 | puts "v1 x: $x" |
68 | puts "v1 y: $y" |
69 | puts "v1 z: $z" |
70 | puts "v2 x: [expr $x + ($dist * [lindex $proj 0])]" |
71 | puts "v2 y: [expr $y + ($dist * [lindex $proj 1])]" |
72 | puts "v2 z: [expr $z + ($dist * [lindex $proj 2])]" |
73 | puts "" |
74 | return 0 |
75 | } |
76 | } |
77 | } |
78 | } |
79 | } |
80 | return 1 |
81 | } |
82 | |
83 | set tcl_precision 16 |
84 | |
85 | #################################################################### |
86 | # Test orthographic camera without frustum culling. # |
87 | # Test camera with scale 1E-8 to avoid jittering. # |
88 | #################################################################### |
89 | vcamera -ortho |
90 | vviewparams -scale 1e-8 |
91 | vfrustumculling 0 |
92 | |
93 | if { [test3d 1e-7] != 1 } { |
94 | puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is OFF" |
95 | } |
96 | |
97 | #################################################################### |
98 | # Test orthographic camera with frustum culling. # |
99 | # Test camera with scale 1E-8 to avoid jittering. # |
100 | #################################################################### |
101 | vcamera -ortho |
102 | vviewparams -scale 1e-8 |
103 | vfrustumculling 1 |
104 | |
105 | if { [test3d 1e-7] != 1 } { |
106 | puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is ON" |
107 | } |
108 | |
109 | #################################################################### |
110 | # Test perspective camera without frustum culling. # |
111 | # Test camera with less starting distance 1.0 to avoid jittering. # |
112 | #################################################################### |
113 | vcamera -persp |
114 | vfrustumculling 0 |
115 | |
116 | if { [test3d 1.0] != 1 } { |
117 | puts "Error: 3D projection test failed: camera is perspective, view frustum culling is OFF" |
118 | } |
119 | |
120 | #################################################################### |
121 | # Test perspective camera with frustum culling. # |
122 | # Test camera with less starting distance 1.0 to avoid jittering. # |
123 | #################################################################### |
124 | vcamera -persp |
125 | vfrustumculling 1 |
126 | |
127 | if { [test3d 1.0] != 1 } { |
128 | puts "Error: 3D projection test failed: camera is perspective, view frustum culling is ON" |
129 | } |