VRML.pm (PDL-2.082) | : | VRML.pm (PDL-2.083) | ||
---|---|---|---|---|
skipping to change at line 282 | skipping to change at line 282 | |||
sub PDL::Graphics::TriD::Image::tovrml_graph { | sub PDL::Graphics::TriD::Image::tovrml_graph { | |||
&PDL::Graphics::TriD::Image::tovrml; | &PDL::Graphics::TriD::Image::tovrml; | |||
} | } | |||
# The quick method is to use texturing for the good effect. | # The quick method is to use texturing for the good effect. | |||
# XXXXXXXXXXXX wpic currently rescales $im 0..255, that's not correct (in $url-> save)! fix | # XXXXXXXXXXXX wpic currently rescales $im 0..255, that's not correct (in $url-> save)! fix | |||
sub PDL::Graphics::TriD::Image::vdraw { | sub PDL::Graphics::TriD::Image::vdraw { | |||
my ($this,$vert) = @_; | my ($this,$vert) = @_; | |||
my $p = $this->flatten(0); # no binary alignment | my $p = $this->flatten(0); # no binary alignment | |||
if(!defined $vert) {$vert = $this->{Points}} | if(!defined $vert) {$vert = $this->{Points}} | |||
my $url = new PDL::Graphics::TriD::VRML::URL('image/JPG'); | my $url = PDL::Graphics::TriD::VRML::URL->new('image/JPG'); | |||
$url->save($p); | $url->save($p); | |||
vrn('Shape', | vrn('Shape', | |||
'appearance' => vrn('Appearance', | 'appearance' => vrn('Appearance', | |||
'texture' => vrn('ImageTexture', | 'texture' => vrn('ImageTexture', | |||
'url' => '"'.$url->totext.'"')), | 'url' => '"'.$url->totext.'"')), | |||
'geometry' => | 'geometry' => | |||
vrn('IndexedFaceSet', | vrn('IndexedFaceSet', | |||
'coord' => vrn('Coordinate', | 'coord' => vrn('Coordinate', | |||
'point' => | 'point' => | |||
[map {vrml3v([$vert->slice(":,($_)")->list])} | [map {vrml3v([$vert->slice(":,($_)")->list])} | |||
skipping to change at line 363 | skipping to change at line 363 | |||
'coord' => | 'coord' => | |||
vrn('Coordinate', | vrn('Coordinate', | |||
'point' => $vert), | 'point' => $vert), | |||
'coordIndex' => $indx)); | 'coordIndex' => $indx)); | |||
return [@children]; | return [@children]; | |||
} | } | |||
sub PDL::Graphics::TriD::SimpleController::tovrml { | sub PDL::Graphics::TriD::SimpleController::tovrml { | |||
# World origin is disregarded XXXXXXX | # World origin is disregarded XXXXXXX | |||
my $this = shift; | my $this = shift; | |||
my $inv = new PDL::Graphics::TriD::Quaternion(@{$this->{WRotation}}); | my $inv = PDL::Graphics::TriD::Quaternion->new(@{$this->{WRotation}}); | |||
$inv->invert_rotation_this; | $inv->invert_rotation_this; | |||
my $pos = $inv->rotate([0,0,1]); | my $pos = $inv->rotate([0,0,1]); | |||
# print "SC: POS0:",(join ',',@$pos),"\n"; | # print "SC: POS0:",(join ',',@$pos),"\n"; | |||
for (@$pos) { $_ *= $this->{CDistance}} | for (@$pos) { $_ *= $this->{CDistance}} | |||
# print "SC: POS:",(join ',',@$pos),"\n"; | # print "SC: POS:",(join ',',@$pos),"\n"; | |||
# ASSUME CRotation 0 for now | # ASSUME CRotation 0 for now | |||
return vrn('Viewpoint', | return vrn('Viewpoint', | |||
'position' => vrml3v($pos), | 'position' => vrml3v($pos), | |||
# 'orientation' => vrml3v(@{$this->{CRotation}}[1..3]). | # 'orientation' => vrml3v(@{$this->{CRotation}}[1..3]). | |||
# " $this->{CRotation}->[0]", | # " $this->{CRotation}->[0]", | |||
skipping to change at line 407 | skipping to change at line 407 | |||
my $this = shift; | my $this = shift; | |||
if ($this->Error) { | if ($this->Error) { | |||
print Win32::DDE::ErrorText($this->Error), "\n# ", | print Win32::DDE::ErrorText($this->Error), "\n# ", | |||
$this->ErrorText; | $this->ErrorText; | |||
barf "client: couldn't connect to netscape"; | barf "client: couldn't connect to netscape"; | |||
} | } | |||
return $this; | return $this; | |||
} | } | |||
sub activate { | sub activate { | |||
my $client = new Win32::DDE::Client ('Netscape','WWW_Activate'); | my $client = Win32::DDE::Client->new('Netscape','WWW_Activate'); | |||
checkerr($client); | checkerr($client); | |||
$client->Request('0xFFFFFFFF,0x0'); | $client->Request('0xFFFFFFFF,0x0'); | |||
barf "can't disconnect" unless $client->Disconnect; | barf "can't disconnect" unless $client->Disconnect; | |||
} | } | |||
sub geturl { | sub geturl { | |||
my ($url) = @_; | my ($url) = @_; | |||
my $client = new Win32::DDE::Client ('Netscape','WWW_OpenURL'); | my $client = Win32::DDE::Client->new('Netscape','WWW_OpenURL'); | |||
checkerr($client); | checkerr($client); | |||
my $status = $client->Request("\"$url\",,0xFFFFFFFF,0x1"); | my $status = $client->Request("\"$url\",,0xFFFFFFFF,0x1"); | |||
barf "can't disconnect" unless $client->Disconnect; | barf "can't disconnect" unless $client->Disconnect; | |||
} | } | |||
package PDL::Graphics::TriD::VRML::Parameter; | package PDL::Graphics::TriD::VRML::Parameter; | |||
use PDL::Core ''; # barf | use PDL::Core ''; # barf | |||
sub new { | sub new { | |||
my ($type,%hash) = @_; | my ($type,%hash) = @_; | |||
skipping to change at line 602 | skipping to change at line 602 | |||
use fields qw/Width Height Interactive _ViewPorts _CurrentViewPort | use fields qw/Width Height Interactive _ViewPorts _CurrentViewPort | |||
VRMLTop DefMaterial/; | VRMLTop DefMaterial/; | |||
use strict; | use strict; | |||
$PDL::Graphics::TriD::VRML::fontstyle = $PDL::Graphics::TriD::VRML::fontstyle; | $PDL::Graphics::TriD::VRML::fontstyle = $PDL::Graphics::TriD::VRML::fontstyle; | |||
sub gdriver { | sub gdriver { | |||
my($this) = @_; | my($this) = @_; | |||
require PDL if not defined $PDL::VERSION; | require PDL if not defined $PDL::VERSION; | |||
$this->{Width} = 300; $this->{Height} = 300; | $this->{Width} = 300; $this->{Height} = 300; | |||
$this->{VRMLTop} = new PDL::Graphics::VRML("\"PDL::Graphics::TriD::VRML Scene\ "", | $this->{VRMLTop} = PDL::Graphics::VRML->new("\"PDL::Graphics::TriD::VRML Scene \"", | |||
["\"generated by the PDL::Graphics::TriD module \"", | ["\"generated by the PDL::Graphics::TriD module \"", | |||
"\"version $PDL::VERSION\""]); | "\"version $PDL::VERSION\""]); | |||
my $fontstyle = new PDL::Graphics::VRMLNode('FontStyle', | my $fontstyle = PDL::Graphics::VRMLNode->new('FontStyle', | |||
'size' => 0.04, | 'size' => 0.04, | |||
'family' => "\"SANS\"", | 'family' => "\"SANS\"", | |||
'justify' => "\"MIDDLE\""); | 'justify' => "\"MIDDLE\""); | |||
$PDL::Graphics::TriD::VRML::fontstyle = $fontstyle; | $PDL::Graphics::TriD::VRML::fontstyle = $fontstyle; | |||
$this->{VRMLTop}->add_proto(PDL::Graphics::TriD::SimpleController->new->tovrml ); | $this->{VRMLTop}->add_proto(PDL::Graphics::TriD::SimpleController->new->tovrml ); | |||
$PDL::Graphics::VRML::current_window = $this->{VRMLTop}; | $PDL::Graphics::VRML::current_window = $this->{VRMLTop}; | |||
$this->{VRMLTop}->register_proto( | $this->{VRMLTop}->register_proto( | |||
vrp('TriDGraphText', | vrp('TriDGraphText', | |||
[fv3f('position',"0 0 0"), | [fv3f('position',"0 0 0"), | |||
fmstr('text')], | fmstr('text')], | |||
skipping to change at line 642 | skipping to change at line 642 | |||
#} | #} | |||
# we only allow [0,0,1,1] viewports and just write a gif of the write size | # we only allow [0,0,1,1] viewports and just write a gif of the write size | |||
# for any children | # for any children | |||
sub new_viewport { | sub new_viewport { | |||
my($this,$x0,$y0,$x1,$y1) = @_; | my($this,$x0,$y0,$x1,$y1) = @_; | |||
# print STDERR "Installing new viewport\n"; | # print STDERR "Installing new viewport\n"; | |||
barf "only allowing [0,1,0,1] viewports with VRML backend" | barf "only allowing [0,1,0,1] viewports with VRML backend" | |||
if abs(PDL->pdl($x0,$y0,$x1-1,$y1-1))->max > 0.01; | if abs(PDL->pdl($x0,$y0,$x1-1,$y1-1))->max > 0.01; | |||
my $vp = new PDL::Graphics::TriD::ViewPort($x0,$y0,$x1,$y1); | my $vp = PDL::Graphics::TriD::ViewPort->new($x0,$y0,$x1,$y1); | |||
push @{$this->{_ViewPorts}},$vp; | push @{$this->{_ViewPorts}},$vp; | |||
return $vp; | return $vp; | |||
} | } | |||
sub clear_viewports { | sub clear_viewports { | |||
my($this) = @_; | my($this) = @_; | |||
$this->{_ViewPorts} = []; | $this->{_ViewPorts} = []; | |||
} | } | |||
sub display { | sub display { | |||
End of changes. 7 change blocks. | ||||
7 lines changed or deleted | 7 lines changed or added |