ValueOperations, burn in hell



  • @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?



  • @erogenesis Yep, look at the Barney figure in Cartoon/Cartoons. It came out with Poser Pro Pack, way back when. There's a line:

    	pythonStartupScript 0 0 ":Runtime:libraries:Character:Cartoon:Cartoons:barneyStartup.py"
    

    in the figure block, which loads a python script which sets up the callbacks.

    @bagginsbill has a script called Parmatic, which also uses python callbacks to create valueParameters which drive animated material shaderNode parameters on multiple materials in parallel, without having to setup multi-channel valueOperation dependencies to achieve the same effect. And when you've set the materials the way you want them, the script can remove the valueParms it created in the first place, keeping the figure and parameters palette clean, until you want to mess with materials again.



  • @anomalaus said in ValueOperations, burn in hell:

    @erogenesis Yep, look at the Barney figure in Cartoon/Cartoons. It came out with Poser Pro Pack, way back when. There's a line:

    	pythonStartupScript 0 0 ":Runtime:libraries:Character:Cartoon:Cartoons:barneyStartup.py"
    

    in the figure block, which loads a python script which sets up the callbacks.

    @bagginsbill has a script called Parmatic, which also uses python callbacks to create valueParameters which drive animated material shaderNode parameters on multiple materials in parallel, without having to setup multi-channel valueOperation dependencies to achieve the same effect. And when you've set the materials the way you want them, the script can remove the valueParms it created in the first place, keeping the figure and parameters palette clean, until you want to mess with materials again.

    ok that can be very useful. If I can harness the essence of allstereo's stuff and turn that into a script, I could have the character's keyframes updated at every mouse release using a callback. Again, it would take a while before I could dig into this properly, but then again by just skimming through it I see I've already been doing some of it with some of the scripts I wrote yesterday. I was making a simple script that aligns a girl to a man (for naughty reasons) and for that I needed to get back into Cartesian mathematics to deal with two coordinate systems like I see in this PDF... only the matrices take it to whole new level. I'm going to have to buy a bottle of single malt for that one...

    .. that is assuming that the IK'ed, pointed and constrained centers are actually updated and represented with these WorldMatrices...



  • Btw where is the python compiler ? I thought i saw one somewhere a known poser website but i don't find it anymore.



  • @barnardino Nevermind, i found it.



  • @anomalaus ok, I think I just made the script that I've been begging for for the last few years, I can find the actual angles in an IK'ed figure and therefore update the mo&^%#%ing JCMs. I feel like its my birthday!

    Long story short is that with a bit of classical vector mathematics, and using worldDisplacement and some other truples in the figure, I was able to successfully deduce what the angle of the forearm was going to be when the IK would be switched off. It was correct to the second decimal place. Its actually so stupid simple!

    The script is a little basic at the moment since it accounts for only two vectors on one plane. Once I start dealing with the shldr things will get a little hairier since it can rotate in one more axis than the elbow can. But its probably not that hard to do.

    Once I have this script going, IK is not going to be a problem anymore for JCMs!!!!!!! I hope it will work with constraints too.

    Again, this is making me so stupid happy!



  • lol I just found a very very easy solution to updating rotations and JCMs with IK, its ridiculously easy... no need for matrices and vectors at all! I'll share soon when I have the script solid.



  • @anomalaus So what I've done was make a script that loads up a grouping dummy, parent it to the actor, restore it so it gets the orientation of the actor, reparent it to the parent of the chosen actor, without re-aligning of course, then the orientation it has in the parent is therefore the orientation of the actor it came from, and I subsequently update the actor with the new orientation, delete the dummy, and boom, the JCMs are back to normal. It works perfectly! The reason I came up with that is because when trying to figure out how to calculate the vectors, I craved some kind of extra point that would sit at a right angle of the joint to help me get the twist of the joint at least, and then I almost gave myself a concussion with an epic facepalm when I realised I needed to think out of the box, or rather, out with a box! The orientations are all there IN the scene, just get another actor to do the work for you.

    Anyway, this also works with the point at feature. I've basically managed to find a way to bake the essential kParmCodeROT keyframes individually, per frame, without baking every single bloody f&^$g parameter like Poser currently does, and therefore get the JCMs to update. It also kind of works with limits on, in that the hands don't skip to wild positions like they used to, provided that they've not gone beyond their limits. I've now expanded the script to do a range of frames and a selection of bodyparts to update.

    It doesn't work with constraints, but that's ok because I've also got a script planned that will get a bodypart to follow something else relative to its original position for an x number of frames. No need for those cumbersome constraints anymore, they were freaking annoying anyway.

    I don't think this script would be practical to run live with callbacks though, so it would just have to be run once people are content with the poses / animations. Would anyone else know how to quickly get those orientations like this? Is it possible to create loose vertices in Poser?

    Let me know if you want the scripts!



  • @erogenesis brilliant, as usual! In a parallel dimension, the latest iOS update has forced me to abandon my most cherished procrastinatio.. err... puzzle apps. The first replacement I found which met my exacting requirements for boredom allevia... err... intellectual stimulation, was Kami 2 (never having given Kami 1 more than a dismissive glance). Not just a "learn the rules/tricks and then grind, grind, grind" kind of puzzle, but one that really challenged me to think in different ways. Then, hopefully, one has an epiphany and the problem gets solved.

    Your solution strikes me as one that might also be applicable to the issue of using point-at with deformers. As in, the deformer prop obeys the point-at operation, but its subsequent orientation is not applied to its rotation parameters and hence has no effect on the objects it is deforming. I was hoping to use that ages ago for gravity simulations on un-articulated hair props. All of that was rendered semi-redundant by Poser 11's new constraint and grouping objects, though setting up keyframed and mutual constraints still seems to take a lot of planning to implement effectively.

    Waiting with breath abated... [BSOD in three, two, ...]



  • @erogenesis in relation to loose vertices, I believe that the wavefront OBJ format defines elements such as points, lines and facets. Poser typically only uses facets. I have some suspicion that I've read of someone trying to use hair props defined as OBJ lines in the hope they could improve upon the Hair Room's "Murder in the dressing room" results.

    I haven't tried yet, to see if it will import such objects. Shouldn't take too much to do so, though. just define a single "v x y z" vertex and a single "p 1" point element, IIRC.

    Yep:

    # Poser Point OBJ test file "point.obj"
    v 0 0.1 0
    p 1
    
    Welcome to the Poser Python shell.
    Python 2.7.1 (r271:33999, Jul 29 2017, 03:36:47) [MSC v.1800 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> scene = poser.Scene()
    >>> point = scene.CurrentActor()
    >>> geom = point.Geometry()
    >>> geom.NumVertices()
    1
    >>> point.Name()
    u'point'