Forum: Poser - OFFICIAL


Subject: PoserParser.pm : Perl Extension status report

_dodger opened this issue on May 13, 2003 ยท 6 posts


_dodger posted Wed, 14 May 2003 at 5:15 AM

WTH? I had one of my long-winded responses to this and it just disappeared! Okay, in simple terms, Batch processing. You can sue Perl to do all sorts of things you'd normally manually do in a text editor, but you can batch them and do them in a few seconds with the right Perlscript. In this case I'm making an OO approach to it so that you can easily manipulate stuff through Perl and do things to them, like extraction, changes, and stuff like embedded geometry extraction. For instance, using this, once it's done, you'll be able to write something like this:

#!C:perlbinperl.exe
use strict;
use 3DModel::Poser;
my $propslib = 'C:Program FilesPoser 4RuntimeLibrariesProps';
my $geomlib = 'C:Program FilesPoser 4RuntimeGeometriesmyProps';
opendir PROPS, $propslib;
my @props = grep /.pp2$/i, readdir PROPS;
for my $propfile (@props) {
    my $fn = $propfile;
    $fn =~ s/.pp2$//i;
    my $changed = 0;
    my $pp2 = new 3DModel::Poser;
    $pp2->read("$propslib/$propfile");
    for my $object ($pp2->getGeomObjects) {
        my $geomName = $object->{object};
        if ($object->geomType eq 'geomCustom') {
            $object->extractGeom(-filename=>"${fn}_$geomName.obj",
                                 -path=>$geomlib);
            $changed=1;
        }
    }
    if ($changed) {
    $pp2->backup("$propslib/${fn}_backup.pp2");
    $pp2->write("$propslib/$propfile");
    }
}

And this tiny little script run through Perl would, in about 1-2 seconds per prop, extract all the geometry from your prop file and place it nicely away in an external OBJ file instead. So if you had 100 props and some of them very complex, it might take a few minutes to extract every single wavefront OBJect that used customGeom to an external geometry and resave everything it touched (saving a backup of the unchanged file, too). One or two more lines and it can correct all your paths to be relative, too. During that time you can go take a pee, have half a smoke, have a cuppa, or whatnot, because you dont have to sit there doing it. Of course I'll give the module and some scripts away for free, and I'll sell some, too, probably. I'm already giving the development stage module away for free B^) Speaking of which It's updated. It now correctly parses the heirarchy, too, and stores that in the data structure. Yeehee! Same URL as above.