Here's a Nuke's Python script for creating a camera’s projection matrix and using paint strokes as a texture map. The idea behind it, is to project 3D texture of all objects in the Viewer to screen space through the currently selected camera using paint strokes.
I need to control projected texture's wrapping Width
and Height
via custom knobs
in User tab properties of a Camera
node.
How to do it programmatically?
import nuke
import nukescripts
def paintPoints():
geoNode = nuke.activeViewer().node()
camera = nuke.selectedNode()
if not camera.Class() in ( 'Camera', 'Camera2' ):
nuke.message( 'Por favor, seleccione un nodo de la cámara primera')
return
geoKnob = geoNode['geo']
objects = geoKnob.getGeometry()
if not objects:
nuke.message( 'No se han encontrado geometría en %s' % geoNode.name() )
pts = []
for o in objects:
objTransform = o.transform()
for p in o.points():
worldP = objTransform * nuke.math.Vector4(p.x, p.y, p.z, 1)
pts.append( [worldP.x, worldP.y, worldP.z] )
curvesKnob = nuke.createNode( 'RotoPaint' )['curves']
task = nuke.ProgressTask( 'painting points' )
for i, pt in enumerate( pts ):
if task.isCancelled():
break
task.setMessage( 'painting point %s' % i )
stroke = nuke.rotopaint.Stroke( curvesKnob )
pos = nukescripts.snap3d.projectPoint( camera, pt )
ctrlPoint = nuke.rotopaint.AnimControlPoint( pos )
stroke.append( ctrlPoint )
curvesKnob.rootLayer.append( stroke )
task.setProgress( int( float(i)/len(pts)*100 ) )
答案 0 :(得分:0)
由于Foundry工程师不赞成使用geo
旋钮及其.getGeometry()
方法,因此我们应该改用.getGeometryNodes()
方法。
如果您需要有关go here的更多详细信息,请写下您的问题。
答案 1 :(得分:-1)
以下是向节点添加自定义旋钮的方法。 Nuke Developer Guide中的更多细节和图片。
以下示例将控件添加到模糊节点:
IsNull
b = nuke.nodes.Blur()
k = nuke.Array_Knob("myctrl", "My Control")
b.addKnob(k)
可以替换为.Array_Knob
用于滑块,.WH_Knob
用于复选框。