IC Python API:Camera Auto-Focus

From Reallusion Wiki!
Revision as of 22:12, 11 August 2019 by Chuck (RL) (Talk | contribs) (Course Prerequisites)

Jump to: navigation, search
Main article: RL Python Samples.

Demo Video


Auto-Focus can be used to automatically calculate the DOF (Depth of Field) distance and range for the current camera according to the viewing distance of a selected object. This script operates and updates in near real-time.

DOF distance and range is calculated based on the selected object's distance and bounding size. The DOF is recalculated when the selection is changed.

Course Prerequisites

You should familiarize yourself with the following fundamental articles before you proceed:

Takeaway Lessons

  • Calculate single axis distance between two object (useful for finding Z-depth).
  • Create and setting DOF keys on cameras.
  • Create timer and handling timer callbacks.

Required Files

  • Auto-focus Python script
  • iClone scene with select-able props or characters.

Usage Instructions

  1. Clone or download the Reallusion/iClone GitHub.
  2. Copy Auto-Focus folder into the iClone install directory > ...\Bin64\OpenPlugin.
  3. Load the script into the project from the menu: Plugins > Python Samples > Auto-Focus.
  4. Follow the instructions in the subsequent dialog window.

Code Flow

  1. The current viewing camera is the currently driven camera.
  2. The current selection is the DOF target, the first item in multiple selection is designated as the target.
  3. Adjust the parameters such as Auto-Distance and Auto-Range toggle and multiplier.
  4. The z-distance between the target prop from the current viewing camera is calculated.
  5. DOF key is created taking into account the depth distance value and the parameter settings.
  6. The created DOF key is set on the current viewing camera in near real-time.

Ic python api auto focus 01.png

APIs Used

You can research the following references for the APIs deployed in this code.