VRML/VRML1.pm

filter: Statementstmt 21.4% 112 / 523 Branchbran 13.1% 41 / 312 Conditioncond 8.3% 5 / 60 MC/DCmcdc 0.0% 0 / 38 Subroutinesub 24.0% 12 / 50 Podpod 2.2% 1 / 45 totaltotal 16.6% 171 / 1028 CC 180 SCAR 58.1
CC
180
Cov
18%
line
1560.0
transform_begin
380.0
viewpoint
132.0
CRAP 332.1
↑ Summary VRML/VRML2.pm »
1 package VRML::VRML1;
2  
3 ############################## Copyright ##############################
4 # #
5 # This program is Copyright 1996,1998 by Hartmut Palm. #
6 # This program is free software; you can redistribute it and/or #
7 # modify it under the terms of the GNU General Public License #
8 # as published by the Free Software Foundation; either version 2 #
9 # of the License, or (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # If you do not have a copy of the GNU General Public License write #
17 # to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, #
18 # MA 02139, USA. #
19 # #
20 #######################################################################
21  
22 1 require 5.000;
23 1 require VRML::VRML1::Standard;
24 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use VRML::Color;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use VRML::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use vars qw(@ISA $AUTOLOAD $VERSION %supported);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 @ISA = qw(VRML::VRML1::Standard);
29  
30 1 $VERSION = "1.10";
31 1 %supported = ('quote' => "Live3D|WorldView|Cosmo Player",
32 'L3D_ext' => "Live3D|Cosmo Player", # not WorldView
33 'gzip' => "Live3D|WorldView|Cosmo Player|libcosmoplayer|VRweb|GLview",
34 'target' => "Live3D|WorldView|Cosmo Player|libcosmoplayer|MSVRML2OCX"
35 );
36  
37 1 my $PI = 3.1415926;
38 1 my $PI_2 = $PI / 2;
39  
40 #--------------------------------------------------------------------
41  
42 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
43 6 my $class = shift;
44 6 my $version = shift;
45 6 my $self = new VRML::VRML1::Standard($version);
46 6 $self->{'viewpoint'} = [];
47 6 return bless $self, $class;
48 }
49  
50 0 ▶sub supported {
Subroutine supported: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my $self = shift;
52 0 my $feature = shift;
53 0 return $self->{'BROWSER'} =~ /$supported{$feature}/i;
54 }
55  
56 #--------------------------------------------------------------------
57 # VRML Grouping Methods
58 #--------------------------------------------------------------------
59 0 ▶sub at {
Subroutine at: not called CC=1 SCAR=6.9
Pod undocumented
60 0 my $self = shift;
61 0 $self->transform_begin(@_);
62 0 return $self;
63 }
64  
65 0 ▶sub back {
Subroutine back: not called CC=1 SCAR=6.9
Pod undocumented
66 0 my $self = shift;
67 0 $self->transform_end();
68 0 return $self;
69 }
70  
71 0 ▶sub begin {
Subroutine begin: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my $self = shift;
73 0 $self->Group($_[0]);
74 0 return $self;
75 }
76  
77 0 ▶sub end {
Subroutine end: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my $self = shift;
79 0 $self->End($_[0]);
80 0 return $self;
81 }
82  
83 0 ▶sub anchor_begin {
Subroutine anchor_begin: not called CC=7 SCAR=40.3
Pod undocumented
84 0 my $self = shift;
85 0 ▶ return $self->_put(qq{# CALL: ->anchor_begin("Url","description","target=parameter");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
86 0 my ($url, $description, $parameter) = @_;
87 0 my $target = undef;
88 0 ▶ my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'BROWSER'} =~ /$VRML::VRML1::supported{'quote'}/i ? : 0 0 0
89 0 ▶ $description =~ s/"/$quote/g if defined $description;
Branch: 1 branch
BranchTrueFalseTotal
if defined $description 0 0 0
90 0 ▶ if (defined $parameter && $self->{'BROWSER'} =~ /$supported{'target'}/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parameter and $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"target"}/i) 0 0 0
Condition0%0/3
defined $parameter and $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"target"}/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $parameter and $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"target"}/i
defined $parameter $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"target"}/i
Truth table0%0/3
A and B
A= defined $parameterB= $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"target"}/i
ABresult
0X0
100
111
91 0 ▶ ($target = $1) =~ s/"/$quote/g if ($parameter =~ /target\s*=(.+)/i);
Branch: 1 branch
BranchTrueFalseTotal
if $parameter =~ /target\s*=(.+)/i 0 0 0
92 }
93 0 $self->WWWAnchor($url, $description, $target);
94 0 return $self;
95 }
96  
97 0 ▶sub anchor_end {
Subroutine anchor_end: not called CC=1 SCAR=6.9
Pod undocumented
98 0 my $self = shift;
99 0 $self->End($_[0]);
100 0 return $self;
101 }
102  
103 0 ▶sub collision_begin {
Subroutine collision_begin: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my $self = shift;
105 0 ▶ $self->_row("CollideStyle { collide TRUE }\n") if $self->{'BROWSER'} =~ /$supported{'L3D_ext'}/i;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"L3D_ext"}/i 0 0 0
106 0 $self->_row("DEF CollisionDetection Info { string \"TRUE\" }\n");
107 0 return $self;
108 }
109  
110 0 ▶sub collision_end {
Subroutine collision_end: not called CC=1 SCAR=6.9
Pod undocumented
111 0 return shift;
112 }
113  
114 0 ▶sub group_begin {
Subroutine group_begin: not called CC=1 SCAR=6.9
Pod undocumented
115 0 my $self = shift;
116 0 $self->Group(@_);
117 0 return $self;
118 }
119  
120 0 ▶sub group_end {
Subroutine group_end: not called CC=1 SCAR=6.9
Pod undocumented
121 0 my $self = shift;
122 0 $self->End($_[0]);
123 0 return $self;
124 }
125  
126 0 ▶sub lod_begin {
Subroutine lod_begin: not called CC=2 SCAR=17.9
Pod undocumented
127 0 my $self = shift;
128 0 ▶ return $self->_put(qq{# CALL: ->lod_begin(range,"center");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
129 0 my ($range, $center) = @_;
130 0 $self->LOD($range,$center);
131 0 return $self;
132 }
133  
134 0 ▶sub lod_end {
Subroutine lod_end: not called CC=1 SCAR=6.9
Pod undocumented
135 0 my $self = shift;
136 0 $self->End($_[0]);
137 0 return $self;
138 }
139  
140 0 ▶sub switch_begin {
Subroutine switch_begin: not called CC=1 SCAR=6.9
Pod undocumented
141 0 my $self = shift;
142 0 $self->Switch(@_);
143 0 return $self;
144 }
145  
146 0 ▶sub switch_end {
Subroutine switch_end: not called CC=1 SCAR=6.9
Pod undocumented
147 0 my $self = shift;
148 0 $self->End($_[0]);
149 0 return $self;
150 }
151  
152 0 ▶sub inline {
Subroutine inline: not called CC=1 SCAR=6.9
Pod undocumented
153 0 my $self = shift;
154 0 $self->WWWInline(@_);
155 0 return $self;
156 }
157  
158 #--------------------------------------------------------------------
159 # VRML Methods
160 #--------------------------------------------------------------------
161  
162 0 ▶sub background {
Subroutine background: not called CC=3 SCAR=24.8
Pod undocumented
163 0 my $self = shift;
164 0 my %hash = @_;
165 0 ▶ $hash{skyColor} = ${$hash{skyColor}}[0] if ref($hash{skyColor}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $hash{"skyColor"} eq "ARRAY" 0 0 0
166 0 $self->backgroundcolor($hash{skyColor});
167 0 ▶ $hash{frontUrl} = ${$hash{frontUrl}}[0] if ref($hash{frontUrl}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $hash{"frontUrl"} eq "ARRAY" 0 0 0
168 0 $self->backgroundimage($hash{frontUrl});
169 0 return $self;
170 }
171  
172 0 ▶sub backgroundcolor {
Subroutine backgroundcolor: not called CC=2 SCAR=17.9
Pod undocumented
173 0 my $self = shift;
174 0 my ($skyColorString) = @_;
175 0 my $skyColor;
176 0 ▶ if (defined $skyColorString) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $skyColorString) 0 0 0
177 0 $skyColor = rgb_color($skyColorString);
178 0 $self->def("BackgroundColor")->Info($skyColor)->_trim;
179 }
180 0 return $self;
181 }
182  
183 0 ▶sub backgroundimage {
Subroutine backgroundimage: not called CC=2 SCAR=17.9
Pod undocumented
184 0 my $self = shift;
185 0 my $bgimage = shift;
186 0 ▶ if (defined $bgimage) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bgimage) 0 0 0
187 0 $self->def("BackgroundImage")->Info($bgimage)->_trim;
188 }
189 0 return $self;
190 }
191  
192 0 ▶sub title {
Subroutine title: not called CC=2 SCAR=17.9
Pod undocumented
193 0 my $self = shift;
194 0 ▶ return $self->_put(qq{# CALL: ->title("string");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
195 0 my $title = shift;
196 0 $self->_row("DEF Title Info { string \"$title\" }\n");
197 0 return $self;
198 }
199  
200 0 ▶sub info {
Subroutine info: not called CC=5 SCAR=34.0
Pod undocumented
201 0 my $self = shift;
202 0 my $string = shift;
203 0 ▶ return $self->_put(qq{# CALL: ->info("string");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
204 0 ▶ my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'BROWSER'} =~ /$VRML::VRML1::supported{'quote'}/i ? : 0 0 0
205 0 ▶ if (defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $string) 0 0 0
206 0 ▶ $string = join(',',@$string) if ref($string) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $string eq "ARRAY" 0 0 0
207 0 $string =~ s/"/$quote/g;
208 0 $self->_row("Info { string \"$string\" }\n");
209 }
210 0 return $self;
211 }
212  
213 0 ▶sub worldinfo {
Subroutine worldinfo: not called CC=5 SCAR=34.0
Pod undocumented
214 0 my $self = shift;
215 0 my $title = shift;
216 0 my $string = shift;
217 0 ▶ my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'BROWSER'} =~ /$VRML::VRML1::supported{'quote'}/i ? : 0 0 0
218 0 ▶ $self->_row("DEF Title Info { string \"$title\" }\n") if defined $title;
Branch: 1 branch
BranchTrueFalseTotal
if defined $title 0 0 0
219 0 ▶ if (defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $string) 0 0 0
220 0 ▶ $string = join(',',@$string) if ref($string) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $string eq "ARRAY" 0 0 0
221 0 $string =~ s/"/$quote/g;
222 0 $self->_row("Info { string \"$string\" }\n");
223 }
224 0 return $self;
225 }
226  
227 0 ▶sub navigationinfo {
Subroutine navigationinfo: not called CC=4 SCAR=30.0
Pod undocumented
228 0 my $self = shift;
229 0 my ($type, $speed, $headlight) = @_;
230 0 ▶ $type = $$type[0] if ref($type) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $type eq "ARRAY" 0 0 0
231 0 $self->_row("DEF Viewer Info { string \"$type\" }\n");
232 0 $self->_row("DEF ViewerSpeed Info { string \"$speed\" }\n");
233 0 ▶ $headlight = defined $headlight && !$headlight ? "FALSE" : "TRUE";
Branch: 1 branch
BranchTrueFalseTotal
defined $headlight && !$headlight ? : 0 0 0
Condition0%0/3
defined $headlight and not $headlight
!ll&&!rl&&r
000
MC/DC0%0/2
defined $headlight and not $headlight
defined $headlight not $headlight
Truth table0%0/3
A and not(B)
A= defined $headlightB= not $headlight
ABresult
0X0
100
111
234 0 $self->_row("DEF Headlight Info { string \"$headlight\" }\n");
235 0 return $self;
236 }
237 #--------------------------------------------------------------------
238  
239 0 ▶sub viewpoint_begin {
Subroutine viewpoint_begin: not called CC=4 SCAR=30.0
Pod undocumented
240 0 my $self = shift;
241 0 my ($whichChild) = @_;
242 0 ▶ $whichChild = (defined $whichChild && $whichChild > 0) ? $whichChild-1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $whichChild && $whichChild > 0 ? : 0 0 0
Condition0%0/3
defined $whichChild and $whichChild > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $whichChild and $whichChild > 0
defined $whichChild $whichChild > 0
Truth table0%0/3
A and B
A= defined $whichChildB= $whichChild > 0
ABresult
0X0
100
111
243 0 my $vrml = $self->{'TAB'}."DEF Cameras Switch {\n";
244 0 $vrml .= $self->{'TAB'}." whichChild $whichChild\n";
245 0 $self->{'TAB_VIEW'} = $self->{'TAB'}."\t";
246 0 ▶ $self->{'viewpoint_begin'} = $#{$self->{'VRML'}}+1 unless defined $self->{'viewpoint_begin'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"viewpoint_begin"} 0 0 0
247 0 push @{$self->{'viewpoint'}}, $vrml;
248 0 return $self;
249 }
250  
251 0 ▶sub viewpoint_end {
Subroutine viewpoint_end: not called CC=1 SCAR=6.9
Pod undocumented
252 0 my $self = shift;
253 0 chop($self->{'TAB_VIEW'});
254 0 push @{$self->{'viewpoint'}}, $self->{'TAB_VIEW'}."}\n";
255 0 splice(@{$self->{'VRML'}}, $self->{'viewpoint_begin'}, 0, @{$self->{'viewpoint'}});
256 0 $self->{'viewpoint'} = [];
257 0 return $self;
258 }
259  
260 0 ▶sub viewpoint_auto_set {
Subroutine viewpoint_auto_set: not called CC=6 SCAR=37.4
Pod undocumented
261 0 my $self = shift;
262 0 my $factor = shift;
263 0 ▶ $factor = 1 unless defined $factor;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $factor 0 0 0
264 0 ▶ if (defined $self->{'viewpoint_set'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'viewpoint_set'}) { } 0 0 0
265 0 my $x = ($self->{'Xmax'}+$self->{'Xmin'})/2;
266 0 my $y = ($self->{'Ymax'}+$self->{'Ymin'})/2;
267 0 my $z = ($self->{'Zmax'}+$self->{'Zmin'})/2;
268 0 my $dx = abs($self->{'Xmax'}-$x); # todo: calculate angle
269 0 my $dy = abs($self->{'Ymax'}-$y);
270 0 my $dz = abs($self->{'Zmax'}-$z);
271 0 my $dist = 0;
272 0 ▶ $dist = $dx if $dx > $dist;
Branch: 1 branch
BranchTrueFalseTotal
if $dx > $dist 0 0 0
273 0 ▶ $dist = $dy if $dy > $dist;
Branch: 1 branch
BranchTrueFalseTotal
if $dy > $dist 0 0 0
274 0 ▶ $dist = $dz if $dz > $dist;
Branch: 1 branch
BranchTrueFalseTotal
if $dz > $dist 0 0 0
275 0 my $offset = $#{$self->{'viewpoint'}}+1;
276 0 $self->viewpoint_set("$x $y $z",$dist*$factor,60);
277 0 @_ = splice(@{$self->{'viewpoint'}}, $offset);
278 0 splice(@{$self->{'viewpoint'}}, $self->{'viewpoint_set'}, $#_+1, @_);
279 } else {
280 0 $self->viewpoint_set(@_);
281 }
282 0 return $self;
283 }
284  
285 0 ▶sub viewpoint_set {
Subroutine viewpoint_set: not called CC=10 SCAR=47.0
Pod undocumented
286 0 my $self = shift;
287 0 my ($center, $distance, $heightAngle) = @_;
288 0 ▶ $self->{'viewpoint_set'} = $#{$self->{'viewpoint'}}+1 unless defined $self->{'viewpoint_set'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"viewpoint_set"} 0 0 0
289 0 ▶ my ($x, $y, $z) = $self->string_to_array($center) if defined $center;
Branch: 1 branch
BranchTrueFalseTotal
if defined $center 0 0 0
290 0 ▶ my ($dx, $dy, $dz) = defined $distance ? $self->string_to_array($distance) : (0,0,0);
Branch: 1 branch
BranchTrueFalseTotal
defined $distance ? : 0 0 0
291 0 ▶ $x = 0 unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
292 0 ▶ $y = 0 unless defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $y 0 0 0
293 0 ▶ $z = 0 unless defined $z;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $z 0 0 0
294 0 ▶ $dx = 1 unless defined $dx;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dx 0 0 0
295 0 ▶ $dy = $dx unless defined $dy;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dy 0 0 0
296 0 ▶ $dz = $dx unless defined $dz;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dz 0 0 0
297 0 $self->viewpoint("Front", "$x $y ".($z+$dz), "0 0 1 0",$heightAngle);
298 0 $self->viewpoint("Right", ($x+$dx)." $y $z", "0 1 0 90",$heightAngle);
299 0 $self->viewpoint("Back", "$x $y ".($z-$dz), "0 1 0 180",$heightAngle);
300 0 $self->viewpoint("Left", ($x-$dx)." $y $z", "0 1 0 -90",$heightAngle);
301 0 $self->viewpoint("Top", "$x ".($y+$dy)." $z", "1 0 0 -90",$heightAngle);
302 0 $self->viewpoint("Bottom", "$x ".($y-$dy)." $z", "1 0 0 90",$heightAngle);
303 0 return $self;
304 }
305  
306 0 ▶sub viewpoint {
Subroutine viewpoint: not called CC=11 SCAR=48.8
Pod undocumented
307 0 my $self = shift;
308 0 my ($name, $position, $orientation, $heightAngle) = @_;
309 0 ▶ if (defined $orientation) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $orientation) 0 0 0
310 0 ▶ if ($orientation !~ /\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $orientation =~ /\s/) { } 0 0 0
311 0 my %val = ("FRONT" => "0 0 1 0", "BACK" => "0 1 0 3.14",
312 "RIGHT" => "0 1 0 1.57", "LEFT" => "0 1 0 -1.57",
313 "TOP" => "1 0 0 -1.57", "BOTTOM" => "1 0 0 1.57");
314 0 my $string = uc($orientation);
315 0 undef $orientation;
316 0 $orientation = $val{$string};
317 0 ▶ $orientation .= " # $string" if $orientation && $self->{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $orientation and $self->{"DEBUG"} 0 0 0
Condition0%0/3
$orientation and $self->{"DEBUG"}
!ll&&!rl&&r
000
MC/DC0%0/2
$orientation and $self->{"DEBUG"}
$orientation $self->{"DEBUG"}
Truth table0%0/3
A and B
A= $orientationB= $self->{"DEBUG"}
ABresult
0X0
100
111
318 } else {
319 0 my ($x,$y,$z,$angle) = $self->string_to_array($orientation);
320 0 ▶ if (defined $angle) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $angle) 0 0 0
321 0 ▶ $angle *= $PI/180 if $self->{'CONVERT'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CONVERT"} 0 0 0
322 0 $orientation = "$x $y $z $angle";
323 }
324 }
325 }
326 0 ▶ $heightAngle *= $PI/180 if defined $heightAngle && $self->{'CONVERT'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $heightAngle and $self->{"CONVERT"} 0 0 0
Condition0%0/3
defined $heightAngle and $self->{"CONVERT"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $heightAngle and $self->{"CONVERT"}
defined $heightAngle $self->{"CONVERT"}
Truth table0%0/3
A and B
A= defined $heightAngleB= $self->{"CONVERT"}
ABresult
0X0
100
111
327 0 ▶ $self->{'TAB_VIEW'} = $self->{'TAB'} unless $self->{'TAB_VIEW'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"TAB_VIEW"} 0 0 0
328 0 $name =~ s/^#//;
329 0 $name =~ s/[\x00-\x20\x22\x23\x27\x2b-\x2e\x30-\x39\x5b-\x5d\x7b\x7d\x7f]/_/g;
330 0 push @{$self->{'viewpoint'}}, $self->{'TAB_VIEW'}."DEF $name\n";
331 0 $self->PerspectiveCamera($position, $orientation, $heightAngle);
332 0 push @{$self->{'viewpoint'}}, pop @{$self->{'VRML'}};
333 0 ▶ unless (defined $self->{'viewpoint_begin'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"viewpoint_begin"}) 0 0 0
334 0 splice(@{$self->{'VRML'}}, @{$self->{'VRML'}}, 0, @{$self->{'viewpoint'}});
335 0 $self->{'viewpoint'} = [];
336 }
337 0 return $self;
338 }
339  
340 #--------------------------------------------------------------------
341  
342 0 ▶sub directionallight {
Subroutine directionallight: not called CC=4 SCAR=30.0
Pod undocumented
343 0 my $self = shift;
344 0 my ($direction, $intensity, $ambientIntensity, $color, $on) = @_;
345 0 ▶ if (defined $on) { $on = $on ? "TRUE" : "FALSE"; }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $on) 0 0 0
$on ? : 0 0 0
346 0 ▶ $color = rgb_color($color) if defined $color;
Branch: 1 branch
BranchTrueFalseTotal
if defined $color 0 0 0
347 0 $self->DirectionalLight($direction, $intensity, $color, $on);
348 0 return $self;
349 }
350  
351 #--------------------------------------------------------------------
352  
353 0 ▶sub line {
Subroutine line: not called CC=39 SCAR=73.5
Pod undocumented
354 0 my $self = shift;
355 0 ▶ return $self->_put(qq{# CALL: ->line("fromXYZ","toXYZ",radius,"appearance","[x][y][z]");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
356 0 my ($from,$to,$radius,$appearance,$order) = @_;
357 0 my ($x1,$y1,$z1) = $self->string_to_array($from);
358 0 my ($x2,$y2,$z2) = $self->string_to_array($to);
359 0 my ($t, $r, $length);
360  
361 0 ▶ $x1 = 0 unless $x1;
Branch: 1 branch
BranchTrueFalseTotal
unless $x1 0 0 0
362 0 ▶ $x2 = 0 unless $x2;
Branch: 1 branch
BranchTrueFalseTotal
unless $x2 0 0 0
363 0 ▶ $y1 = 0 unless $y1;
Branch: 1 branch
BranchTrueFalseTotal
unless $y1 0 0 0
364 0 ▶ $y2 = 0 unless $y2;
Branch: 1 branch
BranchTrueFalseTotal
unless $y2 0 0 0
365 0 ▶ $z1 = 0 unless $z1;
Branch: 1 branch
BranchTrueFalseTotal
unless $z1 0 0 0
366 0 ▶ $z2 = 0 unless $z2;
Branch: 1 branch
BranchTrueFalseTotal
unless $z2 0 0 0
367 0 my $dx=$x1-$x2;
368 0 my $dy=$y1-$y2;
369 0 my $dz=$z1-$z2;
370 0 ▶ unless ($radius =~ /^(-?)([0-9]*)(\.?)([0-9]+)$/) { die "'$radius' is not a number\n" };
Branch: 1 branch
BranchTrueFalseTotal
unless ($radius =~ /^(-?)([0-9]*)(\.?)([0-9]+)$/) 0 0 0
371 0 ▶ $order = "" unless defined $order;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $order 0 0 0
372 0 ▶ $self->comment('line("'.join('", "',@_).'")') if $self->{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DEBUG"} 0 0 0
373 0 $self->Separator;
374 0 ▶ if ($appearance) {
Branch: 1 branch
BranchTrueFalseTotal
if ($appearance) 0 0 0
375 0 ▶ if (defined $radius && $radius==0 && ($self->{'BROWSER'} =~ /Cosmo Player/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $radius and $radius == 0 and $self->{'BROWSER'} =~ /Cosmo Player/) { } 0 0 0
Condition0%0/6
defined $radius and $radius == 0 and $self->{"BROWSER"} =~ /Cosmo Player/
!ll&&!rl&&r
000
defined $radius and $radius == 0
!ll&&!rl&&r
000
MC/DC0%0/3
defined $radius and $radius == 0 and $self->{"BROWSER"} =~ /Cosmo Player/
defined $radius $radius == 0 $self->{"BROWSER"} =~ /Cosmo Player/
Truth table0%0/4
A and B and C
A= defined $radiusB= $radius == 0C= $self->{"BROWSER"} =~ /Cosmo Player/
ABCresult
0XX0
10X0
1100
1111
376 0 $self->appearance("$appearance, 0 0 0");
377 } else {
378 0 $self->appearance($appearance);
379 }
380 }
381 0 ▶ if (defined $radius && $radius>0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $radius and $radius > 0) { } 0 0 0
Condition0%0/3
defined $radius and $radius > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $radius and $radius > 0
defined $radius $radius > 0
Truth table0%0/3
A and B
A= defined $radiusB= $radius > 0
ABresult
0X0
100
111
382 0 ▶ if ($dx && $order =~ /x/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dx and $order =~ /x/) 0 0 0
Condition0%0/3
$dx and $order =~ /x/
!ll&&!rl&&r
000
MC/DC0%0/2
$dx and $order =~ /x/
$dx $order =~ /x/
Truth table0%0/3
A and B
A= $dxB= $order =~ /x/
ABresult
0X0
100
111
383 0 $self->Separator("line_x");
384 0 ▶ $t = ($x1-($dx/2))." $y1 $z1" if $order =~ /^x$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^x$/i 0 0 0
385 0 ▶ $t = ($x1-($dx/2))." $y1 $z1" if $order =~ /^x../i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^x../i 0 0 0
386 0 ▶ $t = ($x1-($dx/2))." $y2 $z1" if $order =~ /yxz/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /yxz/i 0 0 0
387 0 ▶ $t = ($x1-($dx/2))." $y1 $z2" if $order =~ /zxy/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /zxy/i 0 0 0
388 0 ▶ $t = ($x1-($dx/2))." $y2 $z2" if $order =~ /..x$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /..x$/i 0 0 0
389 0 $self->Transform($t,"0 0 1 ".$PI_2);
390 0 $self->Cylinder($radius,abs($dx));
391 0 $self->End();
392 }
393 0 ▶ if ($dy && $order =~ /y/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dy and $order =~ /y/) 0 0 0
Condition0%0/3
$dy and $order =~ /y/
!ll&&!rl&&r
000
MC/DC0%0/2
$dy and $order =~ /y/
$dy $order =~ /y/
Truth table0%0/3
A and B
A= $dyB= $order =~ /y/
ABresult
0X0
100
111
394 0 $self->Separator("line_y");
395 0 ▶ $t = "$x1 ".($y1-($dy/2))." $z1" if $order =~ /^y$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^y$/i 0 0 0
396 0 ▶ $t = "$x1 ".($y1-($dy/2))." $z1" if $order =~ /^y../i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^y../i 0 0 0
397 0 ▶ $t = "$x2 ".($y1-($dy/2))." $z1" if $order =~ /xyz/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /xyz/i 0 0 0
398 0 ▶ $t = "$x1 ".($y1-($dy/2))." $z2" if $order =~ /zyx/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /zyx/i 0 0 0
399 0 ▶ $t = "$x2 ".($y1-($dy/2))." $z2" if $order =~ /..y$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /..y$/i 0 0 0
400 0 $self->Transform($t);
401 0 $self->Cylinder($radius,abs($dy));
402 0 $self->End();
403 }
404 0 ▶ if ($dz && $order =~ /z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dz and $order =~ /z/) 0 0 0
Condition0%0/3
$dz and $order =~ /z/
!ll&&!rl&&r
000
MC/DC0%0/2
$dz and $order =~ /z/
$dz $order =~ /z/
Truth table0%0/3
A and B
A= $dzB= $order =~ /z/
ABresult
0X0
100
111
405 0 $self->Separator("line_z");
406 0 ▶ $t = "$x1 $y1 ".($z1-($dz/2)) if $order =~ /^z$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^z$/i 0 0 0
407 0 ▶ $t = "$x1 $y1 ".($z1-($dz/2)) if $order =~ /^z../i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /^z../i 0 0 0
408 0 ▶ $t = "$x1 $y2 ".($z1-($dz/2)) if $order =~ /yzx/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /yzx/i 0 0 0
409 0 ▶ $t = "$x2 $y1 ".($z1-($dz/2)) if $order =~ /xzy/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /xzy/i 0 0 0
410 0 ▶ $t = "$x2 $y2 ".($z1-($dz/2)) if $order =~ /..z$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $order =~ /..z$/i 0 0 0
411 0 $self->Transform($t,"1 0 0 ".$PI_2);
412 0 $self->Cylinder($radius,abs($dz));
413 0 $self->End();
414 }
415 0 ▶ unless ($order) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($order) 0 0 0
416 0 $length = sqrt($dx*$dx + $dy*$dy + $dz*$dz);
417 0 $t = ($x1-($dx/2))." ".($y1-($dy/2))." ".($z1-($dz/2));
418 0 $r = "$dx ".($dy+$length)." $dz ".$PI;
419 0 $self->Transform($t,$r);
420 0 $self->Cylinder($radius,$length);
421 }
422 } else {
423 0 $self->MaterialBinding("PER_FACE");
424 0 $self->Coordinate3($from,$to);
425 0 $self->IndexedLineSet(["0, 1"]);
426 }
427 0 $self->End("line");
428 0 return $self;
429 }
430  
431 #--------------------------------------------------------------------
432  
433 1 ▶sub box {
Subroutine box: called CC=3 SCAR=11.2
Pod undocumented
434 1 my $self = shift;
435 1 my ($dimension, $appearance) = @_;
436 1 my ($width,$height,$depth) = $self->string_to_array($dimension);
437 1 ▶ $self->Group->appearance($appearance) if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
438 1 $self->Cube($width,$height,$depth);
439 1 ▶ $self->End if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
440 1 return $self;
441 }
442  
443 1 ▶sub cone {
Subroutine cone: called CC=3 SCAR=11.2
Pod undocumented
444 1 my $self = shift;
445 1 my ($dimension, $appearance) = @_;
446 1 my ($radius, $height) = $self->string_to_array($dimension);
447 1 ▶ $self->Group->appearance($appearance) if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
448 1 $self->Cone($radius, $height);
449 1 ▶ $self->End if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
450 1 return $self;
451 }
452  
453 1 ▶sub cube {
Subroutine cube: called CC=5 SCAR=16.7
Pod undocumented
454 1 my $self = shift;
455 1 my ($dimension, $appearance) = @_;
456 1 my ($width,$height,$depth) = $self->string_to_array($dimension);
457 1 ▶ $height=$width unless defined $height;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $height 1 0 1
458 1 ▶ $depth=$width unless defined $depth;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $depth 1 0 1
459 1 ▶ $self->Group->appearance($appearance) if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
460 1 $self->Cube($width,$height,$depth);
461 1 ▶ $self->End if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
462 1 return $self;
463 }
464  
465 1 ▶sub cylinder {
Subroutine cylinder: called CC=12 SCAR=39.1
Pod undocumented
466 1 my $self = shift;
467 1 my ($dimension, $appearance, $top, $side, $bottom) = @_;
468 1 my ($radius, $height) = $self->string_to_array($dimension);
469 1 my @parts;
470 1 ▶ $self->Group->appearance($appearance) if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
471 1 ▶ if (defined $top || defined $side || defined $bottom) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $top or defined $side or defined $bottom) 0 1 1
Condition33%2/6
defined $top or defined $side or defined $bottom
l!l&&r!l&&!r
001
defined $top or defined $side
l!l&&r!l&&!r
001
MC/DC0%0/3
defined $top or defined $side or defined $bottom
defined $top defined $side defined $bottom
Truth table25%1/4
A or B or C
A= defined $topB= defined $sideC= defined $bottom
ABCresult
1XX1
01X1
0011
0000
472 0 ▶ $top = 1 unless defined $top;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $top 0 0 0
473 0 ▶ $side = 1 unless defined $side;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $side 0 0 0
474 0 ▶ $bottom = 1 unless defined $bottom;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bottom 0 0 0
475 0 ▶ push @parts, "TOP" if $top;
Branch: 1 branch
BranchTrueFalseTotal
if $top 0 0 0
476 0 ▶ push @parts, "SIDES" if $side;
Branch: 1 branch
BranchTrueFalseTotal
if $side 0 0 0
477 0 ▶ push @parts, "BOTTOM" if $bottom;
Branch: 1 branch
BranchTrueFalseTotal
if $bottom 0 0 0
478 }
479 1 $self->Cylinder($radius, $height, @parts);
480 1 ▶ $self->End if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
481 1 return $self;
482 }
483  
484 0 ▶sub pyramid {
Subroutine pyramid: not called CC=5 SCAR=34.0
Pod undocumented
485 0 my $self = shift;
486 0 my ($dimension, $appearance) = @_;
487 0 my ($width,$height,$depth) = $self->string_to_array($dimension);
488 0 my $x_2 = $width/2;
489 0 my $y_2 = $height/2;
490 0 ▶ my $z_2 = defined $depth ? $depth/2 : $x_2;
Branch: 1 branch
BranchTrueFalseTotal
defined $depth ? : 0 0 0
491 0 my $color_prop = "";
492 0 ▶ if ($appearance) {
Branch: 1 branch
BranchTrueFalseTotal
if ($appearance) 0 0 0
493 0 ▶ if ($appearance =~ /,/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($appearance =~ /,/) 0 0 0
494 0 $color_prop = [0..4];
495 0 $self->MaterialBinding("PER_FACE_INDEXED");
496 }
497 0 $self->Group->appearance($appearance);
498 }
499 0 $self->Coordinate3("-$x_2 -$y_2 $z_2","$x_2 -$y_2 $z_2","$x_2 -$y_2 -$z_2","-$x_2 -$y_2 -$z_2","0 $y_2 0")
500 ->IndexedFaceSet(["0, 1, 4","1, 2, 4","2, 3, 4","3, 0, 4","0, 3, 2, 1"],$color_prop);
501 0 ▶ $self->End("pyramid") if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 0 0 0
502 0 return $self;
503 }
504  
505 1 ▶sub sphere {
Subroutine sphere: called CC=3 SCAR=11.2
Pod undocumented
506 1 my $self = shift;
507 1 my ($radius, $appearance) = @_;
508 1 ▶ $self->Group->appearance($appearance) if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
509 1 $self->Sphere($radius);
510 1 ▶ $self->End if $appearance;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance 1 0 1
511 1 return $self;
512 }
513  
514 1 ▶sub text {
Subroutine text: called CC=11 SCAR=28.7
Pod undocumented
515 1 my $self = shift;
516 1 my ($string, $appearance, $font, $align) = @_;
517 1 ▶ my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'BROWSER'} =~ /$VRML::VRML1::supported{'quote'}/i ? : 0 1 1
518 1 ▶ $string =~ s/"/$quote/g if defined $string;
Branch: 1 branch
BranchTrueFalseTotal
if defined $string 1 0 1
519 1 ▶ $self->Group->appearance($appearance) if $appearance || $font;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance or $font 1 0 1
Condition33%1/3
$appearance or $font
l!l&&r!l&&!r
100
MC/DC0%0/2
$appearance or $font
$appearance $font
Truth table33%1/3
A or B
A= $appearanceB= $font
ABresult
1X1
011
000
520 1 ▶ if (defined $string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $string) 1 0 1
521 1 ▶ if (ref($string)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $string) { } 0 1 1
522 0 $string = '["'.join('","',@$string).'"]';
523 } else {
524 1 $string =~ s/"/$quote/g;
525 1 $string = "\"$string\"";
526 }
527 }
528 1 ▶ if (defined $font) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $font) 1 0 1
529 1 my ($size, $family, $style) = split(/\s+/,$font,3);
530 1 $self->FontStyle($size, $family, $style);
531 }
532 1 ▶ if (defined $align) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $align) 0 1 1
533 0 $align =~ s/BEGIN/LEFT/i;
534 0 $align =~ s/MIDDLE/CENTER/i;
535 0 $align =~ s/END/RIGHT/i;
536 }
537 1 $self->AsciiText($string, undef, $align);
538 1 ▶ $self->End if $appearance || $font;
Branch: 1 branch
BranchTrueFalseTotal
if $appearance or $font 1 0 1
Condition33%1/3
$appearance or $font
l!l&&r!l&&!r
100
MC/DC0%0/2
$appearance or $font
$appearance $font
Truth table33%1/3
A or B
A= $appearanceB= $font
ABresult
1X1
011
000
539 1 return $self;
540 }
541  
542 0 ▶sub billtext {
Subroutine billtext: not called CC=2 SCAR=17.9
Pod undocumented
543 0 my $self = shift;
544 0 $self->Separator;
545 0 ▶ $self->_row("AxisAlignment { fields [SFBitMask alignment] alignment ALIGNAXISXYZ }\n") if $self->{'BROWSER'} =~ /$supported{'L3D_ext'}/i;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"BROWSER"} =~ /$VRML::VRML1::supported{"L3D_ext"}/i 0 0 0
546 0 $self->text(@_);
547 0 $self->End;
548 }
549 #--------------------------------------------------------------------
550  
551 6 ▶sub appearance {
Subroutine appearance: called CC=26 SCAR=47.3
Pod undocumented
552 6 my $self = shift;
553 6 my ($appearance_list) = @_;
554 6 ▶ return $self unless $appearance_list;
Branch: 1 branch
BranchTrueFalseTotal
unless $appearance_list 0 6 6
555 6 my ($item, $color, $multi_color, $key, $value, @values, $num_color,
556 $texture, %material, $def, $defmat, $deftex);
557 ITEM:
558 6 foreach $item (split(/\s*;\s*/,$appearance_list)) {
559 6 ($key,$value) = split(/\s*=\s*/,$item,2);
560 6 ▶ unless ($value) { # color only
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 6 0 6
561 6 $value = $key;
562 6 $key = "diffuseColor";
563 }
564 MODE: {
565 0 ▶ if ($key eq "d") { $key = "diffuseColor"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "d") 0 6 6
566 0 ▶ if ($key eq "e") { $key = "emissiveColor"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "e") 0 6 6
567 0 ▶ if ($key eq "s") { $key = "specularColor"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "s") 0 6 6
568 0 ▶ if ($key eq "a") { $key = "ambientColor"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "a") 0 6 6
569 0 ▶ if ($key eq "sh") { $key = "shininess"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "sh") 0 6 6
570 0 ▶ if ($key eq "tr") { $key = "transparency"; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "tr") 0 6 6
571 0 ▶ if ($key eq "tex") { $texture = $value; next ITEM; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "tex") 0 6 6
572 0 ▶ if ($key eq "def") { $def = $value; next ITEM; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "def") 0 6 6
573 0 ▶ if ($key eq "defmat") { $defmat = $value; next ITEM; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "defmat") 0 6 6
574 0 ▶ if ($key eq "deftex") { $deftex = $value; next ITEM; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "deftex") 0 6 6
575 }
576 6 ▶ if ($key eq "diffuseColor" | $key eq "emissiveColor" | $key eq "specularColor" | $key eq "ambientColor") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'diffuseColor' | $key eq 'emissiveColor' | $key eq 'specularColor' | $key eq 'ambientColor') { } 6 0 6
577 6 ▶ if ($value =~ /,/) { # multi color field
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /,/) { } 0 6 6
578 0 foreach $color (split(/\s*,\s*/,$value)) {
579 0 ($num_color,$color) = rgb_color($color);
580 0 $value = $num_color;
581 0 ▶ $value .= " # $color" if $color && $self->{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $color and $self->{"DEBUG"} 0 0 0
Condition0%0/3
$color and $self->{"DEBUG"}
!ll&&!rl&&r
000
MC/DC0%0/2
$color and $self->{"DEBUG"}
$color $self->{"DEBUG"}
Truth table0%0/3
A and B
A= $colorB= $self->{"DEBUG"}
ABresult
0X0
100
111
582 0 push @values, $value;
583 }
584 0 $material{$key} = [@values];
585 0 $multi_color = 1;
586 } else {
587 6 ($num_color,$color) = rgb_color($value);
588 6 $value = $num_color;
589 6 ▶ $value .= " # $color" if $color && $self->{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $color and $self->{"DEBUG"} 0 6 6
Condition33%1/3
$color and $self->{"DEBUG"}
!ll&&!rl&&r
060
MC/DC0%0/2
$color and $self->{"DEBUG"}
$color $self->{"DEBUG"}
Truth table33%1/3
A and B
A= $colorB= $self->{"DEBUG"}
ABresult
0X0
100
111
590 6 $material{$key} = $value;
591 }
592 } else {
593 0 $material{$key} = $value;
594 }
595 }
596 6 ▶ $self->def($def)->group_begin if $def;
Branch: 1 branch
BranchTrueFalseTotal
if $def 0 6 6
597 6 ▶ $self->def($defmat) if $defmat;
Branch: 1 branch
BranchTrueFalseTotal
if $defmat 0 6 6
598 6 $self->Material(%material);
599 # $self->MaterialBinding("PER_FACE_INDEXED") if $multi_color;
600 6 ▶ $self->def($deftex) if $deftex;
Branch: 1 branch
BranchTrueFalseTotal
if $deftex 0 6 6
601 6 ▶ $self->Texture2($self->string_to_array($texture)) if defined $texture;
Branch: 1 branch
BranchTrueFalseTotal
if defined $texture 0 6 6
602 6 ▶ $self->group_end if $def;
Branch: 1 branch
BranchTrueFalseTotal
if $def 0 6 6
603 6 return $self;
604 }
605  
606  
607 #--------------------------------------------------------------------
608  
609 0 ▶sub transform_begin {
Subroutine transform_begin: not called CC=19 SCAR=59.4
Pod undocumented
610 0 my $self = shift;
611 0 ▶ return $self->Separator unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
612 0 my (@transform_list) = @_;
613 0 my @transform;
614 0 ▶ if (ref($transform_list[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $transform_list[0]) { } 0 0 0
615 0 @transform = @{$transform_list[0]};
616 } else {
617 0 @transform = @transform_list;
618 }
619 0 my ($item, $key, $value);
620 0 my ($x,$y,$z,$angle,$t,$r,$s,$o,$c);
621 0 foreach $item (@transform) {
622 0 ▶ ($key,$value) = ref($item) ? @$item : split(/\s*=\s*/,$item);
Branch: 1 branch
BranchTrueFalseTotal
ref $item ? : 0 0 0
623 0 ▶ unless ($value) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value) 0 0 0
624 0 ($x,$y,$z) = split(/\s/,$key);
625 0 ▶ $x=0 unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
626 0 ▶ $y=0 unless defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $y 0 0 0
627 0 ▶ $z=0 unless defined $z;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $z 0 0 0
628 0 $t = "$x $y $z";
629 }
630 MODE: {
631 0 ▶ if ($key eq "t") { $t = $value; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "t") 0 0 0
632 0 ▶ if ($key eq "r" || $key eq "rotation") { $r = $value; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "r" or $key eq "rotation") 0 0 0
Condition0%0/3
$key eq "r" or $key eq "rotation"
l!l&&r!l&&!r
000
MC/DC0%0/2
$key eq "r" or $key eq "rotation"
$key eq "r" $key eq "rotation"
Truth table0%0/3
A or B
A= $key eq "r"B= $key eq "rotation"
ABresult
1X1
011
000
633 0 ▶ if ($key eq "c") { $c = $value; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "c") 0 0 0
634 0 ▶ if ($key eq "s") { $s = $value; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "s") 0 0 0
635 0 ▶ if ($key eq "so") { $o = $value; last MODE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "so") 0 0 0
636 }
637 0 ▶ if ($key eq "r" || $key eq "rotation") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "r" or $key eq "rotation") 0 0 0
Condition0%0/3
$key eq "r" or $key eq "rotation"
l!l&&r!l&&!r
000
MC/DC0%0/2
$key eq "r" or $key eq "rotation"
$key eq "r" $key eq "rotation"
Truth table0%0/3
A or B
A= $key eq "r"B= $key eq "rotation"
ABresult
1X1
011
000
638 0 ($x,$y,$z,$angle) = split(/\s/,$value);
639 0 ▶ unless (defined $angle) { # if one param its the angle
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $angle) 0 0 0
640 0 $angle=$x;
641 0 $x=0;
642 0 $y=0;
643 0 $z=1;
644 }
645 0 ▶ $angle *= $PI/180 if $self->{'CONVERT'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CONVERT"} 0 0 0
646 0 $r = "$x $y $z $angle";
647 }
648 }
649 0 $self->Separator->Transform($t,$r,$s,$o,$c);
650 0 return $self;
651 }
652  
653 0 ▶sub transform_end {
Subroutine transform_end: not called CC=1 SCAR=6.9
Pod undocumented
654 0 my $self = shift;
655 0 $self->End();
656 0 return $self;
657 }
658  
659 #--------------------------------------------------------------------
660  
661 0 ▶sub sound {
Subroutine sound: not called CC=4 SCAR=30.0
Pod undocumented
662 0 my $self = shift;
663 0 ▶ return $self->_put(qq{# CALL: ->sound("url", "description", ...)\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
664 0 my ($url, $description, $location, $direction, $intensity, $loop, $pitch, $pause) = @_;
665 0 ▶ $loop = defined $loop && $loop ? "TRUE" : "FALSE";
Branch: 1 branch
BranchTrueFalseTotal
defined $loop && $loop ? : 0 0 0
Condition0%0/3
defined $loop and $loop
!ll&&!rl&&r
000
MC/DC0%0/2
defined $loop and $loop
defined $loop $loop
Truth table0%0/3
A and B
A= defined $loopB= $loop
ABresult
0X0
100
111
666 0 $self->DirectedSound($url, $description, $location, $direction, $intensity, 100, 0, 0, 0, $loop);
667 0 return $self;
668 }
669  
670 #--------------------------------------------------------------------
671  
672 0 ▶sub def {
Subroutine def: not called CC=4 SCAR=30.0
Pod undocumented
673 0 my $self = shift;
674 0 my ($name, $code) = @_;
675 0 ▶ $name = "_DEF_".(++$self->{'ID'}) unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 0 0
676 0 $self->DEF($name);
677 0 ▶ if (defined $code) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code) 0 0 0
678 0 ▶ if (ref($code) eq "CODE") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $code eq 'CODE') { } 0 0 0
679 0 $self->{'TAB'} .= "\t";
680 0 my $pos = $#{$self->{'VRML'}}+1;
681 0 &$code;
682 0 $self->_trim($pos);
683 0 chop($self->{'TAB'});
684 } else {
685 0 $self->_put($code);
686 }
687 }
688 0 return $self;
689 }
690  
691 0 ▶sub use {
Subroutine use: not called CC=2 SCAR=17.9
Pod undocumented
692 0 my $self = shift;
693 0 ▶ return $self->_put(qq{# CALL: ->use("name");\n}) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
694 0 my ($name) = @_;
695 0 $self->USE($name);
696 0 return $self;
697 }
698  
699 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
700 0 my $self = shift;
701 0 $AUTOLOAD =~ s/.*:://g;
702 0 ▶ unless ($AUTOLOAD =~ /^route|sensor$|^interpolator$|^elevationgrid$|^indexedfaceset$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($VRML::VRML1::AUTOLOAD =~ /^route|sensor$|^interpolator$|^elevationgrid$|^indexedfaceset$/) 0 0 0
703 0 my ($package, $filename, $line) = caller;
704 0 die qq{Unknown method "$AUTOLOAD" at $filename line $line.\n};
705 }
706 0 return $self->_row(qq{### "$AUTOLOAD" is not supported by VRML::VRML1\n});
707 }
708  
709 1 1;
710  
711 __END__
↑ Summary VRML/VRML2.pm »