Fri, Jan 24, 4:59 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2025 Jan 24 4:20 pm)



Subject: PoserParser.pm : Perl Extension reaches Beta!


_dodger ( ) posted Mon, 19 May 2003 at 6:05 PM ยท edited Fri, 26 July 2024 at 9:08 PM

Attached Link: PoserParser Perl extension

Okay, there are inevitably still bugs to work out in this, but PoserParser.pm (namespace subject to future change) is now available for beta. The module has now passed alpha tests to:
  1. Read a Poser document into a data structure in memory
  2. Write that data structure out to a Poser file again

An example CR2 output from the module is at http://www.dodger.org/ttt/poserParser/outputTest.cr2. This is a copy of my Elf Mage Vicki boots CR2 that has been read in and spit back out. I have not found any errors in it yet (but if you fond one, let me know). Some notes: The output of the module is, in some places, more syntactically precise than the output of Poser itself. For instance, you'll note that a figureResFile is only declared once. It only needs to be (this has been tested) declared once per figureResFile. It's also declared lower in the file than the Elf Mage Vicki boots original CR2 does this. This is because it recognises that the null geometries do not need it declared. Another thing to note is that boolean values are set to 1 for true and 0 for false. Poser does this for most boolean values, but occassional values (forceLimits and customMaterial, for instance) seem to oddly be set to other values (4 and 32, respectively, in these cases) for true. Setting such values to '1' works identically to the more unusual values Poser inserts, and so this module outputs more correctly typed values (of course, on re-saving, Poser will insert the weird numbers instead, again). This is in a beta 1 pre-release form because if you don't know some Perl, it's not going to help you a lot. By the time I release it as a full release v1.0+, it will contain convenience methods that only require the user to be able to script the barest amount of Perl to use it. However, it should be noted that you can do some pretty cool things right now if you do know Perl. For instance, you can instantiate two PoserParser objects, read in files from both of them, and then rearrange the contents of those files. It can also, at this point, be used for Poser object extraction (not geometry extraction). For instance, you can, at this point, read in a PZ3 file and then extracta single figure from it and save a CR2. The process, once scripted, will take about 1-3 seconds depending on the complexity of the file contents (mts and such). It can also be used for relatively simple channel management and other utility functions.


_dodger ( ) posted Mon, 19 May 2003 at 10:58 PM

Just wanted to note: I've tested the functionality of the thing I built this for and it works. I was able to transfer a material from one file to another! Wuhu! And with only this much code:

#!/usr/bin/perl
use PoserParser;
my $matlib = new PoserParser;
$matlib->read('./weapons.mt4');
my $mat = ($matlib->getFigures)[0];
my $cr2 = new PoserParser;
$cr2->read('/usr/local/www-gc/dodger/friv/devel/ElfMageVickiBeta/Runtime/Librari
es/Character/Elf Mage Vicki/Elf Mage Boots.cr2');
my $boots = $cr2->getFigure(2);
$boots->{material}->{Silver} = $mat->{material}->{Blade};
$boots->{material}->{Silver}->{_id} = 'Silver';
$cr2->writePZ3('CR2', 'ppt/changeAMat.cr2');


_dodger ( ) posted Mon, 19 May 2003 at 11:06 PM

Just as a note, the mt4 file referenced is just a simple MAT pose file.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.