| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package VRML::VRML2; |
|
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
|
|
|
|
|
|
|
require 5.000; |
|
23
|
|
|
|
|
|
|
require VRML::VRML2::Standard; |
|
24
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
25
|
1
|
|
|
1
|
|
308
|
use VRML::Color; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
55
|
|
|
26
|
1
|
|
|
1
|
|
3
|
use vars qw(@ISA $VERSION %supported); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6355
|
|
|
27
|
|
|
|
|
|
|
@ISA = qw(VRML::VRML2::Standard); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$VERSION = "1.10"; |
|
30
|
|
|
|
|
|
|
%supported = ( |
|
31
|
|
|
|
|
|
|
'quote' => "Cortona VRML Client|Cosmo Player|CosmoPlayer|Live3D|WorldView", |
|
32
|
|
|
|
|
|
|
'gzip' => "Cortona VRML Client|Cosmo Player|CosmoPlayer|libcosmoplayer|Live3D|WorldView|VRweb|GLview", |
|
33
|
|
|
|
|
|
|
'target'=> "Cortona VRML Client|Cosmo Player|CosmoPlayer|libcosmoplayer|Live3D|WorldView|MSVRML2OCX" |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $PI = 3.1415926; |
|
37
|
|
|
|
|
|
|
my $PI_2 = $PI / 2; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
|
42
|
6
|
|
|
6
|
1
|
9
|
my $class = shift; |
|
43
|
6
|
|
|
|
|
6
|
my $version = shift; |
|
44
|
6
|
|
|
|
|
22
|
my $self = new VRML::VRML2::Standard($version); |
|
45
|
6
|
|
|
|
|
13
|
$self->{'viewpoint'} = []; |
|
46
|
6
|
|
|
|
|
10
|
$self->{'route'} = []; |
|
47
|
6
|
|
|
|
|
16
|
return bless $self, $class; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub supported { |
|
51
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
52
|
0
|
|
|
|
|
0
|
my $feature = shift; |
|
53
|
0
|
|
|
|
|
0
|
return $self->{'BROWSER'} =~ /$supported{$feature}/i; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
57
|
|
|
|
|
|
|
# VRML Grouping Methods |
|
58
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
59
|
|
|
|
|
|
|
sub begin { |
|
60
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
0
|
$self->Group(@_); |
|
62
|
0
|
|
|
|
|
0
|
return $self; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub end { |
|
66
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
67
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { with comment |
|
68
|
0
|
|
|
|
|
0
|
for (@{$self->{'route'}}) { $self->ROUTE(@{$_}); } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
69
|
0
|
|
|
|
|
0
|
$self->{'route'} = []; |
|
70
|
0
|
|
|
|
|
0
|
return $self; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub anchor_begin { |
|
74
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
75
|
0
|
|
|
|
|
0
|
my ($url, $description, $parameter, $bboxSize, $bboxCenter) = @_; |
|
76
|
0
|
0
|
|
|
|
0
|
my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'"; |
|
77
|
0
|
0
|
|
|
|
0
|
$description =~ s/"/$quote/g if defined $description; |
|
78
|
0
|
0
|
|
|
|
0
|
$parameter =~ s/"/$quote/g if defined $parameter; |
|
79
|
0
|
0
|
|
|
|
0
|
undef $parameter if $self->{'BROWSER'} !~ /$supported{'target'}/i; |
|
80
|
0
|
|
|
|
|
0
|
$self->Anchor($url, $description, $parameter, $bboxSize, $bboxCenter); |
|
81
|
0
|
|
|
|
|
0
|
return $self; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub anchor_end { |
|
85
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
86
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
87
|
0
|
|
|
|
|
0
|
return $self; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub billboard_begin { |
|
91
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
92
|
0
|
|
|
|
|
0
|
$self->Billboard(@_); |
|
93
|
0
|
|
|
|
|
0
|
return $self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub billboard_end { |
|
97
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
98
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
99
|
0
|
|
|
|
|
0
|
return $self; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub collision_begin { |
|
103
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
104
|
0
|
|
|
|
|
0
|
my ($collide, $proxy) = @_; |
|
105
|
0
|
0
|
0
|
|
|
0
|
$collide = defined $collide && $collide ? "TRUE" : "FALSE"; |
|
106
|
0
|
|
|
|
|
0
|
$self->Collision($collide, $proxy); |
|
107
|
0
|
|
|
|
|
0
|
return $self; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub collision_end { |
|
111
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
112
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
113
|
0
|
|
|
|
|
0
|
return $self; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub group_begin { |
|
117
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
118
|
0
|
|
|
|
|
0
|
$self->Group(@_); |
|
119
|
0
|
|
|
|
|
0
|
return $self; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub group_end { |
|
123
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
124
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
125
|
0
|
|
|
|
|
0
|
return $self; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub lod_begin { |
|
129
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
130
|
0
|
|
|
|
|
0
|
$self->LOD(@_); |
|
131
|
0
|
|
|
|
|
0
|
return $self; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub lod_end { |
|
135
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
136
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
137
|
0
|
|
|
|
|
0
|
return $self; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub switch_begin { |
|
141
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
142
|
0
|
|
|
|
|
0
|
$self->Switch(@_); |
|
143
|
0
|
|
|
|
|
0
|
return $self; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub switch_end { |
|
147
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
148
|
0
|
|
|
|
|
0
|
$self->EndChildren->End($_[0]); # close [ and { |
|
149
|
0
|
|
|
|
|
0
|
return $self; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub at { |
|
153
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
154
|
0
|
|
|
|
|
0
|
$self->transform_begin(@_); |
|
155
|
0
|
|
|
|
|
0
|
return $self; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub back { |
|
159
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
160
|
0
|
|
|
|
|
0
|
$self->transform_end; |
|
161
|
0
|
|
|
|
|
0
|
return $self; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub transform_begin { |
|
165
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
166
|
0
|
|
|
|
|
0
|
my (@transform_list) = @_; |
|
167
|
0
|
|
|
|
|
0
|
my @transform; |
|
168
|
0
|
0
|
|
|
|
0
|
if (ref($transform_list[0])) { |
|
169
|
0
|
|
|
|
|
0
|
@transform = @{$transform_list[0]}; |
|
|
0
|
|
|
|
|
0
|
|
|
170
|
|
|
|
|
|
|
} else { |
|
171
|
0
|
|
|
|
|
0
|
@transform = @transform_list; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
0
|
0
|
|
|
|
0
|
return $self->Transform unless @transform; |
|
174
|
0
|
|
|
|
|
0
|
my ($item, $key, $value); |
|
175
|
0
|
|
|
|
|
0
|
my ($x,$y,$z,$angle,$t,$r,$s,$o,$c,$bbs,$bbc); |
|
176
|
0
|
|
|
|
|
0
|
foreach $item (@transform) { |
|
177
|
0
|
0
|
0
|
|
|
0
|
next if !defined $item or $item eq ""; |
|
178
|
0
|
0
|
|
|
|
0
|
($key,$value) = ref($item) ? @$item : split(/\s*=\s*/,$item); |
|
179
|
0
|
0
|
|
|
|
0
|
unless ($value) { |
|
180
|
0
|
|
|
|
|
0
|
($x,$y,$z) = split(/\s/,$key); |
|
181
|
0
|
0
|
|
|
|
0
|
$x=0 unless defined $x; |
|
182
|
0
|
0
|
|
|
|
0
|
$y=0 unless defined $y; |
|
183
|
0
|
0
|
|
|
|
0
|
$z=0 unless defined $z; |
|
184
|
0
|
|
|
|
|
0
|
$t = "$x $y $z"; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
MODE: { |
|
187
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "t" || $key eq "translation") { $t = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
188
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "r" || $key eq "rotation") { $r = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
189
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "c" || $key eq "center") { $c = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
190
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "s" || $key eq "scale") { $s = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
191
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "so" || $key eq "scaleOrientation") { $o = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
192
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "bbs" || $key eq "bboxSize") { $bbs = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
193
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "bbc" || $key eq "bboxCenter") { $bbc = $value; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
194
|
|
|
|
|
|
|
} |
|
195
|
0
|
0
|
0
|
|
|
0
|
if ($key eq "r" || $key eq "rotation") { |
|
196
|
0
|
|
|
|
|
0
|
($x,$y,$z,$angle) = split(/\s/,$value); |
|
197
|
0
|
0
|
|
|
|
0
|
unless (defined $angle) { # if one param its the angle |
|
198
|
0
|
|
|
|
|
0
|
$angle=$x; |
|
199
|
0
|
|
|
|
|
0
|
$x=0; |
|
200
|
0
|
|
|
|
|
0
|
$y=0; |
|
201
|
0
|
|
|
|
|
0
|
$z=1; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
0
|
0
|
|
|
|
0
|
$angle *= $PI/180 if $self->{'CONVERT'}; |
|
204
|
0
|
|
|
|
|
0
|
$r = "$x $y $z $angle"; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
} |
|
207
|
0
|
|
|
|
|
0
|
$self->Transform($t,$r,$s,$o,$c,$b); |
|
208
|
0
|
|
|
|
|
0
|
return $self; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub transform_end { |
|
212
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
213
|
0
|
|
|
|
|
0
|
$self->EndTransform("Transform"); |
|
214
|
0
|
0
|
|
|
|
0
|
unless ($self->{'TAB'}) { |
|
215
|
0
|
|
|
|
|
0
|
for (@{$self->{'route'}}) { $self->ROUTE(@{$_}); } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
216
|
0
|
|
|
|
|
0
|
$self->{'route'} = []; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
0
|
|
|
|
|
0
|
return $self; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub inline { |
|
222
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
223
|
0
|
|
|
|
|
0
|
$self->Inline(@_); |
|
224
|
0
|
|
|
|
|
0
|
return $self; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
228
|
|
|
|
|
|
|
# VRML Methods |
|
229
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub background { |
|
232
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
233
|
0
|
|
|
|
|
0
|
my %hash = @_; |
|
234
|
0
|
|
|
|
|
0
|
my ($key,$value,@list); |
|
235
|
0
|
0
|
|
|
|
0
|
if (defined $hash{'skyColor'}) { |
|
236
|
0
|
0
|
|
|
|
0
|
if (ref($hash{'skyColor'}) eq "ARRAY") { |
|
237
|
0
|
|
|
|
|
0
|
@list = (); |
|
238
|
0
|
|
|
|
|
0
|
for $key (@{$hash{'skyColor'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
239
|
0
|
|
|
|
|
0
|
$value = rgb_color($key); |
|
240
|
0
|
|
|
|
|
0
|
push(@list, $value); |
|
241
|
|
|
|
|
|
|
} |
|
242
|
0
|
|
|
|
|
0
|
$hash{'skyColor'} = "[ ".join(", ",@list)." ]"; |
|
243
|
0
|
0
|
|
|
|
0
|
if (defined $hash{'skyAngle'}) { |
|
244
|
0
|
0
|
|
|
|
0
|
if (ref($hash{'skyAngle'}) eq "ARRAY") { |
|
245
|
0
|
|
|
|
|
0
|
@list = (); |
|
246
|
0
|
|
|
|
|
0
|
for $key (@{$hash{'skyAngle'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
247
|
0
|
0
|
|
|
|
0
|
$key *= $PI/180 if $self->{'CONVERT'}; |
|
248
|
0
|
|
|
|
|
0
|
push(@list, $key); |
|
249
|
|
|
|
|
|
|
} |
|
250
|
0
|
|
|
|
|
0
|
$hash{'skyAngle'} = "[ ".join(", ",@list)." ]"; |
|
251
|
|
|
|
|
|
|
} else { |
|
252
|
0
|
0
|
|
|
|
0
|
$hash{'skyAngle'} *= $PI/180 if $self->{'CONVERT'}; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
} else { |
|
256
|
0
|
|
|
|
|
0
|
$hash{'skyColor'} = rgb_color($hash{'skyColor'}); |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
} |
|
259
|
0
|
0
|
|
|
|
0
|
if (defined $hash{'groundColor'}) { |
|
260
|
0
|
0
|
|
|
|
0
|
if (ref($hash{'groundColor'}) eq "ARRAY") { |
|
261
|
0
|
|
|
|
|
0
|
@list = (); |
|
262
|
0
|
|
|
|
|
0
|
for $key (@{$hash{'groundColor'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
263
|
0
|
|
|
|
|
0
|
$value = rgb_color($key); |
|
264
|
0
|
|
|
|
|
0
|
push(@list, $value); |
|
265
|
|
|
|
|
|
|
} |
|
266
|
0
|
|
|
|
|
0
|
$hash{'groundColor'} = "[ ".join(", ",@list)." ]"; |
|
267
|
0
|
0
|
|
|
|
0
|
if (defined $hash{'groundAngle'}) { |
|
268
|
0
|
0
|
|
|
|
0
|
if (ref($hash{'groundAngle'}) eq "ARRAY") { |
|
269
|
0
|
|
|
|
|
0
|
@list = (); |
|
270
|
0
|
|
|
|
|
0
|
for $key (@{$hash{'groundAngle'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
271
|
0
|
0
|
|
|
|
0
|
$key *= $PI/180 if $self->{'CONVERT'}; |
|
272
|
0
|
|
|
|
|
0
|
push(@list, $key); |
|
273
|
|
|
|
|
|
|
} |
|
274
|
0
|
|
|
|
|
0
|
$hash{'groundAngle'} = "[ ".join(", ",@list)." ]"; |
|
275
|
|
|
|
|
|
|
} else { |
|
276
|
0
|
0
|
|
|
|
0
|
$hash{'groundAngle'} *= $PI/180 if $self->{'CONVERT'}; |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
} else { |
|
280
|
0
|
|
|
|
|
0
|
$hash{'groundColor'} = rgb_color($hash{'groundColor'}); |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
} |
|
283
|
0
|
0
|
|
|
|
0
|
foreach $key (keys %hash) { $hash{$key} = "\"$hash{$key}\"" if $key =~ |
|
|
0
|
|
|
|
|
0
|
|
|
284
|
|
|
|
|
|
|
/Url$/; } |
|
285
|
0
|
|
|
|
|
0
|
$self->Background(%hash); |
|
286
|
0
|
|
|
|
|
0
|
return $self; |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub backgroundcolor { |
|
290
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
291
|
0
|
|
|
|
|
0
|
my ($skyColorString, $groundColorString) = @_; |
|
292
|
0
|
|
|
|
|
0
|
my ($skyColor, $groundColor); |
|
293
|
0
|
0
|
|
|
|
0
|
$skyColor = rgb_color($skyColorString) if defined $skyColorString; |
|
294
|
0
|
0
|
|
|
|
0
|
$groundColor = rgb_color($groundColorString) if defined $groundColorString; |
|
295
|
0
|
|
|
|
|
0
|
$self->Background(skyColor => $skyColor, groundColor => $groundColor); |
|
296
|
0
|
|
|
|
|
0
|
return $self; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
sub backgroundimage { |
|
300
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
301
|
0
|
|
|
|
|
0
|
my ($url) = @_; |
|
302
|
0
|
0
|
|
|
|
0
|
return unless $url; |
|
303
|
0
|
|
|
|
|
0
|
$self->Background( |
|
304
|
|
|
|
|
|
|
frontUrl => "\"$url\"", |
|
305
|
|
|
|
|
|
|
leftUrl => "\"$url\"", |
|
306
|
|
|
|
|
|
|
rightUrl => "\"$url\"", |
|
307
|
|
|
|
|
|
|
backUrl => "\"$url\"", |
|
308
|
|
|
|
|
|
|
bottomUrl => "\"$url\"", |
|
309
|
|
|
|
|
|
|
topUrl => "\"$url\"" |
|
310
|
|
|
|
|
|
|
); |
|
311
|
0
|
|
|
|
|
0
|
return $self; |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub title { |
|
315
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
316
|
0
|
|
|
|
|
0
|
my $title = shift; |
|
317
|
0
|
0
|
|
|
|
0
|
return unless defined $title; |
|
318
|
0
|
0
|
|
|
|
0
|
my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'"; |
|
319
|
0
|
|
|
|
|
0
|
$title =~ s/"/$quote/g; |
|
320
|
0
|
|
|
|
|
0
|
$self->WorldInfo($title); |
|
321
|
0
|
|
|
|
|
0
|
return $self; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub info { |
|
325
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
326
|
0
|
|
|
|
|
0
|
my ($info) = @_; |
|
327
|
0
|
0
|
|
|
|
0
|
my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'"; |
|
328
|
0
|
0
|
|
|
|
0
|
if (defined $info) { |
|
329
|
0
|
|
|
|
|
0
|
$info =~ s/"/$quote/g; |
|
330
|
0
|
|
|
|
|
0
|
$self->WorldInfo(undef, $info); |
|
331
|
|
|
|
|
|
|
} |
|
332
|
0
|
|
|
|
|
0
|
return $self; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub worldinfo { |
|
336
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
337
|
0
|
|
|
|
|
0
|
my ($title, $info) = @_; |
|
338
|
0
|
0
|
|
|
|
0
|
my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'"; |
|
339
|
0
|
0
|
|
|
|
0
|
$title =~ s/"/$quote/g if defined $title; |
|
340
|
0
|
0
|
|
|
|
0
|
$info =~ s/"/$quote/g if defined $info; |
|
341
|
0
|
|
|
|
|
0
|
$self->WorldInfo($title, $info); |
|
342
|
0
|
|
|
|
|
0
|
return $self; |
|
343
|
|
|
|
|
|
|
} |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
sub navigationinfo { |
|
346
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
347
|
0
|
|
|
|
|
0
|
my ($type, $speed, $headlight, $visibilityLimit, $avatarSize) = @_; |
|
348
|
0
|
0
|
0
|
|
|
0
|
$headlight = defined $headlight && !$headlight ? "FALSE" : "TRUE"; |
|
349
|
0
|
|
|
|
|
0
|
$self->NavigationInfo($type, $speed, $headlight, $visibilityLimit, |
|
350
|
|
|
|
|
|
|
$avatarSize); |
|
351
|
0
|
|
|
|
|
0
|
return $self; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub viewpoint_begin { |
|
356
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
357
|
0
|
|
|
|
|
0
|
my ($whichChild) = @_; |
|
358
|
0
|
0
|
0
|
|
|
0
|
$whichChild = (defined $whichChild && $whichChild > 0) ? $whichChild-1 : 0; |
|
359
|
0
|
|
|
|
|
0
|
$self->{'TAB_VIEW'} = $self->{'TAB'}; |
|
360
|
0
|
|
|
|
|
0
|
$self->{'viewpoint_begin'} = $#{$self->{'VRML'}}+1 unless defined |
|
361
|
0
|
0
|
|
|
|
0
|
$self->{'viewpoint_begin'}; |
|
362
|
0
|
|
|
|
|
0
|
return $self; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
sub viewpoint_end { |
|
366
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
367
|
0
|
|
|
|
|
0
|
splice(@{$self->{'VRML'}}, $self->{'viewpoint_begin'}, 0, |
|
368
|
0
|
|
|
|
|
0
|
@{$self->{'viewpoint'}}); |
|
|
0
|
|
|
|
|
0
|
|
|
369
|
0
|
|
|
|
|
0
|
$self->{'viewpoint'} = []; |
|
370
|
0
|
|
|
|
|
0
|
return $self; |
|
371
|
|
|
|
|
|
|
} |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
sub viewpoint_auto_set { |
|
374
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
375
|
0
|
|
|
|
|
0
|
my $factor = shift; |
|
376
|
0
|
0
|
|
|
|
0
|
$factor = 1 unless defined $factor; |
|
377
|
0
|
0
|
|
|
|
0
|
if (defined $self->{'viewpoint_set'}) { |
|
378
|
0
|
|
|
|
|
0
|
my $x = ($self->{'Xmax'}+$self->{'Xmin'})/2; |
|
379
|
0
|
|
|
|
|
0
|
my $y = ($self->{'Ymax'}+$self->{'Ymin'})/2; |
|
380
|
0
|
|
|
|
|
0
|
my $z = ($self->{'Zmax'}+$self->{'Zmin'})/2; |
|
381
|
0
|
|
|
|
|
0
|
my $dx = abs($self->{'Xmax'}-$x); # todo calculate angle |
|
382
|
0
|
|
|
|
|
0
|
my $dy = abs($self->{'Ymax'}-$y); |
|
383
|
0
|
|
|
|
|
0
|
my $dz = abs($self->{'Zmax'}-$z); |
|
384
|
0
|
|
|
|
|
0
|
my $dist = 0; |
|
385
|
0
|
0
|
|
|
|
0
|
$dist = $dx if $dx > $dist; |
|
386
|
0
|
0
|
|
|
|
0
|
$dist = $dy if $dy > $dist; |
|
387
|
0
|
0
|
|
|
|
0
|
$dist = $dz if $dz > $dist; |
|
388
|
0
|
|
|
|
|
0
|
my $offset = $#{$self->{'viewpoint'}}+1; |
|
|
0
|
|
|
|
|
0
|
|
|
389
|
0
|
|
|
|
|
0
|
$self->viewpoint_set("$x $y $z",$dist*$factor,60); |
|
390
|
0
|
|
|
|
|
0
|
@_ = splice(@{$self->{'viewpoint'}}, $offset); |
|
|
0
|
|
|
|
|
0
|
|
|
391
|
0
|
|
|
|
|
0
|
splice(@{$self->{'viewpoint'}}, $self->{'viewpoint_set'}, $#_+1, @_); |
|
|
0
|
|
|
|
|
0
|
|
|
392
|
|
|
|
|
|
|
} else { |
|
393
|
0
|
|
|
|
|
0
|
$self->viewpoint_set(@_); |
|
394
|
|
|
|
|
|
|
} |
|
395
|
0
|
|
|
|
|
0
|
return $self; |
|
396
|
|
|
|
|
|
|
} |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub viewpoint_set { |
|
399
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
400
|
0
|
|
|
|
|
0
|
my ($center, $distance, $fieldOfView) = @_; |
|
401
|
0
|
|
|
|
|
0
|
$self->{'viewpoint_set'} = $#{$self->{'viewpoint'}}+1 unless defined |
|
402
|
0
|
0
|
|
|
|
0
|
$self->{'viewpoint_set'}; |
|
403
|
0
|
0
|
|
|
|
0
|
my ($x, $y, $z) = $self->string_to_array($center) if defined $center; |
|
404
|
0
|
0
|
|
|
|
0
|
my ($dx, $dy, $dz) = defined $distance ? $self->string_to_array($distance) : (0,0,0); |
|
405
|
0
|
0
|
|
|
|
0
|
$x = 0 unless defined $x; |
|
406
|
0
|
0
|
|
|
|
0
|
$y = 0 unless defined $y; |
|
407
|
0
|
0
|
|
|
|
0
|
$z = 0 unless defined $z; |
|
408
|
0
|
0
|
|
|
|
0
|
$dx = 1 unless defined $dx; |
|
409
|
0
|
0
|
|
|
|
0
|
$dy = $dx unless defined $dy; |
|
410
|
0
|
0
|
|
|
|
0
|
$dz = $dx unless defined $dz; |
|
411
|
0
|
|
|
|
|
0
|
$self->viewpoint("Front", "$x $y ".($z+$dz), "0 0 1 0",$fieldOfView); |
|
412
|
0
|
|
|
|
|
0
|
$self->viewpoint("Right", ($x+$dx)." $y $z", "0 1 0 90",$fieldOfView); |
|
413
|
0
|
|
|
|
|
0
|
$self->viewpoint("Back", "$x $y ".($z-$dz), "0 1 0 180",$fieldOfView); |
|
414
|
0
|
|
|
|
|
0
|
$self->viewpoint("Left", ($x-$dx)." $y $z", "0 1 0 -90",$fieldOfView); |
|
415
|
0
|
|
|
|
|
0
|
$self->viewpoint("Top", "$x ".($y+$dy)." $z", "1 0 0 -90",$fieldOfView); |
|
416
|
0
|
|
|
|
|
0
|
$self->viewpoint("Bottom", "$x ".($y-$dy)." $z", "1 0 0 90",$fieldOfView); |
|
417
|
0
|
|
|
|
|
0
|
return $self; |
|
418
|
|
|
|
|
|
|
} |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
sub viewpoint { |
|
421
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
422
|
0
|
|
|
|
|
0
|
my ($description, $position, $orientation, $fieldOfView, $jump) = @_; |
|
423
|
0
|
0
|
|
|
|
0
|
if (defined $orientation) { |
|
424
|
0
|
0
|
|
|
|
0
|
if ($orientation !~ /\s/) { |
|
425
|
0
|
|
|
|
|
0
|
my %val = ("FRONT" => "0 0 1 0", "BACK" => "0 1 0 3.14", |
|
426
|
|
|
|
|
|
|
"RIGHT" => "0 1 0 1.57", "LEFT" => "0 1 0 -1.57", |
|
427
|
|
|
|
|
|
|
"TOP" => "1 0 0 -1.57", "BOTTOM" => "1 0 0 1.57"); |
|
428
|
0
|
|
|
|
|
0
|
my $string = uc($orientation); |
|
429
|
0
|
|
|
|
|
0
|
undef $orientation; |
|
430
|
0
|
|
|
|
|
0
|
$orientation = $val{$string}; |
|
431
|
0
|
0
|
0
|
|
|
0
|
$orientation .= " # $string" if $orientation && $self->{'DEBUG'}; |
|
432
|
|
|
|
|
|
|
} else { |
|
433
|
0
|
|
|
|
|
0
|
my ($x,$y,$z,$angle) = $self->string_to_array($orientation); |
|
434
|
0
|
0
|
|
|
|
0
|
if (defined $angle) { |
|
435
|
0
|
0
|
|
|
|
0
|
$angle *= $PI/180 if $self->{'CONVERT'}; |
|
436
|
0
|
|
|
|
|
0
|
$orientation = "$x $y $z $angle"; |
|
437
|
|
|
|
|
|
|
} |
|
438
|
|
|
|
|
|
|
} |
|
439
|
|
|
|
|
|
|
} |
|
440
|
0
|
0
|
0
|
|
|
0
|
$fieldOfView *= $PI/180 if defined $fieldOfView && $self->{'CONVERT'}; |
|
441
|
0
|
0
|
|
|
|
0
|
if (defined $jump) { $jump = $jump ? "TRUE" : "FALSE"; } |
|
|
0
|
0
|
|
|
|
0
|
|
|
442
|
0
|
0
|
|
|
|
0
|
$self->{'TAB_VIEW'} = $self->{'TAB'} unless $self->{'TAB_VIEW'}; |
|
443
|
0
|
0
|
|
|
|
0
|
if ($description =~ /^#/) { |
|
444
|
0
|
|
|
|
|
0
|
$description =~ s/^#//; |
|
445
|
0
|
|
|
|
|
0
|
my ($name) = $description; |
|
446
|
0
|
|
|
|
|
0
|
$name =~ s/[\x00-\x20\x22\x23\x27\x2b-\x2e\x30-\x39\x5b-\x5d\x7b\x7d\x7f]/_/g; |
|
447
|
0
|
|
|
|
|
0
|
push @{$self->{'viewpoint'}}, $self->{'TAB_VIEW'}."DEF $name\n"; |
|
|
0
|
|
|
|
|
0
|
|
|
448
|
|
|
|
|
|
|
} |
|
449
|
0
|
|
|
|
|
0
|
$self->Viewpoint($description, $position, $orientation, $fieldOfView, |
|
450
|
|
|
|
|
|
|
$jump); |
|
451
|
0
|
|
|
|
|
0
|
push @{$self->{'viewpoint'}}, pop @{$self->{'VRML'}}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
452
|
0
|
0
|
|
|
|
0
|
unless (defined $self->{'viewpoint_begin'}) { |
|
453
|
0
|
|
|
|
|
0
|
splice(@{$self->{'VRML'}}, @{$self->{'VRML'}}, 0, |
|
|
0
|
|
|
|
|
0
|
|
|
454
|
0
|
|
|
|
|
0
|
@{$self->{'viewpoint'}}); |
|
|
0
|
|
|
|
|
0
|
|
|
455
|
0
|
|
|
|
|
0
|
$self->{'viewpoint'} = []; |
|
456
|
|
|
|
|
|
|
} |
|
457
|
0
|
|
|
|
|
0
|
return $self; |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub directionallight { |
|
463
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
464
|
0
|
|
|
|
|
0
|
my ($direction, $intensity, $ambientIntensity, $color, $on) = @_; |
|
465
|
0
|
0
|
|
|
|
0
|
if (defined $on) { $on = $on ? "TRUE" : "FALSE"; } |
|
|
0
|
0
|
|
|
|
0
|
|
|
466
|
0
|
0
|
|
|
|
0
|
$color = rgb_color($color) if defined $color; |
|
467
|
0
|
|
|
|
|
0
|
$self->DirectionalLight($direction, $intensity, $ambientIntensity, $color, |
|
468
|
|
|
|
|
|
|
$on); |
|
469
|
0
|
|
|
|
|
0
|
return $self; |
|
470
|
|
|
|
|
|
|
} |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
sub line { |
|
475
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
476
|
0
|
|
|
|
|
0
|
my ($from,$to,$radius,$appearance,$order) = @_; |
|
477
|
0
|
|
|
|
|
0
|
my ($x1,$y1,$z1) = $self->string_to_array($from); |
|
478
|
0
|
|
|
|
|
0
|
my ($x2,$y2,$z2) = $self->string_to_array($to); |
|
479
|
0
|
|
|
|
|
0
|
my ($t, $r, $length); |
|
480
|
|
|
|
|
|
|
|
|
481
|
0
|
0
|
|
|
|
0
|
$x1 = 0 unless $x1; |
|
482
|
0
|
0
|
|
|
|
0
|
$x2 = 0 unless $x2; |
|
483
|
0
|
0
|
|
|
|
0
|
$y1 = 0 unless $y1; |
|
484
|
0
|
0
|
|
|
|
0
|
$y2 = 0 unless $y2; |
|
485
|
0
|
0
|
|
|
|
0
|
$z1 = 0 unless $z1; |
|
486
|
0
|
0
|
|
|
|
0
|
$z2 = 0 unless $z2; |
|
487
|
0
|
|
|
|
|
0
|
my $dx=$x1-$x2; |
|
488
|
0
|
|
|
|
|
0
|
my $dy=$y1-$y2; |
|
489
|
0
|
|
|
|
|
0
|
my $dz=$z1-$z2; |
|
490
|
0
|
0
|
|
|
|
0
|
$order = "" unless defined $order; |
|
491
|
0
|
0
|
|
|
|
0
|
$self->comment('line("'.join('", "',@_).'")') if $self->{'DEBUG'}; |
|
492
|
0
|
|
|
|
|
0
|
$self->Group(); |
|
493
|
0
|
0
|
0
|
|
|
0
|
if (defined $radius && $radius>0) { |
|
494
|
0
|
0
|
0
|
|
|
0
|
if ($dx && $order =~ /x/i) { |
|
495
|
0
|
0
|
|
|
|
0
|
$t = ($x1-($dx/2))." $y1 $z1" if $order =~ /^x$/i; |
|
496
|
0
|
0
|
|
|
|
0
|
$t = ($x1-($dx/2))." $y1 $z1" if $order =~ /^x../i; |
|
497
|
0
|
0
|
|
|
|
0
|
$t = ($x1-($dx/2))." $y2 $z1" if $order =~ /yxz/i; |
|
498
|
0
|
0
|
|
|
|
0
|
$t = ($x1-($dx/2))." $y1 $z2" if $order =~ /zxy/i; |
|
499
|
0
|
0
|
|
|
|
0
|
$t = ($x1-($dx/2))." $y2 $z2" if $order =~ /..x$/i; |
|
500
|
0
|
|
|
|
|
0
|
$self->Transform($t,"0 0 1 ". $PI_2); |
|
501
|
0
|
|
|
0
|
|
0
|
$self->Shape(sub{$self->Cylinder($radius,abs($dx))}, |
|
502
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)}); |
|
|
0
|
|
|
|
|
0
|
|
|
503
|
0
|
|
|
|
|
0
|
$self->EndTransform; |
|
504
|
|
|
|
|
|
|
} |
|
505
|
0
|
0
|
0
|
|
|
0
|
if ($dy && $order =~ /y/i) { |
|
506
|
0
|
0
|
|
|
|
0
|
$t = "$x1 ".($y1-($dy/2))." $z1" if $order =~ /^y$/i; |
|
507
|
0
|
0
|
|
|
|
0
|
$t = "$x1 ".($y1-($dy/2))." $z1" if $order =~ /^y../i; |
|
508
|
0
|
0
|
|
|
|
0
|
$t = "$x2 ".($y1-($dy/2))." $z1" if $order =~ /xyz/i; |
|
509
|
0
|
0
|
|
|
|
0
|
$t = "$x1 ".($y1-($dy/2))." $z2" if $order =~ /zyx/i; |
|
510
|
0
|
0
|
|
|
|
0
|
$t = "$x2 ".($y1-($dy/2))." $z2" if $order =~ /..y$/i; |
|
511
|
0
|
|
|
|
|
0
|
$self->Transform($t); |
|
512
|
0
|
|
|
0
|
|
0
|
$self->Shape(sub{$self->Cylinder($radius,abs($dy))}, |
|
513
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)}); |
|
|
0
|
|
|
|
|
0
|
|
|
514
|
0
|
|
|
|
|
0
|
$self->EndTransform; |
|
515
|
|
|
|
|
|
|
} |
|
516
|
0
|
0
|
0
|
|
|
0
|
if ($dz && $order =~ /z/i) { |
|
517
|
0
|
0
|
|
|
|
0
|
$t = "$x1 $y1 ".($z1-($dz/2)) if $order =~ /^z$/i; |
|
518
|
0
|
0
|
|
|
|
0
|
$t = "$x1 $y1 ".($z1-($dz/2)) if $order =~ /^z../i; |
|
519
|
0
|
0
|
|
|
|
0
|
$t = "$x1 $y2 ".($z1-($dz/2)) if $order =~ /yzx/i; |
|
520
|
0
|
0
|
|
|
|
0
|
$t = "$x2 $y1 ".($z1-($dz/2)) if $order =~ /xzy/i; |
|
521
|
0
|
0
|
|
|
|
0
|
$t = "$x2 $y2 ".($z1-($dz/2)) if $order =~ /..z$/i; |
|
522
|
0
|
|
|
|
|
0
|
$self->Transform($t,"1 0 0 ". $PI_2); |
|
523
|
0
|
|
|
0
|
|
0
|
$self->Shape(sub{$self->Cylinder($radius,abs($dz))}, |
|
524
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)}); |
|
|
0
|
|
|
|
|
0
|
|
|
525
|
0
|
|
|
|
|
0
|
$self->EndTransform; |
|
526
|
|
|
|
|
|
|
} |
|
527
|
0
|
0
|
|
|
|
0
|
unless ($order) { |
|
528
|
0
|
|
|
|
|
0
|
$length = sqrt($dx*$dx + $dy*$dy + $dz*$dz); |
|
529
|
0
|
|
|
|
|
0
|
$t = ($x1-($dx/2))." ".($y1-($dy/2))." ".($z1-($dz/2)); |
|
530
|
0
|
|
|
|
|
0
|
$r = "$dx ".($dy+$length)." $dz ".$PI; |
|
531
|
0
|
|
|
|
|
0
|
$self->Transform($t,$r); |
|
532
|
0
|
|
|
0
|
|
0
|
$self->Shape(sub{$self->Cylinder($radius,$length)}, |
|
533
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)}); |
|
|
0
|
|
|
|
|
0
|
|
|
534
|
0
|
|
|
|
|
0
|
$self->EndTransform; |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
} else { |
|
537
|
0
|
|
|
|
|
0
|
my $color = rgb_color($appearance); |
|
538
|
|
|
|
|
|
|
$self->Shape(sub{$self->IndexedLineSet( |
|
539
|
0
|
|
|
|
|
0
|
sub{$self->Coordinate($from,$to)}, |
|
540
|
0
|
|
|
0
|
|
0
|
"0 1","Color { color [ $color ] }",undef,"FALSE")}); |
|
|
0
|
|
|
|
|
0
|
|
|
541
|
|
|
|
|
|
|
} |
|
542
|
0
|
|
|
|
|
0
|
$self->EndChildren->End("line"); |
|
543
|
0
|
|
|
|
|
0
|
return $self; |
|
544
|
|
|
|
|
|
|
} |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
sub box { |
|
549
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
550
|
1
|
|
|
|
|
4
|
my ($dimension, $appearance) = @_; |
|
551
|
1
|
|
|
|
|
10
|
my ($width,$height,$depth) = $self->string_to_array($dimension); |
|
552
|
|
|
|
|
|
|
$self->Shape( |
|
553
|
1
|
|
|
1
|
|
11
|
sub{$self->Box("$width $height $depth")}, |
|
554
|
1
|
|
|
1
|
|
13
|
sub{$self->appearance($appearance)} |
|
555
|
1
|
|
|
|
|
18
|
); |
|
556
|
1
|
|
|
|
|
14
|
return $self; |
|
557
|
|
|
|
|
|
|
} |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
sub cone { |
|
560
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
561
|
1
|
|
|
|
|
3
|
my ($dimension, $appearance) = @_; |
|
562
|
1
|
|
|
|
|
5
|
my ($radius, $height) = $self->string_to_array($dimension); |
|
563
|
|
|
|
|
|
|
$self->Shape( |
|
564
|
1
|
|
|
1
|
|
9
|
sub{$self->Cone($radius, $height)}, |
|
565
|
1
|
|
|
1
|
|
4
|
sub{$self->appearance($appearance)} |
|
566
|
1
|
|
|
|
|
13
|
); |
|
567
|
1
|
|
|
|
|
10
|
return $self; |
|
568
|
|
|
|
|
|
|
} |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
sub cube { |
|
571
|
1
|
|
|
1
|
0
|
1
|
my $self = shift; |
|
572
|
1
|
|
|
|
|
3
|
my ($dimension, $appearance) = @_; |
|
573
|
1
|
|
|
|
|
5
|
my ($width,$height,$depth) = $self->string_to_array($dimension); |
|
574
|
1
|
50
|
|
|
|
5
|
$height = $width unless defined $height; |
|
575
|
1
|
50
|
|
|
|
5
|
$depth = $width unless defined $depth; |
|
576
|
|
|
|
|
|
|
$self->Shape( |
|
577
|
1
|
|
|
1
|
|
8
|
sub{$self->Box("$width $height $depth")}, |
|
578
|
1
|
|
|
1
|
|
4
|
sub{$self->appearance($appearance)} |
|
579
|
1
|
|
|
|
|
12
|
); |
|
580
|
1
|
|
|
|
|
9
|
return $self; |
|
581
|
|
|
|
|
|
|
} |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
sub cylinder { |
|
584
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
|
585
|
1
|
|
|
|
|
3
|
my ($dimension, $appearance, $top, $side, $bottom, $inside) = @_; |
|
586
|
1
|
|
|
|
|
5
|
my ($radius, $height) = $self->string_to_array($dimension); |
|
587
|
1
|
0
|
|
|
|
4
|
$top = $top ? "TRUE" : "FALSE" if defined $top; |
|
|
|
50
|
|
|
|
|
|
|
588
|
1
|
0
|
|
|
|
3
|
$side = $side ? "TRUE" : "FALSE" if defined $side; |
|
|
|
50
|
|
|
|
|
|
|
589
|
1
|
0
|
|
|
|
14
|
$bottom = $bottom ? "TRUE" : "FALSE" if defined $bottom; |
|
|
|
50
|
|
|
|
|
|
|
590
|
1
|
50
|
33
|
|
|
6
|
if (defined $inside && $inside) { |
|
591
|
0
|
|
|
|
|
0
|
my $crossSection = "1.00 0.00, 0.92 0.38, 0.71 0.71, 0.38 0.92, 0.00 1.00, -0.38 0.92, -0.71 0.71, -0.92 0.38, -1.00 0.0, -0.92 -0.38, -0.71 -0.71, -0.38 -0.92, 0.00 -1.00, 0.38 -0.92, 0.71 -0.71, 0.92 -0.38, 1.00 0.00"; |
|
592
|
0
|
|
|
|
|
0
|
$height /= 2; |
|
593
|
|
|
|
|
|
|
$self->Shape( |
|
594
|
0
|
|
|
0
|
|
0
|
sub{$self->Extrusion([$crossSection], ["0 -$height 0", "0 $height 0"], ["$radius $radius", "$radius $radius"], undef, $top, $bottom, 0.5, "FALSE")}, |
|
595
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)} |
|
596
|
|
|
|
|
|
|
) |
|
597
|
0
|
|
|
|
|
0
|
} else { |
|
598
|
|
|
|
|
|
|
$self->Shape( |
|
599
|
1
|
|
|
1
|
|
10
|
sub{$self->Cylinder($radius, $height, $top, $side, $bottom)}, |
|
600
|
1
|
|
|
1
|
|
5
|
sub{$self->appearance($appearance)} |
|
601
|
|
|
|
|
|
|
) |
|
602
|
1
|
|
|
|
|
13
|
} |
|
603
|
1
|
|
|
|
|
10
|
return $self; |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
sub elevationgrid { |
|
607
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
608
|
0
|
|
|
|
|
0
|
my ($height, $color, $xDimension, $zDimension, $xSpacing, $zSpacing, |
|
609
|
|
|
|
|
|
|
$creaseAngle, $colorPerVertex, $solid) = @_; |
|
610
|
0
|
0
|
|
|
|
0
|
$xDimension = ($$height[0] =~ s/([+-]?\d+\.?\d*)/$1/g) unless defined $xDimension; |
|
611
|
0
|
0
|
|
|
|
0
|
$zDimension = @$height unless defined $zDimension; |
|
612
|
0
|
0
|
|
|
|
0
|
$xSpacing = 1 unless defined $xSpacing; |
|
613
|
0
|
0
|
|
|
|
0
|
$zSpacing = $xSpacing unless defined $zSpacing; |
|
614
|
0
|
0
|
0
|
|
|
0
|
$creaseAngle *= $PI/180 if defined $creaseAngle && $self->{'CONVERT'}; |
|
615
|
0
|
0
|
|
|
|
0
|
$colorPerVertex = $colorPerVertex ? "TRUE" : "FALSE" if defined $colorPerVertex; |
|
|
|
0
|
|
|
|
|
|
|
616
|
0
|
0
|
|
|
|
0
|
$solid = $solid ? "TRUE" : "FALSE" if defined $solid; |
|
|
|
0
|
|
|
|
|
|
|
617
|
0
|
0
|
|
|
|
0
|
if (ref($color) eq "ARRAY") { |
|
618
|
|
|
|
|
|
|
$self->Shape( |
|
619
|
0
|
|
|
0
|
|
0
|
sub{$self->ElevationGrid($xDimension, $zDimension, $xSpacing, $zSpacing, |
|
620
|
|
|
|
|
|
|
$height, $creaseAngle, $color, $colorPerVertex, $solid)} |
|
621
|
|
|
|
|
|
|
) |
|
622
|
0
|
|
|
|
|
0
|
} else { |
|
623
|
|
|
|
|
|
|
$self->Shape( |
|
624
|
0
|
|
|
0
|
|
0
|
sub{$self->ElevationGrid($xDimension, $zDimension, $xSpacing, $zSpacing, |
|
625
|
|
|
|
|
|
|
$height, $creaseAngle, undef, $colorPerVertex, $solid)}, |
|
626
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($color)} |
|
627
|
|
|
|
|
|
|
) |
|
628
|
0
|
|
|
|
|
0
|
} |
|
629
|
0
|
|
|
|
|
0
|
return $self; |
|
630
|
|
|
|
|
|
|
} |
|
631
|
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
sub indexedfaceset { |
|
633
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
634
|
0
|
|
|
|
|
0
|
my ($coord, $coordIndex, $appearance, $color, $colorIndex) = @_; |
|
635
|
0
|
0
|
|
|
|
0
|
$colorIndex = [0..$#{@$color}] unless defined $colorIndex; |
|
|
0
|
|
|
|
|
0
|
|
|
636
|
0
|
|
|
|
|
0
|
my @color = split(",",$appearance); |
|
637
|
|
|
|
|
|
|
$self->Shape( |
|
638
|
|
|
|
|
|
|
sub{$self->IndexedFaceSet( |
|
639
|
0
|
|
|
|
|
0
|
sub{$self->Coordinate($coord)}, $coordIndex, |
|
640
|
0
|
|
|
0
|
|
0
|
sub{$self->color(@color)}, $colorIndex, "FALSE") |
|
|
0
|
|
|
|
|
0
|
|
|
641
|
|
|
|
|
|
|
}, |
|
642
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)} |
|
643
|
0
|
|
|
|
|
0
|
); |
|
644
|
0
|
|
|
|
|
0
|
return $self; |
|
645
|
|
|
|
|
|
|
} |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
sub pointset { |
|
648
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
649
|
0
|
|
|
|
|
0
|
my ($coord, $color) = @_; |
|
650
|
|
|
|
|
|
|
$self->Shape( |
|
651
|
|
|
|
|
|
|
sub{$self->PointSet( |
|
652
|
0
|
|
|
|
|
0
|
sub{$self->Coordinate(@$coord)}, |
|
653
|
0
|
|
|
|
|
0
|
sub{$self->color(@$color)}) |
|
654
|
0
|
|
|
0
|
|
0
|
} |
|
655
|
0
|
|
|
|
|
0
|
); |
|
656
|
0
|
|
|
|
|
0
|
return $self; |
|
657
|
|
|
|
|
|
|
} |
|
658
|
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
sub pyramid { |
|
660
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
661
|
0
|
|
|
|
|
0
|
my ($dimension, $appearance) = @_; |
|
662
|
0
|
|
|
|
|
0
|
my ($width,$height,$depth) = $self->string_to_array($dimension); |
|
663
|
0
|
0
|
|
|
|
0
|
my $x_2 = $width ? $width/2 : 1; |
|
664
|
0
|
0
|
|
|
|
0
|
my $y_2 = $height ? $height/2 : 1; |
|
665
|
0
|
0
|
|
|
|
0
|
my $z_2 = defined $depth ? $depth/2 : $x_2; |
|
666
|
0
|
0
|
|
|
|
0
|
my @color = split(",",$appearance) if $appearance; |
|
667
|
0
|
|
|
|
|
0
|
my @color_prop = (); |
|
668
|
0
|
0
|
|
0
|
|
0
|
@color_prop = (sub{$self->color(@color)},[0..4],"FALSE") if $#color > 0; |
|
|
0
|
|
|
|
|
0
|
|
|
669
|
|
|
|
|
|
|
$self->Shape( |
|
670
|
|
|
|
|
|
|
sub{$self->IndexedFaceSet( |
|
671
|
0
|
|
|
|
|
0
|
sub{$self->Coordinate("-$x_2 -$y_2 $z_2", "$x_2 -$y_2 $z_2", |
|
672
|
|
|
|
|
|
|
"$x_2 -$y_2 -$z_2", "-$x_2 -$y_2 -$z_2", "0 $y_2 0")}, |
|
673
|
0
|
|
|
0
|
|
0
|
["0, 1, 4","1, 2, 4","2, 3, 4","3, 0, 4","0, 3, 2, 1"], |
|
674
|
|
|
|
|
|
|
@color_prop) |
|
675
|
0
|
|
|
0
|
|
0
|
},sub{$self->appearance($appearance)} |
|
676
|
0
|
|
|
|
|
0
|
); |
|
677
|
0
|
|
|
|
|
0
|
return $self; |
|
678
|
|
|
|
|
|
|
} |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
sub sphere { |
|
681
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
682
|
1
|
|
|
|
|
3
|
my ($radius, $appearance) = @_; |
|
683
|
|
|
|
|
|
|
$self->Shape( |
|
684
|
1
|
|
|
1
|
|
9
|
sub{$self->Sphere($radius)}, |
|
685
|
1
|
|
|
1
|
|
5
|
sub{$self->appearance($appearance)} |
|
686
|
1
|
|
|
|
|
11
|
); |
|
687
|
1
|
|
|
|
|
9
|
return $self; |
|
688
|
|
|
|
|
|
|
} |
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
sub torus { |
|
691
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
692
|
0
|
|
|
|
|
0
|
my ($dimension, $appearance, $beginCap, $endCap, $angle) = @_; |
|
693
|
0
|
|
|
|
|
0
|
my ($r1, $r2, $from, $to, $dstep) = $self->string_to_array($dimension); |
|
694
|
0
|
|
|
|
|
0
|
$self->comment("torus($r1, $r2, $from, $to, $dstep)"); |
|
695
|
0
|
|
0
|
|
|
0
|
$r2 ||= 0.5; |
|
696
|
0
|
|
0
|
|
|
0
|
$from ||= 0; |
|
697
|
0
|
0
|
|
|
|
0
|
$from *= $PI/180 if $self->{'CONVERT'}; |
|
698
|
0
|
|
0
|
|
|
0
|
$to ||= 0; |
|
699
|
0
|
0
|
|
|
|
0
|
$to *= $PI/180 if $self->{'CONVERT'}; |
|
700
|
0
|
|
0
|
|
|
0
|
$dstep ||= 10; |
|
701
|
0
|
0
|
|
|
|
0
|
$dstep *= $PI/180 if $self->{'CONVERT'}; |
|
702
|
0
|
0
|
|
|
|
0
|
$beginCap = $beginCap ? "TRUE" : "FALSE" if defined $beginCap; |
|
|
|
0
|
|
|
|
|
|
|
703
|
0
|
0
|
|
|
|
0
|
$endCap = $endCap ? "TRUE" : "FALSE" if defined $endCap; |
|
|
|
0
|
|
|
|
|
|
|
704
|
0
|
|
|
|
|
0
|
my $crossSection = "1.00 0.00, 0.92 0.38, 0.71 0.71, 0.38 0.92, 0.00 1.00, -0.38 0.92, -0.71 0.71, -0.92 0.38, -1.00 0.0, -0.92 -0.38, -0.71 -0.71, -0.38 -0.92, 0.00 -1.00, 0.38 -0.92, 0.71 -0.71, 0.92 -0.38, 1.00 0.00"; |
|
705
|
0
|
|
|
|
|
0
|
my $alpha = $from; |
|
706
|
0
|
|
|
|
|
0
|
my @spine = (); |
|
707
|
0
|
|
|
|
|
0
|
my @scale = (); |
|
708
|
0
|
|
|
|
|
0
|
for (my $i=0; $i<360; $i++) { |
|
709
|
|
|
|
|
|
|
#radius1 + radius2*Math.cos(alpha)) * Math.cos(beta) |
|
710
|
0
|
|
|
|
|
0
|
push @spine, sprintf("%.2f",$r1*cos($alpha))." 0 ".sprintf("%.2f",$r1*sin($alpha)); |
|
711
|
0
|
|
|
|
|
0
|
push @scale, "$r2 $r2"; |
|
712
|
0
|
|
|
|
|
0
|
$alpha += $dstep; |
|
713
|
0
|
0
|
|
|
|
0
|
last if $alpha>$to; |
|
714
|
|
|
|
|
|
|
} |
|
715
|
0
|
0
|
|
|
|
0
|
if ($from == $to) { |
|
716
|
0
|
|
|
|
|
0
|
push @spine, $spine[0]; |
|
717
|
|
|
|
|
|
|
} else { |
|
718
|
0
|
|
|
|
|
0
|
push @spine, sprintf("%.2f",$r1*cos($to))." 0 ".sprintf("%.2f",$r1*sin($to)); |
|
719
|
0
|
|
|
|
|
0
|
push @scale, "$r2 $r2"; |
|
720
|
|
|
|
|
|
|
} |
|
721
|
|
|
|
|
|
|
#push @scale, "$r2 $r2"; |
|
722
|
|
|
|
|
|
|
$self->Shape( |
|
723
|
0
|
|
|
0
|
|
0
|
sub{$self->Extrusion([$crossSection], [@spine], [@scale], undef, $beginCap, $endCap, 0.5, "FALSE")}, |
|
724
|
0
|
|
|
0
|
|
0
|
sub{$self->appearance($appearance)} |
|
725
|
0
|
|
|
|
|
0
|
); |
|
726
|
0
|
|
|
|
|
0
|
return $self; |
|
727
|
|
|
|
|
|
|
} |
|
728
|
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
sub text { |
|
730
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
|
731
|
1
|
|
|
|
|
3
|
my ($string, $appearance, $font, $align) = @_; |
|
732
|
1
|
|
|
|
|
2
|
my ($size, $family, $style, $language); |
|
733
|
1
|
50
|
|
|
|
120
|
my $quote = $self->{'BROWSER'} =~ /$supported{'quote'}/i ? '\\"' : "'"; |
|
734
|
1
|
50
|
|
|
|
5
|
if (defined $string) { |
|
735
|
1
|
50
|
|
|
|
3
|
if (ref($string)) { |
|
736
|
0
|
|
|
|
|
0
|
map { s/"/$quote/g } @$string; |
|
|
0
|
|
|
|
|
0
|
|
|
737
|
0
|
|
|
|
|
0
|
$string = '["'.join('","',@$string).'"]'; |
|
738
|
|
|
|
|
|
|
} else { |
|
739
|
1
|
|
|
|
|
4
|
$string =~ s/"/$quote/g; |
|
740
|
1
|
|
|
|
|
7
|
$string = "\"$string\""; |
|
741
|
|
|
|
|
|
|
} |
|
742
|
|
|
|
|
|
|
} |
|
743
|
|
|
|
|
|
|
$self->Shape(sub{ |
|
744
|
1
|
50
|
33
|
1
|
|
12
|
if (defined $font || defined $align) { |
|
745
|
1
|
50
|
|
|
|
4
|
if (defined $font) { |
|
746
|
1
|
|
|
|
|
7
|
($size, $family, $style, $language) = split(/\s+/,$font,4); # local variable !!! |
|
747
|
|
|
|
|
|
|
} |
|
748
|
1
|
50
|
|
|
|
4
|
if (defined $align) { |
|
749
|
0
|
|
|
|
|
0
|
$align =~ s/LEFT/BEGIN/i; |
|
750
|
0
|
|
|
|
|
0
|
$align =~ s/CENTER/MIDDLE/i; |
|
751
|
0
|
|
|
|
|
0
|
$align =~ s/RIGHT/END/i; |
|
752
|
|
|
|
|
|
|
} |
|
753
|
1
|
|
|
|
|
9
|
$self->Text($string,sub{$self->FontStyle($size, $family, $style, |
|
754
|
1
|
|
|
|
|
12
|
$align, $language)}); |
|
755
|
|
|
|
|
|
|
} else { |
|
756
|
0
|
|
|
|
|
0
|
$self->Text($string); |
|
757
|
1
|
|
|
1
|
|
4
|
}},sub{$self->appearance($appearance)} |
|
758
|
1
|
|
|
|
|
14
|
); |
|
759
|
1
|
|
|
|
|
13
|
return $self; |
|
760
|
|
|
|
|
|
|
} |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
sub billtext { |
|
763
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
764
|
0
|
|
|
|
|
0
|
my @param = @_; |
|
765
|
0
|
|
|
0
|
|
0
|
$self->Billboard("0 0 0",sub{$self->text(@param)}); # don't use @_ |
|
|
0
|
|
|
|
|
0
|
|
|
766
|
|
|
|
|
|
|
} |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
769
|
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
sub color { |
|
771
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
772
|
0
|
|
|
|
|
0
|
my ($rgb, $comment, @colors); |
|
773
|
0
|
|
|
|
|
0
|
for (@_) { |
|
774
|
0
|
|
|
|
|
0
|
($rgb, $comment) = rgb_color($_); |
|
775
|
0
|
|
|
|
|
0
|
push(@colors, $rgb); |
|
776
|
|
|
|
|
|
|
} |
|
777
|
0
|
|
|
|
|
0
|
$self->Color(@colors); |
|
778
|
0
|
|
|
|
|
0
|
return $self; |
|
779
|
|
|
|
|
|
|
} |
|
780
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
781
|
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
sub appearance { |
|
783
|
6
|
|
|
6
|
0
|
7
|
my $self = shift; |
|
784
|
6
|
|
|
|
|
11
|
my ($appearance_list) = @_; |
|
785
|
6
|
50
|
|
|
|
17
|
return $self->_put("Appearance {}\n") unless $appearance_list; |
|
786
|
6
|
|
|
|
|
7
|
my ($item, $color, $multi_color, $key, $value, @values, $num_color, |
|
787
|
|
|
|
|
|
|
%material, $def, $defmat, $deftex, $textureTransform); |
|
788
|
6
|
|
|
|
|
7
|
my $texture = ""; |
|
789
|
|
|
|
|
|
|
ITEM: |
|
790
|
6
|
|
|
|
|
21
|
foreach $item (split(/\s*;\s*/,$appearance_list)) { |
|
791
|
6
|
50
|
|
|
|
17
|
($key,$value) = ref($item) ? @$item : split(/\s*=\s*/,$item,2); |
|
792
|
|
|
|
|
|
|
# ($key,$value) = split(/\s*=\s*/,$item,2); |
|
793
|
6
|
50
|
|
|
|
14
|
unless ($value) { # color only |
|
794
|
6
|
|
|
|
|
6
|
$value = $key; |
|
795
|
6
|
|
|
|
|
8
|
$key = "diffuseColor"; |
|
796
|
|
|
|
|
|
|
} |
|
797
|
|
|
|
|
|
|
MODE: { |
|
798
|
6
|
50
|
|
|
|
7
|
if ($key eq "d") { $key = "diffuseColor"; last MODE; } |
|
|
6
|
|
|
|
|
14
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
799
|
6
|
50
|
|
|
|
12
|
if ($key eq "e") { $key = "emissiveColor"; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
800
|
6
|
50
|
|
|
|
14
|
if ($key eq "s") { $key = "specularColor"; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
801
|
6
|
50
|
|
|
|
10
|
if ($key eq "ai") { $key = "ambientIntensity"; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
802
|
6
|
50
|
|
|
|
11
|
if ($key eq "sh") { $key = "shininess"; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
803
|
6
|
50
|
|
|
|
13
|
if ($key eq "tr") { $key = "transparency"; last MODE; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
804
|
6
|
50
|
|
|
|
12
|
if ($key eq "tex") { $texture = $value; next ITEM; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
805
|
6
|
50
|
|
|
|
13
|
if ($key eq "textrans") { $textureTransform = $value; next ITEM; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
806
|
6
|
50
|
|
|
|
13
|
if ($key eq "def") { $def = $value; next ITEM; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
807
|
6
|
50
|
|
|
|
12
|
if ($key eq "deftex") { $deftex = $value; next ITEM; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
808
|
6
|
50
|
|
|
|
13
|
if ($key eq "defmat") { $defmat = $value; next ITEM; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
809
|
6
|
50
|
|
|
|
17
|
if ($key eq "use") { |
|
810
|
0
|
|
|
|
|
0
|
$self->use($value); |
|
811
|
0
|
|
|
|
|
0
|
return $self; |
|
812
|
|
|
|
|
|
|
} |
|
813
|
|
|
|
|
|
|
} |
|
814
|
6
|
50
|
|
|
|
16
|
if ($key eq "diffuseColor" | $key eq "emissiveColor" | $key eq |
|
815
|
|
|
|
|
|
|
"specularColor") { |
|
816
|
6
|
50
|
|
|
|
14
|
if ($value =~ /,/) { # multi color field |
|
817
|
0
|
|
|
|
|
0
|
foreach $color (split(/\s*,\s*/,$value)) { |
|
818
|
0
|
|
|
|
|
0
|
($num_color,$color) = rgb_color($color); |
|
819
|
0
|
|
|
|
|
0
|
$value = $num_color; |
|
820
|
0
|
0
|
0
|
|
|
0
|
$value .= " # $color" if $color && $self->{'DEBUG'}; |
|
821
|
0
|
|
|
|
|
0
|
push @values, $value; |
|
822
|
|
|
|
|
|
|
} |
|
823
|
0
|
|
|
|
|
0
|
$material{$key} = $values[0]; # ignore foll. colors |
|
824
|
0
|
|
|
|
|
0
|
$multi_color = 1; |
|
825
|
|
|
|
|
|
|
} else { |
|
826
|
6
|
|
|
|
|
19
|
($num_color,$color) = rgb_color($value); |
|
827
|
6
|
|
|
|
|
8
|
$value = $num_color; |
|
828
|
6
|
50
|
33
|
|
|
27
|
$value .= " # $color" if $color && $self->{'DEBUG'}; |
|
829
|
6
|
|
|
|
|
19
|
$material{$key} = $value; |
|
830
|
|
|
|
|
|
|
} |
|
831
|
|
|
|
|
|
|
} else { |
|
832
|
0
|
|
|
|
|
0
|
$material{$key} = $value; |
|
833
|
|
|
|
|
|
|
} |
|
834
|
|
|
|
|
|
|
} |
|
835
|
6
|
50
|
|
|
|
13
|
$self->def($def) if $def; |
|
836
|
|
|
|
|
|
|
$self->Appearance( |
|
837
|
6
|
50
|
|
6
|
|
42
|
%material ? sub{$self->def($defmat) if $defmat; $self->Material(%material)} : undef, |
|
|
6
|
|
|
|
|
39
|
|
|
838
|
0
|
0
|
|
0
|
|
0
|
$texture =~ /\.gif|\.jpg|\.png|\.bmp/i ? sub{$self->def($deftex) if $deftex; $self->ImageTexture($self->string_to_array($texture))} : undef || |
|
|
0
|
|
|
|
|
0
|
|
|
839
|
0
|
0
|
|
0
|
|
0
|
$texture =~ /\.avi|\.mpg|\.mov/i ? sub{$self->def($deftex) if $deftex; |
|
840
|
0
|
|
|
|
|
0
|
$self->MovieTexture($self->string_to_array($texture))} : undef, |
|
841
|
6
|
50
|
33
|
|
|
109
|
$textureTransform |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
); |
|
843
|
6
|
|
|
|
|
35
|
return $self; |
|
844
|
|
|
|
|
|
|
} |
|
845
|
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
847
|
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
sub sound { |
|
849
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
850
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->sound("url", "description", ...)\n}) |
|
851
|
|
|
|
|
|
|
unless @_; |
|
852
|
0
|
|
|
|
|
|
my ($url, $description, $location, $direction, $intensity, $loop, $pitch) = |
|
853
|
|
|
|
|
|
|
@_; |
|
854
|
0
|
0
|
0
|
|
|
|
$loop = defined $loop && $loop ? "TRUE" : "FALSE"; |
|
855
|
0
|
|
|
0
|
|
|
$self->Sound(sub{$self->DEF($description)->AudioClip($url, $description, |
|
856
|
0
|
|
|
|
|
|
$loop, $pitch)->_trim}, $location, $direction, $intensity, 100 ); |
|
857
|
0
|
|
|
|
|
|
return $self; |
|
858
|
|
|
|
|
|
|
} |
|
859
|
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
861
|
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
sub cylindersensor { |
|
863
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
864
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->cylindersensor("name")\n}) unless @_; |
|
865
|
0
|
|
|
|
|
|
my ($name) = shift; |
|
866
|
0
|
|
|
|
|
|
$self->def($name)->CylinderSensor(@_)->_trim; |
|
867
|
0
|
|
|
|
|
|
return $self; |
|
868
|
|
|
|
|
|
|
} |
|
869
|
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
sub planesensor { |
|
871
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
872
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->planesensor("name")\n}) unless @_; |
|
873
|
0
|
|
|
|
|
|
my $name = shift; |
|
874
|
0
|
|
|
|
|
|
$self->def($name)->PlaneSensor(@_)->_trim; |
|
875
|
0
|
|
|
|
|
|
return $self; |
|
876
|
|
|
|
|
|
|
} |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
sub proximitysensor { |
|
879
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
880
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->proximitysensor("name")\n}) unless @_; |
|
881
|
0
|
|
|
|
|
|
my $name = shift; |
|
882
|
0
|
|
|
|
|
|
$self->def($name)->ProximitySensor(@_)->_trim; |
|
883
|
0
|
|
|
|
|
|
return $self; |
|
884
|
|
|
|
|
|
|
} |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
sub spheresensor { |
|
887
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
888
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->spheresensor("name")\n}) unless @_; |
|
889
|
0
|
|
|
|
|
|
my $name = shift; |
|
890
|
0
|
|
|
|
|
|
$self->def($name)->SphereSensor(@_)->_trim; |
|
891
|
0
|
|
|
|
|
|
return $self; |
|
892
|
|
|
|
|
|
|
} |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
sub timesensor { |
|
895
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
896
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->timesensor("name")\n}) unless @_; |
|
897
|
0
|
|
|
|
|
|
my $name = shift; |
|
898
|
0
|
|
|
|
|
|
$self->def($name)->TimeSensor(@_)->_trim; |
|
899
|
0
|
|
|
|
|
|
return $self; |
|
900
|
|
|
|
|
|
|
} |
|
901
|
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
sub touchsensor { |
|
903
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
904
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->touchsensor("name")\n}) unless @_; |
|
905
|
0
|
|
|
|
|
|
my $name = shift; |
|
906
|
0
|
|
|
|
|
|
$self->def($name)->TouchSensor(@_)->_trim; |
|
907
|
0
|
|
|
|
|
|
return $self; |
|
908
|
|
|
|
|
|
|
} |
|
909
|
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
sub visibitysensor { |
|
911
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
912
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->visibitysensor("name")\n}) unless @_; |
|
913
|
0
|
|
|
|
|
|
my $name = shift; |
|
914
|
0
|
|
|
|
|
|
$self->def($name)->VisibilitySensor(@_)->_trim; |
|
915
|
0
|
|
|
|
|
|
return $self; |
|
916
|
|
|
|
|
|
|
} |
|
917
|
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
919
|
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
sub interpolator { |
|
921
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
922
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->interpolator("name","type", |
|
923
|
|
|
|
|
|
|
[keys],[keyValues])\n}) unless @_; |
|
924
|
0
|
|
|
|
|
|
my $name = shift; |
|
925
|
0
|
|
|
|
|
|
my $type = shift; |
|
926
|
0
|
|
|
|
|
|
$type .= "Interpolator"; |
|
927
|
0
|
|
|
|
|
|
$self->def($name)->$type(@_)->_trim; |
|
928
|
0
|
|
|
|
|
|
return $self; |
|
929
|
|
|
|
|
|
|
} |
|
930
|
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
932
|
|
|
|
|
|
|
# other |
|
933
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
934
|
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
sub route { |
|
936
|
|
|
|
|
|
|
# ROUTEs must be outside of nodes |
|
937
|
|
|
|
|
|
|
# collect them |
|
938
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
939
|
0
|
0
|
|
|
|
|
if ($self->{'TAB'}) { |
|
940
|
0
|
|
|
|
|
|
push @{$self->{'route'}}, [$_[0],$_[1]]; |
|
|
0
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
} else { |
|
942
|
0
|
|
|
|
|
|
$self->ROUTE($_[0],$_[1]); |
|
943
|
|
|
|
|
|
|
} |
|
944
|
0
|
|
|
|
|
|
return $self; |
|
945
|
|
|
|
|
|
|
} |
|
946
|
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
sub def { |
|
948
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
949
|
0
|
|
|
|
|
|
my ($name, $code) = @_; |
|
950
|
0
|
0
|
|
|
|
|
$name = "DEF_".(++$self->{'ID'}) unless defined $name; |
|
951
|
0
|
|
|
|
|
|
$self->DEF($name); |
|
952
|
0
|
0
|
|
|
|
|
if (defined $code) { |
|
953
|
0
|
0
|
|
|
|
|
if (ref($code) eq "CODE") { |
|
954
|
0
|
|
|
|
|
|
$self->{'TAB'} .= "\t"; |
|
955
|
0
|
|
|
|
|
|
my $pos = $#{$self->{'VRML'}}+1; |
|
|
0
|
|
|
|
|
|
|
|
956
|
0
|
|
|
|
|
|
&$code; |
|
957
|
0
|
|
|
|
|
|
$self->_trim($pos); |
|
958
|
0
|
|
|
|
|
|
chop($self->{'TAB'}); |
|
959
|
|
|
|
|
|
|
} else { |
|
960
|
0
|
|
|
|
|
|
$self->_put($code); |
|
961
|
|
|
|
|
|
|
} |
|
962
|
|
|
|
|
|
|
} |
|
963
|
0
|
|
|
|
|
|
return $self; |
|
964
|
|
|
|
|
|
|
} |
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
sub use { |
|
967
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
968
|
0
|
0
|
|
|
|
|
return $self->_put(qq{# CALL: ->use("name")\n}) unless @_; |
|
969
|
0
|
|
|
|
|
|
my ($name) = @_; |
|
970
|
0
|
|
|
|
|
|
$self->USE($name); |
|
971
|
0
|
|
|
|
|
|
return $self; |
|
972
|
|
|
|
|
|
|
} |
|
973
|
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
1; |
|
975
|
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
__END__ |