1
###################################
4
package PDL::Graphics::TriD::Object;
8
use fields qw(Objects ValidList ChangedSub List VRML);
12
my $self = bless [ \%{"$class\::FIELDS"}], $class;
18
$this->{Objects} = [];
19
$this->{ValidList} = 0;
24
my($this,$object) = @_;
25
return unless(defined $object && defined $this->{Objects});
26
for(0..$#{$this->{Objects}}){
27
if($object == $this->{Objects}[$_]){
28
splice(@{$this->{Objects}},$_,1);
34
# XXXXXXXXX sub {} makes all these objects and this window immortal!
36
my($this,$object) = @_;
37
push @{$this->{Objects}},$object;
38
$this->{ValidList} = 0;
39
for(@{$this->{ChangedSub}}) {
40
$object->add_changedsub($_);
42
if($this->i_keep_list) {
43
$object->add_changedsub(sub {$this->changed_from_above()});
47
sub changed_from_above {
49
print "CHANGED_FROM_ABOVE\n" if $PDL::Graphics::TriD::verbose;
54
my($this,$chsub) = @_;
55
push @{$this->{ChangedSub}}, $chsub;
56
for (@{$this->{Objects}}) {
57
$_->add_changedsub($chsub);
64
# print "Clear: $this\n";
65
for(@{$this->{Objects}}) {
68
$this->delete_displist();
69
delete $this->{ChangedSub};
70
delete $this->{Objects};
75
print "VALID0 $this\n" if $PDL::Graphics::TriD::verbose;
76
$this->{ValidList} = 0;
77
for(@{$this->{ChangedSub}}) {
89
use PDL::Graphics::VRML;
91
$this->{VRML} = new PDL::Graphics::VRMLNode('Transform',
92
'translation' => "-1 -1 -1",
94
$this->{ValidList} = 1;
100
print ref($this)," valid=",$this->{ValidList}," tovrml\n";
102
if (!$this->{ValidList}) {
103
$this->vrml_update();
105
$this->{VRML}->add('children',
106
[map {$_->tovrml()} @{$this->{Objects}}]);