PhilC opened this issue on Mar 04, 2011 · 12 posts
PhilC posted Fri, 04 March 2011 at 3:49 PM
What is the encoding/decoding for PMD files? Tried gzip .. no go.
Thanks
amandagirl15701 posted Fri, 04 March 2011 at 8:59 PM
Attached Link: Binary Morph Editor
As I understand it, Pmd files are Binary and not compressed. I noticed that if the file is opened in a text editor, the first few words are the morph name and which group the morph affects. I know D3D has a few scripts that work with Pmds and has a Pmd Editor found here in the marketplace.Hope it helps.
PhilC posted Fri, 04 March 2011 at 11:24 PM
Yes they are binary files, thanks.
Was trying something along these lines but I'm not quite there yet.
try:
import binascii
except:
print "binascii not found"
def main():
filepath = "C:test.pmd"
f = open(filepath,"rb")
data = f.readlines()
f.close()
i = 0
while i < len(data):
text = data[i]
#print binascii.a2b_hex(text)
#print binascii.a2b_hqx(text)
#print binascii.a2b_base64(text)
#print binascii.a2b_uu(text)
print binascii.a2b_qp(text)
i = i + 1
main()
print "done"
semidieu posted Sat, 05 March 2011 at 4:25 AM
I'm also interested of this because...
saving a figure with python scripts and Binary morph deltas enabled creates a pmd... but not usable for injecting using a pose file. It works if you load it with the figure but cannot be used to load morphs on a figure with a pose (pz2) file.
PhilC posted Sat, 05 March 2011 at 6:56 AM
Exactly :)
PhilC posted Sat, 05 March 2011 at 8:26 AM
Just throwing stuff at the wall here. As above but with:-
import struct
struct.unpack('<4b',text)
http://docs.python.org/library/struct.html
Also:-
import xdrlib
xdrlib.Unpacker.unpack_list(text)
PhilC posted Sat, 05 March 2011 at 11:38 AM
Not there but a little more structured.
def main():
import struct
filepath = "C:test ball.pmd"
f = open(filepath,"rb")
data = f.readlines()
print data
print
print"-----------------------"
print
f = open(filepath,"rb")
while 1:
chunk = f.read(4)
if chunk == "":
break
print struct.unpack('<4b',chunk)
f.close()
main()
grichter posted Sat, 05 March 2011 at 4:21 PM
Quote - I'm also interested of this because...
saving a figure with python scripts and Binary morph deltas enabled creates a pmd... but not usable for injecting using a pose file. It works if you load it with the figure but cannot be used to load morphs on a figure with a pose (pz2) file.
I assume you do not know the old Miki2.0 exapnsion morphs (Ultimate Body Morphs) from RDNA where injected pmd's. Granted what you are trying to do and how that file was created might be as different as night and day. When it comes to morph creations, injections and or advanced python scripts, I am a complete rookie.
Hopefully without violating the copyright, the first line in the pz2 file reads. It is edited from the original location by me.
injectPMDFileMorphs :Runtime:libraries:Morphs:Miki2:M2UBM.pmd
Gary
"Those who lose themselves in a passion lose less than those who lose their passion"
markschum posted Sat, 05 March 2011 at 10:26 PM
are you looking at the file with a hex editor ? from when I worked with bigger systems the numbers were stored in several formats according to size and type. For example an integer might be stored as two byte binary as &H0255 which the language decodes to 255.
Just ignore this if it makes no sense. :)
semidieu posted Sun, 06 March 2011 at 7:43 AM
Quote - > Quote - I'm also interested of this because...
saving a figure with python scripts and Binary morph deltas enabled creates a pmd... but not usable for injecting using a pose file. It works if you load it with the figure but cannot be used to load morphs on a figure with a pose (pz2) file.
I assume you do not know the old Miki2.0 exapnsion morphs (Ultimate Body Morphs) from RDNA where injected pmd's. Granted what you are trying to do and how that file was created might be as different as night and day. When it comes to morph creations, injections and or advanced python scripts, I am a complete rookie.
Hopefully without violating the copyright, the first line in the pz2 file reads. It is edited from the original location by me.
injectPMDFileMorphs :Runtime:libraries:Morphs:Miki2:M2UBM.pmd
There's a very little difference: the pmd from Ultimate Body Morphs were created using the default Poser library (the + sign). But when you save a figure using a python script, it seems that it does not save exactly the same pmd! It's a Poser Python bug.
grichter posted Sun, 06 March 2011 at 12:01 PM
Ahh, you learn something new everyday regarding life....and something new everytime you run Poser!
Gary
"Those who lose themselves in a passion lose less than those who lose their passion"
nruddock posted Sun, 06 March 2011 at 1:08 PM
As markschum says, it's best to look at bniary files in a hex editor (I use emacs in hexl-mode).
In the case of PMD files, the organisation looks to be quite simple.
Magic (4 bytes) = "PZMD"
Unknown (12 bytes)
Figure count ? (4 bytes)
Figure number ? (4 bytes)
Figure morph header length ? (4 bytes)
Figure morph header
Morph count (2 bytes)
Morph name (1 byte) name length, (length bytes) name
Group name (1 byte) name length, (length bytes) name
Num deltas (2 bytes)
Offset to data (2 bytes) relative to beginning of file
Morph data
Index count (4 bytes
2 doubles ? (16 bytes) X index count