Forum: Poser Python Scripting


Subject: Moving morphs between different figures

Cage opened this issue on Dec 20, 2006 · 1232 posts


nruddock posted Sat, 23 December 2006 at 8:26 AM

Quote - If any of the Python wizards are listening, I'm encountering a puzzling error, with which I need at least a logic check, hopefully advice.

When I apply the conversion morph target, I am taking the original morph deltas plus the difference between the 'target' actor's coordinates and the 'source' actor's coordinates.  This creates a morph which then needs to have the same difference subtracted.  Initially, I created a 'difference' morph and set it to negative1.  So I adjusted the code to try to integrate that difference morph.  (see below.)

        a = geom2.Vertex(int(i)) #source
        b = geom1.Vertex(matched) #target
        #adjust the morph delta by the difference between the two source meshes
        diff = (b.X()-a.X(),b.Y()-a.Y(),b.Z()-a.Z())       
        deltaX = (mt[0] + diff[0]) - (b.X()-a.X())
        deltaY = (mt[1] + diff[1]) - (b.Y()-a.Y())
        deltaZ = (mt[2] + diff[2]) - (b.Z()-a.Z())   

And that seems to work... some of the time.  I've favored running tests from V1 to V3.  This code works for that situation.  Going the other way, it causes problems.  The above is what I've had posted in these scripts.  But I had actually intended to subtract (a-b) coords from the (mt+diff) portion.

Umm.  So, my question: what the bloody heck is the math representing a morph dial set to negative1?  I can't seem to get the results to turn out consistently right without going back to adding the compensatory dial and setting it to negative.  There has to be a mathematical expression for this....  I assume I'm just mixed up about the proper formula.

See, I'm really not so bright.  :)  Don't get to hyped up about this, folks.  Cage is struggling with simple things.  😊

Unless I'm mistaken, then what your ending up with is deltaX = mt[0] etc.
If you expand your equations for the deltas you get, e.g. deltaX = mt[0] + b.X() - a.X() - b.X() + a.X()

For a morph set at -1.0, then the calculated delta values should be -mt[0] etc.

HTH