IC Python API:Blurry Vision
- Main article: RL Python Samples.
This article goes into creating, setting, and keying the DOF settings of the camera with a very simple example script.
Required Modules and Starting Variables
Let's load the standard Reallusion python module and establish variables for the duration of the DOF animation.
import RLPy
start_time = 1
end_time = 3000
DOF Settings
We can start off by retrieving the current DOF settings of the current camera and adjusting some of its settings to simulate a blurry vision effect:SetNearBlurScale and SetFarBlurScale in particular.
current_camera = RLPy.RScene.GetCurrentCamera()
dof = current_camera.GetDOFData()
dof.SetEnable(True) # Activate
dof.SetNearBlurScale(0)
dof.SetFarBlurScale(0)
Keying the Start and End Frames
First, we'll set a key for the start and end time of the animation where the vision starts off and end up clear.
key = RLPy.RKey()
key.SetTime(RLPy.RTime(start_time))
current_camera.AddDofKey(key, dof)
key.SetTime(RLPy.RTime(end_time))
current_camera.AddDofKey(key, dof)
Notice that the same key object is reused with just slight adjustments to time.
Keying the Blurry Mid-state
Now, we can reuse the DOF and key objects with slight adjustments to key the blurry mid-state for the camera.
dof.SetNearBlurScale(2)
dof.SetFarBlurScale(2)
key.SetTime(RLPy.RTime((end_time-start_time) * 0.5))
current_camera.AddDofKey(key, dof)
Now we can play the animation back:
RLPy.RGlobal.Play(RLPy.RTime(start_time), RLPy.RTime(end_time))