Thread: how to apply corner pin to a paint stroke

Reply to Thread
Results 1 to 12 of 12
  1. #1 how to apply corner pin to a paint stroke 
    Join Date
    Oct 2008
    Posts
    334
    Hi, Does anyone know if it's possible to apply corner pin to paint stroke (NOT paint node)? So instead of transforming the resulting paint, i actually want to transform the stroke itself (not the resulting paint). This kind like inserting the 'modifier' to the stroke BEFORE the actual painting is proceeded (not AFTER).
    In the transform tab in paint node, there's no option to apply corner pin. Any idea ?

    Thanx
    Last edited by metaclay; July 21st, 2012 at 02:53 AM.
    Reply With Quote  

  2. #2  
    Join Date
    Jun 2009
    Location
    Singapore
    Posts
    536
    No idea...
    but I thought it might be possible using the extra matrix function in the transform tab of the Rotopaint transforms node.
    But I couldn't find a way to get the matrix from the cornerpin.
    I just stumbled on this though...
    http://forums.thefoundry.co.uk/phpBB...df0d2a95643aa0
    My idea is to use this information to get a 4x4 matrix from the cornerpin and apply it to the rotopaint...
    No idea if it will work - just an idea.

    I'll probably give it a go when I have some free time.
    let me know if you have any success with it.
    Process; Compute: Situation = Unacceptable; /// > Compute: Solution ... > Locating File: Understanding.exe... > ERROR: File not found /// > ... ... ... System = Crashing Process; Load: Default File; ... > Locating File: Rage.exe... > File Found /// > Executing
    Reply With Quote  

  3. #3 cornerPin as a Matrix 
    Join Date
    Jul 2007
    Location
    Munich. Germany
    Posts
    222
    this will convert your cornerPin animation to extraMatrix
    you can put it later on your rotopaint
    Hope, that is what you need.

    Code:
    import nuke
    def getTheCornerpinAsMatrix():
         # Original script by Pete O'Connell extended by Alexey Kuchinsky to loop the script over a frame range.
         projectionMatrixTo = nuke.math.Matrix4()
         projectionMatrixFrom = nuke.math.Matrix4()
    
         #dir(projectionMatrix)
         theCornerpinNode = nuke.selectedNode()
         theNewCornerpinNode = nuke.createNode("CornerPin2D")
         theNewCornerpinNode['transform_matrix'].setAnimated()
    
         imageWidth = float(theCornerpinNode.width())
         imageHeight = float(theCornerpinNode.height())
    
         first = nuke.Root().knob('first_frame').getValue()
         first = int(first)
         last = nuke.Root().knob('last_frame').getValue()
         last = int(last)+1
         frame = first
         while frame<last:
             to1x = theCornerpinNode['to1'].valueAt(frame)[0]
             to1y = theCornerpinNode['to1'].valueAt(frame)[1]
             to2x = theCornerpinNode['to2'].valueAt(frame)[0]
             to2y = theCornerpinNode['to2'].valueAt(frame)[1]
             to3x = theCornerpinNode['to3'].valueAt(frame)[0]
             to3y = theCornerpinNode['to3'].valueAt(frame)[1]
             to4x = theCornerpinNode['to4'].valueAt(frame)[0]
             to4y = theCornerpinNode['to4'].valueAt(frame)[1]
        
             from1x = theCornerpinNode['from1'].valueAt(frame)[0]
             from1y = theCornerpinNode['from1'].valueAt(frame)[1]
             from2x = theCornerpinNode['from2'].valueAt(frame)[0]
             from2y = theCornerpinNode['from2'].valueAt(frame)[1]
             from3x = theCornerpinNode['from3'].valueAt(frame)[0]
             from3y = theCornerpinNode['from3'].valueAt(frame)[1]
             from4x = theCornerpinNode['from4'].valueAt(frame)[0]
             from4y = theCornerpinNode['from4'].valueAt(frame)[1]
        
             projectionMatrixTo.mapUnitSquareToQuad(to1x,to1y,to2x,to2y,to3x,to3y,to4x,to4y)
             projectionMatrixFrom.mapUnitSquareToQuad(from1x,from1y,from2x,from2y,from3x,from3y,from4x,from4y)
             theCornerpinAsMatrix = projectionMatrixTo*projectionMatrixFrom.inverse()
             theCornerpinAsMatrix.transpose()
           
             a0 = theCornerpinAsMatrix[0]
             a1 = theCornerpinAsMatrix[1]
             a2 = theCornerpinAsMatrix[2]
             a3 = theCornerpinAsMatrix[3]    
             a4 = theCornerpinAsMatrix[4]
             a5 = theCornerpinAsMatrix[5]
             a6 = theCornerpinAsMatrix[6]
             a7 = theCornerpinAsMatrix[7]   
             a8 = theCornerpinAsMatrix[8]
             a9 = theCornerpinAsMatrix[9]
             a10 = theCornerpinAsMatrix[10]
             a11 = theCornerpinAsMatrix[11]    
             a12 = theCornerpinAsMatrix[12]
             a13 = theCornerpinAsMatrix[13]
             a14 = theCornerpinAsMatrix[14]
             a15 = theCornerpinAsMatrix[15]
        
             theNewCornerpinNode['transform_matrix'].setValueAt(a0,frame,0)
             theNewCornerpinNode['transform_matrix'].setValueAt(a1,frame,1)
             theNewCornerpinNode['transform_matrix'].setValueAt(a2,frame,2)
             theNewCornerpinNode['transform_matrix'].setValueAt(a3,frame,3)    
             theNewCornerpinNode['transform_matrix'].setValueAt(a4,frame,4)
             theNewCornerpinNode['transform_matrix'].setValueAt(a5,frame,5)
             theNewCornerpinNode['transform_matrix'].setValueAt(a6,frame,6)
             theNewCornerpinNode['transform_matrix'].setValueAt(a7,frame,7)    
             theNewCornerpinNode['transform_matrix'].setValueAt(a8,frame,8)
             theNewCornerpinNode['transform_matrix'].setValueAt(a9,frame,9)
             theNewCornerpinNode['transform_matrix'].setValueAt(a10,frame,10)
             theNewCornerpinNode['transform_matrix'].setValueAt(a11,frame,11)
             theNewCornerpinNode['transform_matrix'].setValueAt(a12,frame,12)
             theNewCornerpinNode['transform_matrix'].setValueAt(a13,frame,13)
             theNewCornerpinNode['transform_matrix'].setValueAt(a14,frame,14)
             theNewCornerpinNode['transform_matrix'].setValueAt(a15,frame,15)
             frame = frame + 1
    Last edited by lamakaha; August 6th, 2012 at 05:15 AM.
    Reply With Quote  

  4. #4  
    Join Date
    Oct 2008
    Posts
    334
    @Lamakaha : the script is very COOL!! i can use it without problem. Thanx a lot for sharing.
    @invader777 : i somehow found this another trick , for me the fastest way is using lamakaha's script. But i found this trick just for fun , i use a 'ready' to use object in nuke. Let say we have the data of corner pin already (from nuke or mocha) then we need to do re-tracking in nuke using planar tracker (not retracking raw material but i mean retracking using the available corner pin data so we don't have to re-deal again with some existing tracking problem) . The purpose of this 're-tracking' is that the planar tracker will generate the matrix we need. So all i need to do is copying/link the matrix and use it inside the roto paint 'transform' tab.

    Thanx

    --smiley is broken--

    Last edited by metaclay; July 22nd, 2012 at 10:16 PM.
    Reply With Quote  

  5. #5  
    Join Date
    Dec 2008
    Location
    Leeds, UK
    Posts
    69
    Hey guys!

    This seems cool, my only problem is that I couldn't get it to work... what exactly you do? I have an animated Cpin, I select the node and run the script in the script editor, but nothing seems to happen... what should I do?

    Thank
    Reply With Quote  

  6. #6  
    Join Date
    Oct 2008
    Posts
    334
    Quote Originally Posted by verdesmeraldo View Post
    Hey guys!

    This seems cool, my only problem is that I couldn't get it to work... what exactly you do? I have an animated Cpin, I select the node and run the script in the script editor, but nothing seems to happen... what should I do?

    Thank
    if you copy that script , that only define the function() . So to make it works, you also need to call the function.
    So at the bottom after that script , add this line :
    getTheCornerpinAsMatrix()

    Select cpin node, run the new modified script, you'll get a new cpin (duplicate but with matrix is set already).
    Reply With Quote  

  7. #7  
    Join Date
    Dec 2008
    Location
    Leeds, UK
    Posts
    69
    Cheers guys! ;o)
    Reply With Quote  

  8. #8 one click now :) 
    Join Date
    Jul 2007
    Location
    Munich. Germany
    Posts
    222
    just finished one click solution
    select cornerPin node, execute a code
    and you will have ready to go roto node with all animation inside

    .......ha ha ha ! just realized that this one is just working when you already have extra matrix animation, so this one just copying animation from Cornerpin matrix to Roto matrix, you can easily combine both codes to get it to work in one click.
    Initially coded it for this one.
    will be included in V5.0 in few days.


    Code:
    def cornerToPaint():
        # Original script by Pete O'Connell extended by Alexey Kuchinsky to loop the script over a frame range.
        import nuke
        first = nuke.Root().knob('first_frame').getValue()
        first = int(first)
        last = nuke.Root().knob('last_frame').getValue()
        last = int(last)+1
        frame = first
        
        cor = nuke.selectedNode()
        Roto = nuke.createNode('Roto')
        Knobs = Roto['curves']
        root=Knobs.rootLayer
        transform = root.getTransform()
           
        while frame<last:
    
            cm0 = cor['transform_matrix'].getValueAt(frame,0)
            cm1 = cor['transform_matrix'].getValueAt(frame,1)
            cm2 = cor['transform_matrix'].getValueAt(frame,2)
            cm3 = cor['transform_matrix'].getValueAt(frame,3)
            cm4 = cor['transform_matrix'].getValueAt(frame,4)
            cm5 = cor['transform_matrix'].getValueAt(frame,5)
            cm6 = cor['transform_matrix'].getValueAt(frame,6)
            cm7 = cor['transform_matrix'].getValueAt(frame,7)
            cm8 = cor['transform_matrix'].getValueAt(frame,8)
            cm9 = cor['transform_matrix'].getValueAt(frame,9)
            cm10 = cor['transform_matrix'].getValueAt(frame,10)
            cm11 = cor['transform_matrix'].getValueAt(frame,11)
            cm12 = cor['transform_matrix'].getValueAt(frame,12)
            cm13 = cor['transform_matrix'].getValueAt(frame,13)
            cm14 = cor['transform_matrix'].getValueAt(frame,14)
            cm15 = cor['transform_matrix'].getValueAt(frame,15)
            
            matr = transform.getExtraMatrixAnimCurve(0,0) 
            matr.addKey(frame,cm0)  
            matr = transform.getExtraMatrixAnimCurve(0,1) 
            matr.addKey(frame,cm1)  
            matr = transform.getExtraMatrixAnimCurve(0,2) 
            matr.addKey(frame,cm2)  
            matr = transform.getExtraMatrixAnimCurve(0,3) 
            matr.addKey(frame,cm3)  
            matr = transform.getExtraMatrixAnimCurve(0,4) 
            matr.addKey(frame,cm4)  
            matr = transform.getExtraMatrixAnimCurve(0,5) 
            matr.addKey(frame,cm5)  
            matr = transform.getExtraMatrixAnimCurve(0,6) 
            matr.addKey(frame,cm6)  
            matr = transform.getExtraMatrixAnimCurve(0,7) 
            matr.addKey(frame,cm7)  
            matr = transform.getExtraMatrixAnimCurve(0,8) 
            matr.addKey(frame,cm8)  
            matr = transform.getExtraMatrixAnimCurve(0,9) 
            matr.addKey(frame,cm9)  
            matr = transform.getExtraMatrixAnimCurve(0,10) 
            matr.addKey(frame,cm10)  
            matr = transform.getExtraMatrixAnimCurve(0,11) 
            matr.addKey(frame,cm11)  
            matr = transform.getExtraMatrixAnimCurve(0,12) 
            matr.addKey(frame,cm12)  
            matr = transform.getExtraMatrixAnimCurve(0,13) 
            matr.addKey(frame,cm13)  
            matr = transform.getExtraMatrixAnimCurve(0,14) 
            matr.addKey(frame,cm14)  
            matr = transform.getExtraMatrixAnimCurve(0,15) 
            matr.addKey(frame,cm15)                 
            frame = frame+1
    Last edited by lamakaha; August 6th, 2012 at 05:15 AM.
    Reply With Quote  

  9. #9  
    Join Date
    Dec 2008
    Location
    Leeds, UK
    Posts
    69
    Mmm... think I need to learn python can't get it to work... thanks guys for sharing though!
    Reply With Quote  

  10. #10  
    Join Date
    Aug 2010
    Posts
    74
    Hi lamakaha,

    thanks for posting that code. I've been looking for a way to access the matrix on a roto-paint node layer, and in your example you use getExtraMatrixAnimCurve, which I haven't seen before. However when I try to use it Nuke tells me:

    '_curvelib.AnimCTransform' object has no attribute 'getExtraMatrixAnimCurve'

    Any idea what this is? I'm on Nuke 6.3. Thanks.
    Reply With Quote  

  11. #11  
    Join Date
    Jul 2007
    Location
    Munich. Germany
    Posts
    222
    Sorry, but i need more info,
    1 what exactly you trying to do
    2 which code from those two you running
    maybe you need read again about - what exactly each one is doing, this post (mine)is quite messy : )


    About the code, i also was for very long time trying to find the way to Roto Python, and i can recomend you to have a look on this page, where Doodle explaining about this
    And on my final code where i am using his tips.
    Cheers : )
    Last edited by lamakaha; July 30th, 2012 at 04:50 AM.
    Reply With Quote  

  12. #12  
    Join Date
    Aug 2010
    Posts
    74
    Hi,

    I looked again and found that getExtraMatrixAnimCurve is availible in Nuke 6.3v8 ! Thanks for your example code!
    Reply With Quote  

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 1
    Last Post: May 8th, 2010, 12:23 PM
  2. Frame Range Visibility per Paint Stroke
    By shaneholloman in forum NUKE from The Foundry
    Replies: 0
    Last Post: July 10th, 2009, 05:13 PM
  3. Changing paint stroke order/timing
    By Ol' Kentucky Shark in forum NUKE from The Foundry
    Replies: 0
    Last Post: February 4th, 2009, 07:05 PM
  4. pixels when apply a corner pin
    By rox in forum NUKE from The Foundry
    Replies: 2
    Last Post: July 29th, 2008, 08:38 PM
  5. can this be apply to
    By dash1969 in forum Beginners Talk
    Replies: 1
    Last Post: May 4th, 2004, 01:12 PM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts