Wrestling with the Snake - My Experiments with Python


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

By Kelleytoons - 5 Years Ago
I thought I would start a thread where I'll post my video python tutorials/explanations (they aren't *exactly* instructional, but more the reasoning and process behind my experiments) in iClone.  If nothing more these very short looks might tell people what can and can't be done, or at least give you your own ideas on doing things (and you can easily ignore this entire thread if you like without feeling you are missing something important).

Also, don't look for any UI tips/tricks here -- I couldn't care less about UI (when I was team lead I specifically got folks who were good at that -- I'm a systems programmer and kind of hate UI).  While I might end up having some scripts useful for others, for the most part this is going to be focused on me doing things *I* need to do (again, it might be inspirational or not as the case may be).

To start with I'm going to show my efforts to control rotations of props, for my Robby the Robot character.


By nlprod1 - 5 Years Ago
Although I don't understand a stitch of programming I think that this open programming functionality will benefit many of you skilled cats. Nice to see it being utilized,  thanks for sharing!
By Kelleytoons - 5 Years Ago
Hopefully those of us who do program will generate scripts that will be of use to those who don't -- this very small script, for example, could be used to rotate almost any prop over the course of your animation clip, so if you had radar antenna, or anything that needed regular rotations you could easily adapt this.  But other, more comprehensive and useful scripts will be coming, particular on the second patch (there are a LOT of things we need to be exposed in the API).
By sonic7 - 5 Years Ago

I'm looking forward to viewing this Mike! - in a couple of hours time - when l'll have internet connection at my sister's home. - (currently interstate for 6 weeks) ...
By sonic7 - 5 Years Ago

Brilliant! - Great stuff Mike! - Looks like Python will make many things possible - this conjures up all sorts of ideas in my 'gyros' ...
By TopOneTone - 5 Years Ago
Mike,
Thanks for sharing this, I'll certainly try to follow what you are doing. Right now the coding makes no sense to me and it was hard to instantly recognize what bits you were talking about, but the outcome is impressive and clearly shows the value of learning this stuff.
Cheers,
Tony 
By rollasoc - 5 Years Ago
Thanks Mike, that is a really useful introduction.

My immediate thought was, this would be useful for doing something like animating light panels in space ships.
Kind of like in the mother scene in the first Alien. (and in the proposed iClone Alien - message film)?


https://forum.reallusion.com/uploads/images/45f101f0-6354-4c5f-85c0-019f.jpg

By Kelleytoons - 5 Years Ago
Okay, part two of this, showing how you can emulate step transition curves (useful since we can't currently alter the curves on some things):


By charly Rama - 5 Years Ago
waouh, all this is great, python seems bring many possibilities. bravo Mike
By Warped Reality VFX - 5 Years Ago
Hello, Mike, this is a great example of what I would usually make a library of subroutines for thank you for showing some python.
I am currently using IC 7.2 but this makes me want to update to 7.4.
Just waiting a bit to see how stable it is.
Thank you again.
By Kelleytoons - 5 Years Ago
Thanks to all for the kind words -- it encourages me to keep posting these.

Kevin -- my goal, eventually, is to have a library of such things.  Right now they are very specific to my tasks at hand, and I'm sure very soon now we'll have tons of more generalized scripts that will work for everyone.  I was actually hoping by doing these I'd encourage more people to check it out -- even if you don't know how to code you can put together snippets of other folks' coding and do amazing stuff (and there are lots of folks around to help).

By Warped Reality VFX - 5 Years Ago
I completely agree I will start creating a library to share also, I also have more free popcornfx to put up soon so thanks again I appreciate your videos keep them coming.
Quick question is python compiled or interpreted I ask only for execution speed.
By Rampa - 5 Years Ago
Cool stuff KT!

A library of "helpers" is a great idea. Seeing the process of how create it is very helpful.
By TonyDPrime - 5 Years Ago
I don't know anything about Python and probably never will.
But I do know this-

"Wrestling with the Snake"....!!!!....such a fantastic title to this post
**APPLAUSE***
By Kelleytoons - 5 Years Ago
Python is interpreted.  It's pretty fast, though (like Lua it will process lists extremely fast).  I wouldn't worry (much) about execution speed (even the real time examples they have done work well -- the biggest lag is just going to be iClone itself).
By Warped Reality VFX - 5 Years Ago
Thank you for your quick response, how are you enjoying the iclone 7.4 API and what would you improve on?.
Are there good code snippets and good documentation?
By Kelleytoons - 5 Years Ago
There are two issues: one, we are missing some critical functionality.  Two, the documentation is a bit contradictory (and some examples plain don't work that way).

The first will be fixed -- Luke is working hard and has a real good plan for what is coming.  Even if we just get the first pass (the immediate stuff) I'll be happy.  It will fill in all the gaps there currently exist.

The second is just a matter of working through it, which is why I started this thread.  For my part I will post what I know works, and if others can do the same we won't be reinventing the wheel.  The docs will get cleaned up eventually -- you can never have too much documentation.
By sonic7 - 5 Years Ago

Great Mike! - yes (though not a programmer), I still understand your videos at a 'conceptual level'. It's interesting that the 1st video (rotation of gyros) is *seemingly* a more involved task to achieve (than the lights) - yet the script is more concise. But, (as you pointed out), that's partly to do with having to add extra lines of code for *emulating* the stepping curve. I can grasp that this is necessary because of dealing with current *limitations*. (I don't understand the coding itself - but in any case, (and as Rampa said) creating these 'helpers' is a great idea) ...
By Kelleytoons - 5 Years Ago
By rollasoc - 5 Years Ago
Thanks Mike, (especially for video 2 that implemented the idea I suggested).

I installed python last night and an Pycharm IDE (though over the weekend, I may start using VSCode since I use that at work) or scrap having an IDE and stick to notepad++.
I played throught the first few RL examples and hacked about with them a bit.

So will have a play over the weekend, hopefully.  Have some ideas for some scripts I want to write.



By toystorylab - 5 Years Ago
Thanx for more insight of Python-functionality...
I hope the best and most usefull scripts will find an affordable way (Store) to people like me,
who have no clue about Python (it probably goes beyond my capabilities Wink)...
First of all I would have to install 7.4, not done yet, will wait till I really have to.
By rollasoc - 5 Years Ago
toystorylab (1/11/2019)
who have no clue about Python (it probably goes beyond my capabilities Wink)...

Don't write yourself off just yet.
At work, we had a work experience person in earlier in the year.  He had never programmed before at all.  We gave him a raspberry pi and pointed him at some Python tutorials.  He picked the pi and python up in about a week.
By TonyDPrime - 5 Years Ago
Will a Python 'function' be forever bound to iClone, or is it exportable...
Like - Is a Pythonian animation, like KT created, baked into the timeline, or is it the timeline needs a running Python script to be enacted?
By jlittle - 5 Years Ago
TonyDPrime (1/11/2019)
Will a Python 'function' be forever bound to iClone, or is it exportable...
Like - Is a Pythonian animation, like KT created, baked into the timeline, or is it the timeline needs a running Python script to be enacted?

What KT did was use a python script to create keys in the timeline just as if you manually put them there.
In this case the python script is not needed after you create the keys.

Jeff

By Kelleytoons - 5 Years Ago
ToyStory -- I think you'll be surprised by how many useful scripts folks will just give away for free here.  Honestly, unless someone is going to put out something really fantastic (think something along the lines of Anima 3, for example, or a whole traffic system, which is something I *do* have in mind but may never get around to doing) I wouldn't expect to pay anything for it.  As rollasoc notes, it's not hard to program in Python and folks who would charge for simple things are going to quickly be surpassed by others willing to fill the void for nothing.

And, rollasoc, I didn't see your idea but I'm glad you came up with the same thought as I did -- great minds think alike <g>.  It will be interesting to see if you have the same thought as I have for the next two here (one is finished and I'll display it tomorrow: it's mocap with a completely different approach).
By kungphu - 5 Years Ago
That’s just wonderful mike! Can’t wait to see what else you come up with. This is a great start to what I’m guessing is going to be a lot more great stuff from ya!
By Kelleytoons - 5 Years Ago
Okay, yet one more piece of the puzzle (we're getting there -- I only have one more piece to show, but it's a very useful piece to almost anyone.  I'll try and post it no later than tomorrow, but maybe even this afternoon if I can do it before I consume alcohol :>Wink.


By Delerna - 5 Years Ago
Almost finished moving from my capital city back to my home town so I've only been able to look at these so far but I can see that what you are showing is going to be very helpful to getting my head around this part of the process......making useful things happen in projects....


So far, a couple of weeks ago, I have only been looking into setting up Python User Interface so far. One of the things I will be looking into soon will be python scripts that will make some of my morph animation objects easier to animate and I am sure I will think of plenty of other things as I progress.
I want to thank you for what you have shown here. Certainly going to assist me to get my head around these sorts of processes much quicker
By Kelleytoons - 5 Years Ago
Thanks again for everyone's kind words and the encouragement to keep showing these things.

Here's the last piece for Robby -- this does open up some other ideas for exploration, but for at least this particular prop animation I am finished.


By Rampa - 5 Years Ago
This is totally rad Mike! Smile

If you combine those last two you've shown you could have "auto-motion" in iClone, like CT8 has.
By videodv - 5 Years Ago
Exerlent work there Mike, lots of good info to check as well.

Chris.
By dogged2003 - 5 Years Ago
Kelleytoons
You create magic. Can you share the source?
By RobertoColombo - 5 Years Ago
Great job Mike!
By toystorylab - 5 Years Ago
Nice and definitely cool applications that would save (at least when creating Python script is done) a lot of manual work...
By Kelleytoons - 5 Years Ago
Some last stuff with Robby and a discussion about source code.


By Kelleytoons - 5 Years Ago
Okay, some more experiments with the latest Python version.  Here I show how someone can use a third party freeware program, Papagayo, to generate visemes and then use them in iClone.

When we were doing our show for Fox we used this approach exclusively to do all our lip sync in the 2D animation program Anime Studio/Moho, and it worked well.  It seems to work well in iClone, although I won't be using it (because I like using LiveFace and the iPhone X -- that way I get all the natural expressions, too).  However, for folks without LiveFace or Faceware this might be a viable alternative.

(And sorry for being so sleepy -- I got to bed REAL early last night, but woke up about 3am and thought I'd do this before I fell back asleep)


By Kelleytoons - 5 Years Ago
And we're back with a very quick shot with the new functionality to load image maps into our texture channels.

This solves a big problem I have with Anima so that's great, but it might give some of you ideas for other things: