0

When improving shot framing, I often want to move a camera by a certain "percent." I realize that "percent" can be arbitrary when you aren't sure where the camera is positioned to begin with, but it's more meaningful to the customer to talk in percents rather than units (e.g. "Push in 10%")

In Maya's python libraries, I see the camera and dolly commands, but not a built-in way to move the camera a fraction of its current position. What is the most elegant way to approach this?

AteYourLembas
  • 303
  • 3
  • 12

2 Answers2

0

Here is my sample solution for a push-in of 10%, which is in no way elegant:

import maya.cmds as cmds
import maya.mel as mm

currentPosition = cmds.camera("MyCameraShape", q=True, coi=True)
desiredPosition = float(currentPosition) - (currentPosition * (float(pushPercent) / 100.0) )
cmds.dolly('MyCameraShape', absolute=True, distance=desiredPosition)

My understanding is I want absolute=True because I want to preserve my coi (center of interest).

AteYourLembas
  • 303
  • 3
  • 12
0

This is fine for the application you're describing. The math is simpler if you just use decimals:

def push_pct (cameraShape, amt):
  ''' where .1 = in 10%, -.1 = out 10%, etc'''
  cmds.dolly(cameraShape, abs = True, d =  (1 - amt) * cmds.camera(cameraShape, q=True, coi=True))
theodox
  • 12,028
  • 3
  • 23
  • 36