Difference between revisions of "IC Python API:Spring Joints"

From Reallusion Wiki!
Jump to: navigation, search
m (main.py)
m (Usage Instructions)
 
(16 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
== Demo Video ==
 
== Demo Video ==
 +
 +
{{#evt:
 +
service=youtube
 +
|id=https://www.youtube.com/watch?v=Yg5CcQg7RQo&feature=emb_logo
 +
}}
  
 
== Description ==
 
== Description ==
  
Spring bones allows you to apply spring physics to designated bones in the scene.  The spring effect is calculated using an algorithm that takes into account several physics elements such as stiffness, bounciness, and damping.  This script is versatile and can turn any existing bone or prop hierarchy into an active physics spring chain.  You can also create a prop chain by attaching various props together and apply spring physics using this plugin.
+
Spring Joints allows you to apply spring physics to designated bone and prop hierarchies in the scene.  The spring effect is calculated using an algorithm that takes into account several physics elements such as stiffness, bounciness, and damping.  This script is versatile and can turn any existing bone or prop hierarchy into an active physics spring chain.  You can also create a prop chain by attaching various props together and apply spring physics using this plugin.
 +
 
 +
{{Duo_Illustration
 +
|Ic_python_api_spring_bones_01.png|iClone's native spring implementation acts like a lagging chain.|
 +
|Ic_python_api_spring_bones_02.png|Spring Bones script also takes into account joint rotations.
 +
}}
  
 
== Course Prerequisites ==
 
== Course Prerequisites ==
Line 16: Line 26:
 
!Purpose
 
!Purpose
 
|-
 
|-
|
+
|[[ iC_Python_API:Transform_Math | Transform Math ]]
|
+
|Access recipes for 3D transformational math dealing with spatial calculations.
 
|-
 
|-
|
+
|[[ iC_Python_API:Rotation_Math | Rotation Math ]]
|
+
|Access recipes for 3D rotational math dealing with spatial calculations.
 
|-
 
|-
|
+
|[[ iC_Python_API:Error_Handling | Error Handling ]]
|
+
|Learn to handle and debug show-stopping errors in code.
 
|-
 
|-
|
+
|[[ iC_Python_API:Handling_Time | Handling Time ]]
|
+
|Learn to manage complex timeline features by making a special re-usable class.
 
|-
 
|-
|
+
|[[ iC_Python_API:Basic_Math | Basic Math ]]
|
+
|Access recipes for basic mathematics for common numerical operations.
 
|}
 
|}
  
Line 42: Line 52:
  
 
*Sample project.
 
*Sample project.
*Spring bones Python script.
+
*Spring Joints Python script.
*Extensions Python script.
+
*Spring Extensions Python script.
 +
 
 +
You can download this plugin from the [https://marketplace.reallusion.com/spring-joints Reallusion Marketplace].
 +
 +
To acquire and view the source code, please visit [https://github.com/reallusion/iClone/tree/master/SpringJoints Reallusion GitHub].
  
 
== Usage Instructions ==
 
== Usage Instructions ==
  
#Load or create a scene with Props attached in a required order.
+
#Clone or download the Reallusion/iClone GitHub.
#Move and/or rotate the objects around the scene.
+
#Copy '''SpringJoints''' folder into the iClone install directory > '''...\Bin64\OpenPlugin'''. 
#Load the Spring Bones script and select the desired joints in the Bones tree list view.
+
#Load the script into the project from the menu: '''Plugins > Python Samples > Spring Joints'''.
 +
#Load or create a scene with Props attached in a hierarchical order.
 +
#Load the '''Spring Bones''' script and select the desired joints in the Bones tree list view.
 
#Adjust the '''Stiffness''', '''Bounciness''', and '''Dampness''' settings:
 
#Adjust the '''Stiffness''', '''Bounciness''', and '''Dampness''' settings:
 
#*'''Stiffness''': how rigid are the joints?
 
#*'''Stiffness''': how rigid are the joints?
Line 95: Line 111:
 
* [[ IC_Python_API:RLPy_RTime#IndexedFrameTime | RLPy.RTime.IndexedFrameTime() ]]
 
* [[ IC_Python_API:RLPy_RTime#IndexedFrameTime | RLPy.RTime.IndexedFrameTime() ]]
 
* [[ IC_Python_API:RLPy_RVector3 | RLPy.RVector3() ]]
 
* [[ IC_Python_API:RLPy_RVector3 | RLPy.RVector3() ]]
* [[ IC_Python_API:RLPy_RVector3 or type | RLPy.RVector3 or type() ]]
 
 
* [[ IC_Python_API:RLPy_RScene#FindObjects | RLPy.RScene.FindObjects() ]]
 
* [[ IC_Python_API:RLPy_RScene#FindObjects | RLPy.RScene.FindObjects() ]]
 
</div>
 
</div>

Latest revision as of 03:29, 11 March 2020

Main article: RL Python Samples.

Demo Video

Description

Spring Joints allows you to apply spring physics to designated bone and prop hierarchies in the scene. The spring effect is calculated using an algorithm that takes into account several physics elements such as stiffness, bounciness, and damping. This script is versatile and can turn any existing bone or prop hierarchy into an active physics spring chain. You can also create a prop chain by attaching various props together and apply spring physics using this plugin.

  • iClone's native spring implementation acts like a lagging chain.
  • Spring Bones script also takes into account joint rotations.

Course Prerequisites

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

Link Purpose
Transform Math Access recipes for 3D transformational math dealing with spatial calculations.
Rotation Math Access recipes for 3D rotational math dealing with spatial calculations.
Error Handling Learn to handle and debug show-stopping errors in code.
Handling Time Learn to manage complex timeline features by making a special re-usable class.
Basic Math Access recipes for basic mathematics for common numerical operations.

Takeaway Lessons

  • Apply spring physics to bones or attached props.
  • Create a tree list view to represent bone hierarchies.
  • Update UI by receiving callback events.
  • Using Timer events.

Required Files

  • Sample project.
  • Spring Joints Python script.
  • Spring 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 SpringJoints folder into the iClone install directory > ...\Bin64\OpenPlugin.
  3. Load the script into the project from the menu: Plugins > Python Samples > Spring Joints.
  4. Load or create a scene with Props attached in a hierarchical order.
  5. Load the Spring Bones script and select the desired joints in the Bones tree list view.
  6. Adjust the Stiffness, Bounciness, and Dampness settings:
    • Stiffness: how rigid are the joints?
    • Bounciness: how likely will the joints swing back and forth?
    • Dampness: how fast do the joints come to a complete stop?
  7. You could use the [Start Simulation] button to test the spring parameters and using[Stop Simulation] to stop it.
  8. After you are satisfied with your settings, click the [ Apply Setting ] button and watch the bone chain swing around as the objects moves.
  9. You could use [Clear Key] to remove the result.

Code Flow

Ic python api spring bones 03.png

APIs Used

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

main.py

Extensions.py