Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

IndexedFaceSet to 3D lines in two lines of PDL

by etj (Chaplain)
on Apr 17, 2022 at 21:12 UTC ( #11143037=CUFP: print w/replies, xml ) Need Help??

I was digging through some bit-rotted PDL::Graphics::TriD stuff to finish/fix it, and looked at PDL::Graphics::TriD::Logo. It was intended to be used with the non-functional-right-now PDL VRML support, in particular VRML's IndexedFaceSet feature. It had 3D point coordinates, then triplets of indexes into those to describe triangles.

Gripped - nay, seized - by a desire to see what the logo looked like, I needed to turn that into something the current TriD code can show me. I knew line3d could take a set of 4-point tuples to draw triangles if the 4th point was the same as the 1st. But how to turn points+indexes into that?

I often say that in PDL, the "right" solution to problems involves slices and dimension-mangling. This was no exception!

use PDL::Graphics::TriD; use PDL::Graphics::TriD::Logo; $p = $PDL::Graphics::TriD::Logo::POINTS; # dims: xyz, i $i = $PDL::Graphics::TriD::Logo::FACES; # dims: i1to3, ntriangles # 1: duplicate 0-th index onto end of each vector completing triangle $i = $i->append($i->slice('0')); # change to i1to3to1 # 2: flatten indices, slice points with those, restore 4-tuples shape $tri = $p->slice(':',$i->clump(-1))->splitdim(1,$i->dim(0)); line3d($tri); # visualise
Coda: the logo is just "PDL" in a serif font, given "depth" as if in a stick of rock.

I'm intending to update the VRML support to:

  1. generalise that plus the OpenGL support of each specific thing (lines, points, etc) to go via an intermediate description to make this easy;
  2. work at all;
  3. switch it to use X3D;
  4. use that to generate updated 3d demos for the PDL website.
If anyone wants to help, please say so!

Replies are listed 'Best First'.
Re: IndexedFaceSet to 3D lines in two lines of PDL
by etj (Chaplain) on Apr 17, 2022 at 22:23 UTC
    That last bit now suggests to me we need PDL::IO::TriD::VRML, PDL::IO::TriD::OpenGL1, PDL::IO::TriD::X3D, etc: the "intermediate format" I had in mind was tuples of ("thingtype", \@needed_pdls, \%options), where "thingtype" might be "line", "triangles", etc. Now it looks like we need functions in each of those packages like line, triangles, etc, which take e.g. line($suitable_handle, \@pdls, \%options).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://11143037]
Approved by kcott
Front-paged by Discipulus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2022-09-28 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (124 votes). Check out past polls.

    Notices?