5 #######################################################################
6 # Visualization - precision factor added to ZNear, ZFar in method ZFitAll() of Graphic3d_Camera is not enough
7 #######################################################################
9 vinit View1 w=409 h=409
15 proc test3d {dstart} {
17 set proj1 { 0.47243081629544409 -0.39335870920278265 -0.78871924644244684}
18 set proj2 {-0.31828216872577886 0.17649241059446089 -0.93142197208020105}
20 for {set i 1} {$i <= 3} {incr i} {
21 for {set r 1} {$r <= 3} {incr r} {
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)]
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])"]
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} {
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
45 if { [checkcolor 204 204 1 1 0] != 1 } {
46 puts "Error: 3D projection test failed with the following parameters:"
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])]"
62 if { [checkcolor 204 204 1 1 0] != 1 } {
63 puts "Error: 3D projection test failed with the following parameters:"
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])]"
85 ####################################################################
86 # Test orthographic camera without frustum culling. #
87 # Test camera with scale 1E-8 to avoid jittering. #
88 ####################################################################
90 vviewparams -scale 1e-8
93 if { [test3d 1e-7] != 1 } {
94 puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is OFF"
97 ####################################################################
98 # Test orthographic camera with frustum culling. #
99 # Test camera with scale 1E-8 to avoid jittering. #
100 ####################################################################
102 vviewparams -scale 1e-8
105 if { [test3d 1e-7] != 1 } {
106 puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is ON"
109 ####################################################################
110 # Test perspective camera without frustum culling. #
111 # Test camera with less starting distance 1.0 to avoid jittering. #
112 ####################################################################
116 if { [test3d 1.0] != 1 } {
117 puts "Error: 3D projection test failed: camera is perspective, view frustum culling is OFF"
120 ####################################################################
121 # Test perspective camera with frustum culling. #
122 # Test camera with less starting distance 1.0 to avoid jittering. #
123 ####################################################################
127 if { [test3d 1.0] != 1 } {
128 puts "Error: 3D projection test failed: camera is perspective, view frustum culling is ON"