Announcement

Collapse
No announcement yet.

Post translate python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Post translate python

    Is there a way to calculate the distance of an object to the rendering camera within a post translate python script?

    I want to calculate the distance to an object and save that value into a metadata field of the rendered exr file.
    Then I can use that value to automagically set the focus distance of the post dof in Nuke.

    Thanks
    Andreas
    http://www.andreas-reimer.de
    http://www.renderpal.com
    my HDRI and texture collection

  • #2
    If you know the name of the exported Node plugin in the V-Ray scene, you can take its transformation matrix and from there you can take the position of the object. You can do the same for the "Render View" plugin, from where you can figure out the distance between the two.

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      Actually I am nearly done. The only thing left is getting the position of my object that has to get into v2.

      import maya.cmds as cmds
      import pymel.core as pm
      from vray.utils import *

      distances=[]

      pc = pm.xform( 'camname', q=True, translation=True, ws=True)
      v1 = pm.datatypes.Vector(pc[0],pc[1],pc[2])
      v2 = pm.datatypes.Vector(0,0,0)
      distances.append( v1.distanceTo(v2))

      l=findByName("vraySettingsEXR")
      zNode=findByType('RenderChannelZDepth')
      zFactor = zNode[0].get('depth_black')

      l[0].set('extra_attributes',("targetDistance=%s; zfactor=%s" % (max(distances),zFactor)) )
      http://www.andreas-reimer.de
      http://www.renderpal.com
      my HDRI and texture collection

      Comment


      • #4
        If you are using the nightlies, you can directly call a python or mel function to calculate the attribute. For distance, you even have Maya node. Here is a scene:

        distance_test.zip

        pSphere1 has temp and temp2 attributes that calculates the distance in two different ways.
        V-Ray/PhoenixFD for Maya developer

        Comment


        • #5
          Cool thanks. Will have a look into that.
          http://www.andreas-reimer.de
          http://www.renderpal.com
          my HDRI and texture collection

          Comment

          Working...
          X