ValueOperations, burn in hell



  • ok so I am scripting in python, and its a lot of fun... but now I realized that many of my scripts don't work on figures because when you take a value of a parameter at one frame, and overwrite another frame with it... it entirely ignores the apparent ValueOperations that are controlling it... and now suddenly I understand why copypasting keyframes of conforming figures doesn't work.

    Dependency controlled operations have been around since V4, probably earlier. But now I have to make complicated for loops to isolate which parameter is controlling my actual parameter to minus that value from the value f my actual parameter so that I can get the actual bloody value of the bloody parameter! Guys, really?

    Please tell me I am missing some simple option somewhere?

    PS: please please let normal keyboard functions work in the python shell. ie: Ctrl+C and Ctrl+A



  • I don't know whether you eventually can reverse engineer D3D's "PoseWriterPanel"...

    But what Ralf Sesseler did with that script is exactly what you are looking for: It reads the global values of the parameters instead of only the local (dialed) values.

    Of course I know that reverse engineering and copying code is strictly prohibited by USA "World Law".
    However getting personal inspiration still isn't (yet)
    ;)

    K



  • Yeah I'm digging through other people's code now, the problem is that most of its been compiled. I'd need a python decompiler and that's probably illegal.

    But the fact that I cannot for the life of me access a number that is staring back at me from the UI is unbelievable. I find it shockingly stupid.



  • @erogenesis latest version of Poser Python has UnaffectedValue() method for parameters. This is what you want. I have reams of code emulating that behaviour from prior to that method being made available. The only problem (at least for animation processing) is that there is no parallel function for the ValueFrame() method, whereby you can ask for the UnaffectedValueFrame() at the specified frame, so you have to set the scene frame to the frame you want to process and call UnaffectedValue(). I have asked for this functionality, as I did previously for UnaffectedValue(), but so far SMS has not come to the party.



  • @erogenesis Oh, and welcome to my world ;-). I, too, lament the late D3D's passing, but there are still a heap of things which those of us who remain, have experience with and can willingly assist in overcoming. (TGLWATCDR). Further on the UnaffectedValue() method; previously, I had developed python library methods which performed simple linear regression algebra to functionally invert valueOpDeltaAdd. The real bellyache came when I turned my attention to valueOpKey, whose interpolation method is entirely undocumented, (without access to the source code) and for three key, value elements was still not perfectly emulated by B-Splines, for which I had to replace the bundled NumPy module so I could import SciPy. Thankfully, the need for that level of artful gyration evaporated when UnaffectedValue() was implemented. The prior methods were all subject to discontinuities and hence uninvertible when limits were in effect, not to mention Python Callbacks, which remain a black box permeable only to tachyons and clingwrapping a Poser Code Warrior to a table with scalpel in hand (Thanks, Dexter).



  • Amazing, that exactly a part of what i'm actually working on :)

    UnaffectedValue is king, but will work only in P11.
    I found the easiest way to re-emulate ValueOps correctly is to ... recreate 2 temp paramaters (one master and a dependency) re-emulate the values and finally remove them. It looks dirty, but it's efficient, correct and fast.
    After all, a figure is finally just a bag of datas. Why should i be afraid of doing that ? :)



  • @barnardino Yes, prior to P11 and UnaffectedValue() the safest way (without attempting to reverse engineer the interpolation of splines for valueOpKey) to determine dial values was to create a list of a parameter's value operations, delete them all, record the parameter Value(), and then re-create the saved list of value operations. The major problem with this is that it is impossible to account for Python callbacks (which are a form of value operation) if the callback comes from a plugin, or code which you haven't written yourself, and the time penalty, especially if one is attempting to save an animation is enormous if one does that for every parameter of every actor in the scene for every frame. It may seem reasonable to try and remove the value operations for all parameters and then collect their values over the frame range before reinstating them, using ValueFrame(), but then you have to step through the frames with the valueOperations in place if you want to generate Library Pose Icons which are representative of the pose at that frame. Poser also displayed an annoying tendency to crash with such a high volume of valueOperation deletion and creation.



  • thanks guys for the info. Yeah I figured they must have fixed that in p11, was about time too. But yeah I mostly still use P10 for the hardcore work.

    So I solved it something like this:

    def getactualf*ckingvalue(parameter, index):

    value = 0
    if parameter.NumValueOperations() > 0:
    	for v in parameter.ValueOperations():
    
    		valueopResult = v.SourceParameter().ValueFrame(index) * v.Delta()
    		finalValue = 0
    		valueReadFromParm = parameter.ValueFrame(index)
    		finalValue = (valueReadFromParm - valueopResult)
    		value += round(finalValue, 4)
    else:
    	value = parameter.ValueFrame(index)	
    			
    return value
    

    I was worried that I'd have to reverse engineer the dependency keys, and those can be a biaatch since they can be anything, but it seems that Delta is just the difference regardless of how its programmed to respond to other values. So since I'm just looping to find keys and then moving them around, all I need is the end value and this is how I finally managed to get it. It SEEMS to work up until now. The rest of the script just loops through the actors in the timeline and collects a list of keyframes to swap.

    My other scripts was about creating a gap in the timeline and I solved that by simply starting from the back of the timeline working forwards, storing the keyframe type, setting it to constant and then adding a keyframe at the specified distance. Then that new keyframe gets the type of the old one, and the old one gets chucked. That way actually worked faster.

    Ugh!

    PS: ignore my code style I'm brand new at this!



  • @erogenesis the only other caveat with using linear regression to get the dial value from a valueOpDeltaAdd is that at the parameter's limits, if forceLimits is on, there will be a discontinuity and you can get misleading values back if the valueOperation has driven the parameter value beyond it's limit. I.e. you won't get the correct dial value back in this case. E.g. for a parm with limits 0 and 1, if the delta is 2.0 and the master is at 1.0, the parameter's value will still only be 1, not 2, so subtracting 2 * 1 from 1 will give you -1, which will be incorrect as it should be 0.



  • @anomalaus said in ValueOperations, burn in hell:

    @erogenesis the only other caveat with using linear regression to get the dial value from a valueOpDeltaAdd is that at the parameter's limits, if forceLimits is on, there will be a discontinuity and you can get misleading values back if the valueOperation has driven the parameter value beyond it's limit. I.e. you won't get the correct dial value back in this case. E.g. for a parm with limits 0 and 1, if the delta is 2.0 and the master is at 1.0, the parameter's value will still only be 1, not 2, so subtracting 2 * 1 from 1 will give you -1, which will be incorrect as it should be 0.

    oh crap I didn't think of that. I'd have to cross check with the limits too...!



  • @erogenesis I'm going to throw this code out there. It forms part of a PoserLib module I've been building, which is a collection of Poser Python API addons that SMS should be providing, but don't, yet. There is a lot of redundant code which is commented out, but it is instructive to see what I originally implemented to do what UnaffectedValue() does now in P11.

    PoserDialValue.py

    It should work equally well in PPro2014 as it has try: except: blocks around calls to P11 only methods, and on exception reverts to the workaround methods.



  • @anomalaus said in ValueOperations, burn in hell:

    @erogenesis I'm going to throw this code out there. It forms part of a PoserLib module I've been building, which is a collection of Poser Python API addons that SMS should be providing, but don't, yet. There is a lot of redundant code which is commented out, but it is instructive to see what I originally implemented to do what UnaffectedValue() does now in P11.

    PoserDialValue.py

    It should work equally well in PPro2014 as it has try: except: blocks around calls to P11 only methods, and on exception reverts to the workaround methods.

    that is absolute sublime! Will dig into it immediately. I'm also doing this to help a scriptor to make nice scripts for PE. Thank you so much!



  • @anomalaus yes i could have bet you had the best solution :)
    It depends in which case you need it. Your solution is 'universal', mine is 'situational'.
    Why use a nuclear weapon when you only need a rock ! :)
    But i agree, in the case of animation my solution is not the best.

    thx for you collection !

    (btw i've never seen yet python callback method used anywhere in most of the python scripts i met for poser)



  • @anomalaus just wanted to say thanks once more the the example scripts. Was interesting to check out. I'm going to take a closer look at how you built up those functions where you recreate the valueops, those will come in serious handy one day. For now I think I managed to adjust the script I made such that I don't have to delete any value ops, that indeed does take long because my girls are FILLED with them!!!

    BTW does anyone know if Game Dev had its own Python reference manual? And did it contain any references to baking elements?

    Also: does anyone have a copy of the P11 python ref pdf? I don't feel like downloading 400+ Mb of useless crap in japanese and german just for a 4Mb PDF (hint hint @Poser-Team pls provide manuals separately from that monster support download)



  • @barnardino one of the earliest Poser demo figures "Barney" has python callbacks to blink his eyes (which are black discs and blinking scales their yScale to zero 8-O).



  • @erogenesis given that it's sometimes years between updates to these scripts, I've found the only way to keep on top of how I made things work is to bury everything in comments and even leave in great swathes of commented out code to remind me how I got there. At least it means I generally have no qualms about sharing obscure code.

    I will PM you a link for the thing you asked for when I get it uploaded. I don't remember there being any separate "Game Dev' manual, though the P11 manual does mention things which are Game Dev only, IIRC (Kinect? Mesh decimation?)



  • @anomalaus said in ValueOperations, burn in hell:

    @erogenesis given that it's sometimes years between updates to these scripts, I've found the only way to keep on top of how I made things work is to bury everything in comments and even leave in great swathes of commented out code to remind me how I got there. At least it means I generally have no qualms about sharing obscure code.

    And I'm thankful for it. I too don't care about sharing it. I think I've just solved about 80% of all my problems in Poser by picking up Python in the last week. From swapping out keyframes between selected parameters, to repeaters, to randomizers, to pointing objects at others without committing them to point at, creating gaps, moving keyframes up in bulk, bringing an actor near to another, aligning actors, putting an actor in front of the camera, resetting children, setting keyframes for only the poser parameters, loading up entire characters with hair and materials with the latest updated version of my figure without overloading my library with compound characters, loading groups of such characters in one click... I haven't been this excited about poser in years, I'm not kidding! These tools will all be available for Project E.

    I will PM you a link for the thing you asked for when I get it uploaded. I don't remember there being any separate "Game Dev' manual, though the P11 manual does mention things which are Game Dev only, IIRC (Kinect? Mesh decimation?)

    thanks so much !

    btw, do you know what the four truples in WorldMatrix represent? could it help me with making my own bake function?



  • @erogenesis I will have to swap to another browser with all my bookmarks (and literally hundreds of open tabs) for the reference material I've found relating to world matrices. IIRC the things which are most inadequately described are exactly what Poser's pipeline of matrix processing is, because I think they do scaling separately after everything else at each actor hierarchy level. I know that including scaling in the matrices stops them being unit normalised, so you can't just derive the Euler angles from them with the standard formulas and you need to know exactly which rotation order each actor uses in the hierarchy to correctly reverse engineer the world matrices.

    I was trying, for quite a while, to develop a script to implement vertex following props (think body piercings), but rotating the figure about the Y-axis completely screwed with the matrix calculations I was using to extract Euler angles. I would love for Poser to have boarded the dual-quaternion train, just to avoid gimbal-lock situations, but as @bagginsbill helpfully pointed out, there are actually even better solutions for limb bending deformations that dual-quaternions don't solve very well, and you also end up with the horrible solution which DAZ have used to overcome the single vertex d-q weight map: bend limb + twist limb.



  • @erogenesis OK, here's a good resource I've found with Poser matrix method explanations. A lot to go through, but well worth the understanding when you've made the effort.

    allstereo-poser-matrix-methods.zip



  • @anomalaus said in ValueOperations, burn in hell:

    @erogenesis OK, here's a good resource I've found with Poser matrix method explanations. A lot to go through, but well worth the understanding when you've made the effort.

    allstereo-poser-matrix-methods.zip

    wow, ok some of that looks scarily familiar. I had to do matrix operations and Fourier transforms back in the day when studying geology, not my favorite course, but, I'll have to dig into this if I wanna get the scripts I want. It might have to wait until after PE... but I really want to be rid of all those annoying limitations with IK, constraints and Point Ats. Thanks so much for the link!

    btw I noticed this chat about python callbacks, you mean that a character can invoke a python script when activated / dialled?


Log in to reply
 

Looks like your connection to Graphics Forum was lost, please wait while we try to reconnect.