@@ -162,46 +162,11 @@ sub PDL::Graphics::TriD::Lattice::gdraw {
162162 if grep $_ -> ndims < 3, $points , $this -> {Colors };
163163 my $options = $this -> {Options };
164164 my $shading = $options -> {Shading };
165- my $faces = !defined $this -> {Faceidx } ? undef : $points -> clump(1..$points -> ndims-1)-> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
166- my $colours = !defined $this -> {Faceidx } ? undef : $this -> {Colors }-> clump(1..$this -> {Colors }-> ndims-1)-> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
167- if ($shading ) {
168- glShadeModel($shading == 1 ? GL_FLAT : GL_SMOOTH);
169- my $f = ' PDL::gl_triangles' ;
170- $f .= ' _wn' if $shading > 2;
171- { no strict ' refs' ; $f = \&$f ; }
172- if ($shading > 2) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
173- my $tmpn = $shading <= 2 ? undef : $options -> {Smooth }
174- ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
175- -> splitdim(1,$this -> {Faceidx }-> dim(0)) : $this -> {FaceNormals }-> dummy(1,3);
176- $f -> ($faces , $shading > 2 ? $tmpn : (), $colours );
177- if ($shading > 2) { glDisable(GL_COLOR_MATERIAL); }
178- }
179165 if ($shading == 0 or $options -> {Lines }) {
180166 glDisable(GL_LIGHTING);
181167 PDL::gl_line_strip_col($points , $shading ? [0,0,0] : $this -> {Colors });
182168 PDL::gl_line_strip_col($points -> xchg(1,2), $shading ? [0,0,0] : $this -> {Colors }-> xchg(1,2));
183169 }
184- if ($options -> {ShowNormals }) {
185- die " No normals to show!" if !grep defined $this -> {$_ }, qw( FaceNormals VertexNormals) ;
186- if (defined $this -> {VertexNormals }) {
187- my $points_clumped = $points -> clump(1..$points -> ndims-1);
188- my $arrows = $points_clumped -> append($points_clumped + $this -> {VertexNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
189- glDisable(GL_LIGHTING);
190- my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows ,sequence(ulong,2,$points_clumped -> dim(1))-> t-> dog,
191- 0.5, 0.2);
192- PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [1,1,1]);
193- PDL::gl_lines_col($arrows ,[1,1,1]);
194- }
195- if (defined $this -> {FaceNormals }) {
196- my $facecentres = $faces -> transpose-> avgover;
197- my $facearrows = $facecentres -> append($facecentres + $this -> {FaceNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
198- glDisable(GL_LIGHTING);
199- my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows ,sequence(ulong,2,$facecentres -> dim(1))-> t-> dog,
200- 0.5, 0.2);
201- PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [0.5,0.5,0.5]);
202- PDL::gl_lines_col($facearrows ,[0.5,0.5,0.5]);
203- }
204- }
205170}
206171
207172sub PDL ::Graphics::TriD::Triangles::gdraw {
0 commit comments