@@ -188,7 +188,7 @@ sub PDL::Graphics::TriD::Lattice::gdraw {
188188 my $arrows = $points_clumped -> append($points_clumped + $this -> {VertexNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
189189 glDisable(GL_LIGHTING);
190190 my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows ,sequence(ulong,2,$points_clumped -> dim(1))-> t-> dog,
191- 0.5, 0.02 );
191+ 0.5, 0.2 );
192192 PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [1,1,1]);
193193 PDL::gl_lines_col($arrows ,[1,1,1]);
194194 }
@@ -197,23 +197,28 @@ sub PDL::Graphics::TriD::Lattice::gdraw {
197197 my $facearrows = $facecentres -> append($facecentres + $this -> {FaceNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
198198 glDisable(GL_LIGHTING);
199199 my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows ,sequence(ulong,2,$facecentres -> dim(1))-> t-> dog,
200- 0.5, 0.02 );
200+ 0.5, 0.2 );
201201 PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [0.5,0.5,0.5]);
202202 PDL::gl_lines_col($facearrows ,[0.5,0.5,0.5]);
203203 }
204204 }
205205}
206206
207- sub PDL ::Graphics::TriD::Arrows::gdraw {
208- my ($this ,$points ) = @_ ;
209- my $opts = $this -> {Options };
210- glColor3d(@{$opts -> {Color }});
211- my ($from , $to ) = @$opts {qw( From To) };
212- my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($points ,$from ,$to ,
213- @$opts {qw( ArrowLen ArrowWidth) });
214- PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), $opts -> {Color });
215- my $lines = $points -> dice_axis(1,$from )-> append($points -> dice_axis(1,$to ))-> splitdim(0,3);
216- PDL::gl_lines_col($lines ,$opts -> {Color });
207+ sub PDL ::Graphics::TriD::Triangles::gdraw {
208+ my ($this ,$points ) = @_ ;
209+ my $options = $this -> {Options };
210+ my $shading = $options -> {Shading };
211+ my $colours = $this -> {Colors }-> clump(1..$this -> {Colors }-> ndims-1)-> dice_axis(1,$this -> {Faceidx }-> flat)-> splitdim(1,3);
212+ glShadeModel($shading == 1 ? GL_FLAT : GL_SMOOTH) if $shading ;
213+ my $f = ' PDL::gl_triangles' ;
214+ $f .= ' _wn' if $shading > 2;
215+ { no strict ' refs' ; $f = \&$f ; }
216+ if ($shading > 2) { glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); }
217+ my $tmpn = $shading <= 2 ? undef : $options -> {Smooth }
218+ ? $this -> {VertexNormals }-> dice_axis(1,$this -> {Faceidx }-> flat)
219+ -> splitdim(1,$this -> {Faceidx }-> dim(0)) : $this -> {FaceNormals }-> dummy(1,3);
220+ $f -> ($points -> dice_axis(1,$this -> {Faceidx })-> splitdim(1,3), $shading > 2 ? $tmpn : (), $colours );
221+ if ($shading > 2) { glDisable(GL_COLOR_MATERIAL); }
217222}
218223
219224sub PDL ::Graphics::TriD::LineStrip::gdraw {
@@ -270,7 +275,7 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
270275 my $arrows = $points -> append($points + $this -> {VertexNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
271276 glDisable(GL_LIGHTING);
272277 my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($arrows ,sequence(ulong,2,$points -> dim(1))-> t-> dog,
273- 0.5, 0.02 );
278+ 0.5, 0.2 );
274279 PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [1,1,1]);
275280 PDL::gl_lines_col($arrows ,[1,1,1]);
276281 }
@@ -279,7 +284,7 @@ sub PDL::Graphics::TriD::Trigrid::gdraw {
279284 my $facearrows = $facecentres -> append($facecentres + $this -> {FaceNormals }*0.1)-> splitdim(0,3)-> clump(1,2);
280285 glDisable(GL_LIGHTING);
281286 my ($tv , $ti ) = PDL::Graphics::OpenGLQ::gen_arrowheads($facearrows ,sequence(ulong,2,$facecentres -> dim(1))-> t-> dog,
282- 0.5, 0.02 );
287+ 0.5, 0.2 );
283288 PDL::gl_triangles($tv -> dice_axis(1,$ti )-> splitdim(1,3), [0.5,0.5,0.5]);
284289 PDL::gl_lines_col($facearrows ,[0.5,0.5,0.5]);
285290 }
0 commit comments