Difference between revisions of "IC Python API:Smooth Camera Follow"

From Reallusion Wiki!
Jump to: navigation, search
m
m (Steps to Take)
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}
+
{{Parent|IC_Python_API#Python_of_the_Month|Python of the Month}}
  
== Smooth Camera Follow ==
+
== Demo Video ==
 +
 
 +
{{#evt:
 +
service=youtube
 +
|id=https:www.youtube.com/watch?v=tLMSRrxa8Is&feature=youtu.be
 +
}}
 +
 
 +
== Description ==
  
 
This script lets the user pick a camera/view and a prop/target to follow.  The camera will always be facing the direction of the target prop with delay as an adjustable factor. The Offset values creates a distance between the view and the target.  Use the Delay value to create a lag between the view and the target.
 
This script lets the user pick a camera/view and a prop/target to follow.  The camera will always be facing the direction of the target prop with delay as an adjustable factor. The Offset values creates a distance between the view and the target.  Use the Delay value to create a lag between the view and the target.
  
=== Learn How to ===
+
{{Single_Illustration|Smooth_Camera_Follow_Diagram.png|As the target prop starts to move, the camera will begin to follow with a specified delay.  However, the camera's facing direction will always be locked onto the prop's pivot point no matter how fast the prop is moving.}}
* Drive the motion of the camera according to the animation of a prop.
+
 
 +
== Course Prerequisites ==
 +
 
 +
You should be familiarize yourself with the following fundamental articles before you proceed:
 +
 
 +
*[[ iC_Python_API:List_All_Props | List All Props ]]
 +
*[[ iC_Python_API:Look_At | Look At ]]
 +
*[[ iC_Python_API:Transformation_Key | Transformation Key]]
 +
*[[ iC_Python_API:Linear_Interpolation| Linear Interpolation]]
 +
*[[ iC_Python_API:Float_Slider| Float Slider ]]
 +
 
 +
== Takeaway Lessons ==
 +
 
 +
* Learn to drive the motion of the camera according to the animation of a prop.
 
* Populate drop down menus/combo boxes with elements from the scene.
 
* Populate drop down menus/combo boxes with elements from the scene.
* Set timer and event callbacks and attach commands.
 
  
=== Required Files ===
+
== Required Files ==
  
 
* iClone scene with camera and animated prop
 
* iClone scene with camera and animated prop
Line 17: Line 36:
 
* Extensions Python script
 
* Extensions Python script
  
=== Code Flow ===
+
You can download this plugin from the [https://marketplace.reallusion.com/smooth-camera-follow Reallusion Marketplace]. 
 +
To acquire and view the source code, please visit [https://github.com/reallusion/iClone/tree/master/SmoothCameraFollow Reallusion GitHub].
  
Given a target prop and a target camera, the script will also require the inputs for the camera movement delay and offset position from the target prop.  The code creates a new movement animation for the camera transformations by applying keys in the timeline.  The final result is a camera that smoothly follows the target prop at the designated offset position with a certain degree of lag time decided by the user.
+
== Usage Instructions ==
  
{{Single_Illustration|Camera_WIKI_Code_Route.png}}
+
# Clone or download the Reallusion/iClone GitHub.
 +
# Copy '''SmoothCameraFollow''' folder into the iClone install directory > '''...\Bin64\OpenPlugin'''. 
 +
# Load the script into the project from the menu: '''Plugins > Python Samples > Smooth Camera Follow'''.
 +
# Follow the instructions in the subsequent dialog window.
  
 +
== Code Flow ==
  
=== Steps to Take ===
+
Given a target prop and a target camera, the script will also require the inputs for the camera movement delay and offset position from the target prop.  The code creates a new movement animation for the camera transformations by applying keys in the timeline.  The final result is a camera that smoothly follows the target prop at the designated offset position with a certain degree of lag time decided by the user.
  
# Unzip the contents of '''Smooth Camera Follow.zip''' into the iClone install directory '''...\Bin64\OpenPlugin'''. 
+
[[File:Camera_WIKI_Code_Route.png]]
# Load the script into the project from the menu: '''Plugins > Python Samples > Smooth Camera Follow'''.
+
 
# Follow the instructions in the subsequent dialog window.
+
== APIs Used ==
 +
 
 +
You can research the following references for the modules deployed in this code.
  
=== Modules Used ===
+
=== main.py ===
====main.py====
+
 
<div style="column-count:4; -moz-column-count:4; -webkit-column-count:4">
 
<div style="column-count:4; -moz-column-count:4; -webkit-column-count:4">
* [[ IC_Python_API:RLPy_REventCallback#__init__ | RLPy.REventCallback.__init__() ]]
 
 
* [[ IC_Python_API:RLPy_RMatrix3 | RLPy.RMatrix3() ]]
 
* [[ IC_Python_API:RLPy_RMatrix3 | RLPy.RMatrix3() ]]
* [[ IC_Python_API:RLPy_REventHandler#UnregisterCallback | RLPy.REventHandler.UnregisterCallback() ]]
 
* [[ IC_Python_API:RLPy_RGlobal#SetTime | RLPy.RGlobal.SetTime() ]]
 
* [[ IC_Python_API:RLPy_RGlobal#GetStartTime | RLPy.RGlobal.GetStartTime() ]]
 
 
* [[ IC_Python_API:RLPy_RQuaternion | RLPy.RQuaternion() ]]
 
* [[ IC_Python_API:RLPy_RQuaternion | RLPy.RQuaternion() ]]
 
* [[ IC_Python_API:RLPy_RTransform | RLPy.RTransform() ]]
 
* [[ IC_Python_API:RLPy_RTransform | RLPy.RTransform() ]]
* [[ IC_Python_API:RLPy_RGlobal#IsPlaying | RLPy.RGlobal.IsPlaying() ]]
+
* [[ IC_Python_API:RLPy_RMath#Ceil | RLPy.RMath.Ceil() ]]
* [[ IC_Python_API:RLPy_RGlobal#GetTime | RLPy.RGlobal.GetTime() ]]
+
* [[ IC_Python_API:RLPy_RGlobal#SetTime | RLPy.RGlobal.SetTime() ]]
* [[ IC_Python_API:RLPy_RMath#Min | RLPy.RMath.Min() ]]
+
* [[ IC_Python_API:RLPy_RGlobal#Stop | RLPy.RGlobal.Stop() ]]
+
* [[ IC_Python_API:RLPy_REventHandler#RegisterCallback | RLPy.REventHandler.RegisterCallback() ]]
+
 
* [[ IC_Python_API:RLPy_RGlobal#Play | RLPy.RGlobal.Play() ]]
 
* [[ IC_Python_API:RLPy_RGlobal#Play | RLPy.RGlobal.Play() ]]
* [[ IC_Python_API:RLPy_RGlobal#GetEndTime | RLPy.RGlobal.GetEndTime() ]]
+
* [[ IC_Python_API:RLPy_RGlobal#Stop | RLPy.RGlobal.Stop() ]]
 +
* [[ IC_Python_API:RLPy_RGlobal#GetStartTime | RLPy.RGlobal.GetStartTime() ]]
 
* [[ IC_Python_API:RLPy_RUi#ShowMessageBox | RLPy.RUi.ShowMessageBox() ]]
 
* [[ IC_Python_API:RLPy_RUi#ShowMessageBox | RLPy.RUi.ShowMessageBox() ]]
 
* [[ IC_Python_API:RLPy_RUi#AddMenu | RLPy.RUi.AddMenu() ]]
 
* [[ IC_Python_API:RLPy_RUi#AddMenu | RLPy.RUi.AddMenu() ]]
Line 53: Line 72:
 
</div>
 
</div>
  
====Extensions.py====
+
=== Extensions.py ===
 +
 
 
<div style="column-count:4; -moz-column-count:4; -webkit-column-count:4">
 
<div style="column-count:4; -moz-column-count:4; -webkit-column-count:4">
 
* [[ IC_Python_API:RLPy_RMath#Abs | RLPy.RMath.Abs() ]]
 
* [[ IC_Python_API:RLPy_RMath#Abs | RLPy.RMath.Abs() ]]
 
* [[ IC_Python_API:RLPy_RVector3 | RLPy.RVector3() ]]
 
* [[ IC_Python_API:RLPy_RVector3 | RLPy.RVector3() ]]
 
* [[ IC_Python_API:RLPy_RQuaternion | RLPy.RQuaternion() ]]
 
* [[ IC_Python_API:RLPy_RQuaternion | RLPy.RQuaternion() ]]
 +
* [[ IC_Python_API:RLPy_RGlobal#GetFps | RLPy.RGlobal.GetFps() ]]
 +
* [[ IC_Python_API:RLPy_RGlobal#GetStartTime | RLPy.RGlobal.GetStartTime() ]]
 +
* [[ IC_Python_API:RLPy_RGlobal#GetEndTime | RLPy.RGlobal.GetEndTime() ]]
 +
* [[ IC_Python_API:RLPy_RTime#GetFrameIndex | RLPy.RTime.GetFrameIndex() ]]
 +
* [[ IC_Python_API:RLPy_RTime#IndexedFrameTime | RLPy.RTime.IndexedFrameTime() ]]
 
* [[ IC_Python_API:RLPy_RScene#FindObjects | RLPy.RScene.FindObjects() ]]
 
* [[ IC_Python_API:RLPy_RScene#FindObjects | RLPy.RScene.FindObjects() ]]
 
</div>
 
</div>

Latest revision as of 20:09, 19 October 2020

Main article: Python of the Month.

Demo Video

Description

This script lets the user pick a camera/view and a prop/target to follow. The camera will always be facing the direction of the target prop with delay as an adjustable factor. The Offset values creates a distance between the view and the target. Use the Delay value to create a lag between the view and the target.

As the target prop starts to move, the camera will begin to follow with a specified delay. However, the camera's facing direction will always be locked onto the prop's pivot point no matter how fast the prop is moving.

Course Prerequisites

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

Takeaway Lessons

  • Learn to drive the motion of the camera according to the animation of a prop.
  • Populate drop down menus/combo boxes with elements from the scene.

Required Files

  • iClone scene with camera and animated prop
  • Smooth Camera Follow Python script
  • Extensions Python script

You can download this plugin from the Reallusion Marketplace. To acquire and view the source code, please visit Reallusion GitHub.

Usage Instructions

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

Code Flow

Given a target prop and a target camera, the script will also require the inputs for the camera movement delay and offset position from the target prop. The code creates a new movement animation for the camera transformations by applying keys in the timeline. The final result is a camera that smoothly follows the target prop at the designated offset position with a certain degree of lag time decided by the user.

Camera WIKI Code Route.png

APIs Used

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

main.py

Extensions.py