X-Mirror / Invert Clip Script


https://forum.reallusion.com/Topic459858.aspx
Print Topic | Close Window

By 4u2ges - 4 Years Ago
I actually have 2 scripts to present. They both are based on Pose Manager plugin script, but they work differently.
Both have about 99% mirror/invert precision. Both are slow (thought second script is twice as fast compare to first).

The problem I was facing here is with Set and Get data. Get data works with Scene time, Set data works with Clip Time.
Conversion Time to Frame and vice versa (which requires an extreme precision in this case), goes out of wack.
You guys may take a look at it and see if you can facilitate routines and make it faster. I did my best to make it working.

Before running scripts make sure to check every option in Animation > Motion Settings Options.

Invert_Clip.py - Mirrors the clip from one avatar to another.
* You have to have 2 avatars in the scene (spread them apart by X for best visual).
* Make sure avatars do not have a clips at frame 1. By default they do. So delete clip at first frame.
* Open script in an editor and specify 2 avatar names at the top. You may change clip_step from 1 to 2, or 3.
   Higher number makes the script to run faster. Number indicates how frequently to insert a clip. 1 - every frame, 2 every second frame, etc.
   Experiment to see if the high number of steps is acceptable for your clip.
* Add a clip to the avatar you specified first (clip does not have to start at frame 1)
* Load script and wait Whistling (go have a coffee or something...) With clip_step = 1, 10 seconds clip would take about 4 minutes to mirror.

At the end the second avatar should be assigned a mirrored clip for every frame (if clip_step = 1)
DO NOT attempt to merge those clips, nor Flatten them (that would invalidate them). Use Collect Clip and Add Motion to Library.
What interesting about this method is, that at the end, Mirrored clips are 100% match the original (you may use Orthogonal camera to verify).
However, when you use Collect Clip, save and add the resulted clip back to the timeline, there is a barely noticeable mismatch (no idea why...).

Invert_Clip2.py - creates a Mirrored clip to the right from the original for the same avatar.
* Load an avatar and delete a clip at frame 1.
* Optional: Open script in an editor and change clip_step value.   
   Higher number makes the script to run faster. Number indicates how frequently to insert a frame into the inverted clip. 1 - every frame, 2 every second frame, etc.
   Experiment to see if the high number of steps is acceptable for your clip. clip_offset specifies how far apart should mirrored clip be located from the original (default is 20 frames).
* Add a clip to the avatar (clip does not have to start at first frame).  Important: make sure you have enough frames at the timeline for the mirrored clip.
* Make sure avatar is selected, load script and wait. This one is faster. 10 sec clip mirrored in about 1.5 minute with clip_step = 1
At the end a single mirrored clip should be created to the right from the original. As with first script, DO NOT attempt to flatten mirrored clip. You may use Collect Clip and Add to Motion Library.
Or save the clip, add it back to the timeline, Now you may flatten it and save again.
This script is also produces a mirrored clip with barely noticeable difference for the original.

Here is a video for creating invert clip with Invert_Clip2.py (I cut out the script running time)



Feel free to comment, ask questions, customize / modify / add UI, or write your own script/plugin and share.




Update: Invert_CLip2.py was updated to force Avatar selection. If you did not select an Avatar you would get a friendly reminder.
By wires - 4 Years Ago
Brilliant work again Gurgen, now all that we need is a Nobel Prize for iClone tip creators. CoolSmooooth
By 4u2ges - 4 Years Ago
https://forum.reallusion.com/uploads/images/ccb41ad6-62fd-441f-94a1-242b.png
By Rampa - 4 Years Ago
Great work Gurgen! Smile

I am happy to see this finally get a method inside iClone.
By 4u2ges - 4 Years Ago
Thanks Rampa Smile
By Rampa - 4 Years Ago
Is it quick and easy to add some code to automatically grab the character name, for the second version? That way only the step value would ever need changing, and we could just go with the defaults, usually.
By 4u2ges - 4 Years Ago
Yes, it sure is. I will update...
By 4u2ges - 4 Years Ago
Updated to have second script to force avatar selection.
By Kelleytoons - 4 Years Ago
Glad you did this, Mr. G, sure saves me (to show you how little time I have right now, I can't even check this out.  Perhaps in a week or two).
By Rampa - 4 Years Ago
Works pretty great! Smile That has been wanted for a long time.
By John From Oz - 4 Years Ago
Brilliant! Thankyou so much!! ๐Ÿ‘๐Ÿ‘ Can't tell you how many times I've wanted this feature!
By 4u2ges - 4 Years Ago
Thank you folks, I am happy myself, that this is finally possible  w00t Laugh
By GrannyJ - 4 Years Ago
Great job, Gurgen!  And a sincere thank you for sharing it with the community! Well done 
By toystorylab - 4 Years Ago
Wow, that's great! w00t

EDIT this statement is no longer valid!
Took "Invert_Clip2.py" to test and was not sure were to put avatar name.
Then checked "Invert_Clip.py". Here it is obvious where to put the name(s)...

So for those like me who are not sure where to put avatar name in "Invert_Clip2.py"

use phrase:
source_Avatar_name  = "your avatar name"

and put it on top of clip_step = 1

Simply add a character and motion and use the script...

Thanx so much for sharing, Gurgen!
https://forum.reallusion.com/uploads/images/1c36326b-a440-4fd3-a286-8228.png

By 4u2ges - 4 Years Ago
Thank you GrannyJ Smile

No, no, no Toystory! You do not have to change anything anymore in "Invert_Clip2.py"
As per Rampas' request I have update the script and have it run against any avatar selected in Scene Manager.
I will change line in the instruction. Thanks. and sorry for confusion... Blush

By toystorylab - 4 Years Ago
4u2ges (10/9/2020)
Thank you GrannyJ Smile

No, no, no Toystory! You do not have to change anything anymore in "Invert_Clip2.py"
As per Rampas' request I have update the script and have it run against any avatar selected in Scene Manager.
I will change line in the instruction. Thanks. and sorry for confusion... Blush


Oh cool!
Tried it and worked fine...
Changed my comment to prevent further confusion Wink
Thanx!
By rosuckmedia - 4 Years Ago
@4u2ges
That's great,
Many Thanks.SmileSmile
Best regards rosuckmedia

By 4u2ges - 4 Years Ago
@rosuckmedia, @toystorylab
Thanks guys for checking it out Smile
By mark - 4 Years Ago
I knew you could do it!!! :But I deserve something for waiting soooooo patiently TongueTongueTongueTongue

Now....what about that mirror????w00tBigGrinBigGrinTongueTongue

By Hewa' s Art - 4 Years Ago
@4u2ges
That's great,
SmileSmile
Thanks for sharing!
By davidmaximo - 4 Years Ago
You sir, are a king


THANK YOU
By mikahawkins - 4 Years Ago
You really are a master of iClone.
By 4u2ges - 4 Years Ago
Thank you guys! I am really happy it all worked out good for you Smile


@Mark
Hmmm.. How about this to try:

    import RLPy
    if iWantMirror is True:
       try:
          reflect()
       finally:
          in_iClone8()

BigGrinLaughw00t
By ahingel - 4 Years Ago
wow amazing
never thought i would need this till i saw it BigGrin
thank you <3 
By 4u2ges - 4 Years Ago
ahingel (10/11/2020)
wow amazing
never thought i would need this till i saw it BigGrin
thank you <3 

No problem Smile
By Cary B - 3 Years Ago
Just discovered this. Have not had a chance to check it out fully, but I am blown away by this. What a great, great asset! I would give this ten stars if I could. Thank you, sir! 
By charly Rama - 3 Years Ago
Woooww. Used it for the first time. Simply simple , quick and work great, no bug, no headache  , You're a king Gurgen, thank you so much. You're so generous. You know, I was ready to buy it , discoverd that it's free. Be blessed man
By 4u2ges - 3 Years Ago
Thanks Charly. I'm glad it helped that many people. Smile
By woody173 - 3 Years Ago
Absolutely brilliant. Exactly what I was looking for. How on earth do you manage to do it is beyond me.
THANKS YOU SO MUCH KEEP UP THE GOOD WORK

By 4u2ges - 3 Years Ago
woody173 (6/5/2021)
Absolutely brilliant. Exactly what I was looking for. How on earth do you manage to do it is beyond me.
THANKS YOU SO MUCH KEEP UP THE GOOD WORK




Thanks Woody. I actually just reverse engineered the Pose Manager plug-in and made a loop over the timeline to mirror pose by pose. Well... if you put it simple. Lots of obstacles were in a way.
By jeremymonroe1 - 3 Years Ago
Thankyou for working on this kind sir!  Works great
By 4u2ges - 3 Years Ago
No problem. Glad, it worked out for you well Smile
By dpolcino - 3 Years Ago
Brilliant!
By 4u2ges - 3 Years Ago
Thanks Smile