Are there efficient ways of reading and writing binary numeric data ?
zaz777
Posts: 115
I've cobbled together a PMD loader in DAZ script and while it works, its very slow. I expect this is because I'm using my own routines, written in DAZ script, to convert the byte data to 32 bit ints and floats.
I'm not finding any way of directly reading or writing binary ints and floats nor any functions/methods on classes to convert from bytes to ints and floats. I assume this is because they don't exist in DAZ script at this time. DzFile looks like a good candidate to add readInt, readFloat and other operations like this.
Prove me wrong, please, .
Post edited by zaz777 on
Comments
The script engine, like all interpreted languages, is going to be a lot slower than native code. If you really need it to be faster, look at how you are parsing the file and see if you can do things more efficiently. Instead of converting stuff by hand, you may be able to simply cast things which will be faster than manually rearranging and calculating other types.
If all else fails, it might be better to write it as an I/O plugin in native C++.
Unfortunately, casts aren't working at all and not surprising in a dynamically typed language. Good idea though, one I hadn't thought of. Thanks for trying.
It'd definitely be faster in C/C++, or even Java, but all that is more hassle for me than its worth right now.
I ended up getting the Terradome 2 bundle as a freebie and couldn't get the PMD morphs to work in DS (don't have poser) with CR2 hacks or MorphExchange. So, I just hacked some DAZ Script to do the job. It works, but takes over 20 mins to load the base morphs.
I think I'll just call it done for now as I don't have that big of a need for PMD support,.
If you could do it in C/C++ and make it a Studio Plugin, you would have many people beating a path to your door...and the undieing gratitude of quite a few folks, too...
And even if it does take forever to load, that script solution may make quite a few people happy.
I'm not really setup for development on Windoze, at least not for plugins as I've been using MinGW for the rare C/C++ programs I write for Windoze. MinGW doesn't produce the correct signatures for C++ code to link against DS and Microsoft C++ libaries.
I did convert the code to C last night though, the parsing and loading of the PMD data, and its about 1,500 times faster. I knew it'd be faster, but I wasn't expecting that much of a performance gain. I rarely see that type of a difference any more between scripting and compiled languages.
It also wasn't as straight forward of a conversion as I thought. The readInt/readFloat operations I mentioned in the OP wouldn't actually work for this anyway.
So, I think at this point, I'll look at putting a UI on the script, do some more testing and see where it sits. It might be time to get VS in some form or another though.
Do you have the SDK?
http://www.daz3d.com/daz-studio-4-5-sdk
Yep, I've had the SDK for years. I just haven't had a means to compile the C++ code that would work with DS, until recently.
Earlier in the week, I did take the time to get VS2015 installed and registered and have built the AFirstPlugin and other projects as a test. I haven't tried to make a plugin out of the PMD code yet.
Now, I'm trying to verify the results of importing the PMD morphs. I don't think its worth the time making a plugin until I'm more confident in the results I'm getting.
The results I get look at least plausible on Terradome 2. Some of the morphs look really good and I see nothing to make me suspicious of the results, but some morphs take on a shape that might not be correct. A few other figures that I've tried this on seem to work well and I haven't noticed anything to be suspicious of, but I've only done a few of those.
I either need to get a copy of poser or find someone to work with who has both poser and Terradome 2, and other figures with PMD morphs, so a comparison of the results can be made.
I believe the work I've done gets me close, but I'm not convinced I've solved all the little gotcha's of the PMD import process.