PySwarm for PyCarrara (V0.6) Released 01/25/2013

1356712

Comments

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    V0.4 is now available. See the details in the updated post at the front of this thread:
    http://www.daz3d.com/forums/discussion/31190/

    As always, I am interested in hearing your thoughts and suggestions, and would love to see some example animations where this product is used!

    Thanks.
    FD

  • PhilWPhilW Posts: 5,145
    edited December 1969

    Thanks for this, I will look forward to having a play! So many fun things to do right now...

  • DartanbeckDartanbeck Posts: 21,583
    edited December 1969

    PySwarm for PyCarrara V0.4 is now available for public use!

    PySwarm for PyCarrara is a Python script specifically designed and written to be used with DAZ3D Carrara’s plug-in PyCarrara to manipulate and render realistic swarming object and other similar forms of group behavior in Carrara. (Read about how to install PyCarrara at the end of this post.)

    Download V0.4 with the following link:
    https://drive.google.com/file/d/0B8V9-txK8F4MUVlQdGhGRFBseVk/edit?usp=sharing

    and select "Download".

    The V0.4 package contains:
    - the latest PySwarm script (V.0.4)
    - an updated V0.4 Users Guide
    - a generic .CAR starter file to test and use with the V0.4 script


    How to get PySwarm to Work:
    Read this section if you still need to install the PyCarrara plug-in onto your Windows-based computer, which is required to use the PySwarm script.

    Follow these steps...


    Wow.
    Thank you very much for this super cool front post. Very helpful for those with little time.
    Also,
    Thanks for all of your hard work on all of this, FD... Truly... Thank You!
  • FractalDimensiaFractalDimensia Posts: 0
    edited November 2013

    Wow.
    Thank you very much for this super cool front post. Very helpful for those with little time.
    Also,
    Thanks for all of your hard work on all of this, FD... Truly... Thank You!

    You're welcome, Dartan. I really can't call this "work" though. Maybe "labor of love" fits better. I plan to take a breather the next few days and see if I can turn a few of the dozen scenarios I have come up with into animations. I have lots of stuff to throw at it now besides PySwarm - Poser Pro 2012, PyCarrara modifiers, ERC, NLA loops, ...

    Now, if I can just figure out what all those tools do! :)

    Post edited by FractalDimensia on
  • DartanbeckDartanbeck Posts: 21,583
    edited December 1969

    That's a lot, too.
    Just ERC alone is a good bit of power to tackle.
    You do know about fabaone's gallery at ShareCG (faba here), right? She is a leading source of great idea and examples of some of the brilliant capabilities it gives you. It's actually a really slick setup that is easy to fill out to get it doing stuff. It might seem a bit overwhelming at first, but then it should all just start to make sense. I still have to get at a lot of that stuff too. I downloaded all of faba's tutorials from the link above, and printed them all out, combined them with the instructions that comes with ERC for Carrara, as well as Mimic instructions and a few of 3dage's tutorials, printed them all out and bound them into a book - so I can study on the go. I do that a lot with stuff I want to wrap my head around, but my time at the computer is short.
    Plus I just like having books ;)

  • FractalDimensiaFractalDimensia Posts: 0
    edited November 2013

    That's a lot, too. Just ERC alone is a good bit of power to tackle.
    You do know about fabaone's gallery at ShareCG (faba here), right? She is a leading source of great idea and examples of some of the brilliant capabilities it gives you. It's actually a really slick setup that is easy to fill out to get it doing stuff. It might seem a bit overwhelming at first, but then it should all just start to make sense. I still have to get at a lot of that stuff too.

    Actually, until I started working with PyCarrara about a month ago, I have done almost ZIP regarding animation. So EVERYTHING is new. I just downloaded a few faba tutorials that will be VERY useful, as I have been struggling with ERC a bit.

    Thank you! =)

    Post edited by FractalDimensia on
  • PhilWPhilW Posts: 5,145
    edited December 1969

    ERC is very powerful but it takes a little time to get your head around how it works. But at its heart is a very simple concept - if I change something on one object, then that changes something else on another object (or a different part of the same object) - with an optional time delay. The Faba example with the lizard tail is I think a superb example of how complex animation can be produced from a simple motion.

  • Philemo_CarraraPhilemo_Carrara Posts: 1,175
    edited December 1969

    Hi FD,

    I rephrase what I've sent for everybody benefit :

    All the rules are testing last frame solution and not the potential position for the frame (last frame position plus last frame velocity).
    If not, you could be correcting something that is already corrected.
    For instance, a boid was brushing along a limit and is now taking a course that will exit this limit. If you test only on position, you may consider it is still brushing and apply again a correction.
    Another example is to boids a heading for a collision. they weren't colliding after last frame move, but if nothing is done, they will this frame. The only way to detect it is to add velocity to position.

    If you want, I can correct the script

  • DUDUDUDU Posts: 1,945
    edited November 2013

    Hello,
    I installed Python 2.6.6 + placed the files extensions Pycarrara, Pyswarm and Pycloid + the file plugin in extensions.
    At the beginning, I opened a file demonstration and I had an error message “Python .dll missing”…
    I copies the DLL present in the program and I paste it in System32.
    Now, the files demonstration function well!
    It is very well but I want to create my own scene with some cones to try, and here the error messages…
    What does it occur?
    Pycloid doen't work anymore.
    I run on W7/64bits
    Thank you for an answer.

    Capture_2.JPG
    381 x 787 - 62K
    Post edited by DUDU on
  • Philemo_CarraraPhilemo_Carrara Posts: 1,175
    edited November 2013

    Hi Dudu,

    The error is due to the fact that PyCarrara cannot find an object in your scene.


    The Script expect all names to be unique (ie cone1, cone2, cone3...)
    All your boids have the same name (cône)

    If you look in the script line 59 and 60, you see :
    boids_name='Boid' # Prefix name of Carrara object
    num_boids = 20 # Set to be the number of BOIDS in the simulation

    If you don't have 20 boids named Boid1 to boid21, you need to change those 2 lines.

    If your objects are in a group (like in your example), the prefix should be "Réplicateur converti/Cône"

    Also, you're not suppose to use a PyCarrara Modifier, but to import the script via import file.

    By any mean, please read the included PDF file FD took some pain to write.

    Hello,
    I installed Python 2.6.6 + placed the files extensions Pycarrara, Pyswarm and Pycloid + the file plugin in extensions.
    At the beginning, I opened a file demonstration and I had an error message “Python .dll missing”…
    I copies the DLL present in the program and I paste it in System32.
    Now, the files demonstration function well!
    It is very well but I want to create my own scene with some cones to try, and here the error messages…
    What does it occur?
    Pycloid doen't work anymore.
    I run on W7/64bits
    Thank you for an answer.
    Post edited by Philemo_Carrara on
  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    Hello,
    I installed Python 2.6.6 + placed the files extensions Pycarrara, Pyswarm and Pycloid + the file plugin in extensions.
    At the beginning, I opened a file demonstration and I had an error message “Python .dll missing”…
    I copies the DLL present in the program and I paste it in System32.
    Now, the files demonstration function well!
    It is very well but I want to create my own scene with some cones to try, and here the error messages…
    What does it occur?
    Pycloid doen't work anymore.
    I run on W7/64bits
    Thank you for an answer.

    Hi DUDU. According to the screenshot you have, you are attempting to use the PySwarm script in the PyCarrara modifier type. It is important to remember that PyCarrara has three components. The PyCarrara modifier is one of them, and is not the one related to how PySwarm operates.

    Once you have your scene set up (with the objects you want PySwarm to manipulate), you should use the "File / Import ..." pull-down menu option. Then select the PySwarm script file (".py" extension). That will launch PySwarm.

    Also, you will need to number each of the instances (BOIDs). So, in your example, you should have a "Cone1", "Cone2", "Cone3", etc. This is necessary so that PySwarm can find each object to include in the manipulation.

    Be sure to read the PySwarm Users Guide, which describes the steps necessary to set up your scene and to run PySwarm.

    I hope that helps get you started.
    FD

  • DUDUDUDU Posts: 1,945
    edited December 1969

    Thanks Philemo;
    I'm not familiar with scripts, I try that directly !
    @+

  • FractalDimensiaFractalDimensia Posts: 0
    edited November 2013

    Philemo said:
    Hi FD,

    I rephrase what I've sent for everybody benefit :

    All the rules are testing last frame solution and not the potential position for the frame (last frame position plus last frame velocity).
    If not, you could be correcting something that is already corrected.
    For instance, a boid was brushing along a limit and is now taking a course that will exit this limit. If you test only on position, you may consider it is still brushing and apply again a correction.
    Another example is to boids a heading for a collision. they weren't colliding after last frame move, but if nothing is done, they will this frame. The only way to detect it is to add velocity to position.

    If you want, I can correct the script


    Hi Philemo.

    Your interpretation of the algorithm is correct.

    A technical explanation for those following this discussion: As PySwarm currently operates, each rule (#1, 2, 3, 6, & 7) is examined based on the BOID's current position. I wrote the script to also maintain the previous iteration's velocity vector. You are suggesting that a better approach might be to assume the BOID should first look at the next position based on the saved velocity, and then correct any "situations" at that point, since the current trajectory may fix any problems (flying too close to another BOID, flying outside a container) at the current position without having to do anything. Such a "look ahead" approach has been done in other BOID algorithms, though I have not found the technical details for how it was done.

    My assumption is that such a modification would result in smoother BOID performance, and is well worth investigating! I'd like to see what you come up with.

    When evaluating changes to how the rules function, I have been first running a set of 3-4 simulation runs (Monte Carlo style, with different settings) before making the changes, and then running them again after the changes, to validate the change results in improved performance (behavior).

    I look forward to seeing your results! :)

    Post edited by FractalDimensia on
  • DUDUDUDU Posts: 1,945
    edited November 2013

    Here, I tried to take all your advice and looked at the tutorial but without success.
    To make a test, I made a copy (PySwarm v0.4-Copy.py) of the original script demo and I tried to reload it (File/importation) in the demo project and here another error message…
    What is wrong in my computer ?

    Copie_du_script.JPG
    826 x 640 - 43K
    Post edited by DUDU on
  • FractalDimensiaFractalDimensia Posts: 0
    edited November 2013

    Here, I tried to take all your advice and looked at the tutorial but without success.
    To make a test, I made a copy (PySwarm v0.4-Copy.py) of the original script demo and I tried to reload it (File/importation) in the demo project and here another error message…
    What is wrong in my computer ?

    DUDU, sorry it is not working for you yet. Give me a little time to run this down and I will get back to you.

    Did you modify the PySwarm script? If so, what did you change? Any information about what you did would help me run down the problem.

    Also, could you post a screen shot of your scene settings (the instances list in the bottom right corner of your screen)?

    FD

    Post edited by FractalDimensia on
  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    Here, I tried to take all your advice and looked at the tutorial but without success.
    To make a test, I made a copy (PySwarm v0.4-Copy.py) of the original script demo and I tried to reload it (File/importation) in the demo project and here another error message…
    What is wrong in my computer ?

    I looked at the script and the line where the error occurred. I don't have enough information to know why this is happening. I re-imported the script in the demo .CAR file (as released) and it ran fine.

    It would help if you could upload the script and .CAR file somewhere and send me the link, so that I could look at them.

    Apologies,
    FD

    Python_Execution.jpg
    527 x 603 - 33K
  • DUDUDUDU Posts: 1,945
    edited December 1969

    The scene settings are yours, I don't change anythings in your scene, I just made a copy of your script and reload it into your scene.
    normally, if I understood well, old the keyframes should be replaced by the new ones.

    Capture.JPG
    254 x 751 - 37K
  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    The scene settings are yours, I don't change anythings in your scene, I just made a copy of your script and reload it into your scene.
    normally, if I understood well, old the keyframes should be replaced by the new ones.

    This is very perplexing! If you are simply loading and running the released script in the released demo .CAR file, it should work! Did you try importing the original "PySwarm V0.4.py" file to make sure nothing got changed when you made a copy?

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    By the way, for those using MS Word to edit the script:

    During my attempts to discover the source of this problem, I found out something odd.

    If you have your .py script actively loaded in MS Word when you attempt to import it, either PyCarrara or Python (or Carrara) thinks the file is locked, and won't run the script! It doesn't give an error message, either. It just says, "Script execution terminated." (See screenshot attached.)

    If you get this message, you'll need to close the file out of MS Word and click "Restart script".

    I suggest using WordPad or NotePad as your editor, and you won't experience this problem.

    Python_Execution.jpg
    530 x 601 - 28K
  • DUDUDUDU Posts: 1,945
    edited December 1969

    I just do that now, and it's always the same problem.
    If your demo work, I think the installation of the files are corrects ?
    It's surely an internal problem in my computer but what ?

  • DUDUDUDU Posts: 1,945
    edited December 1969

    I tested all your Pycarrara samples and reloaded the scripts and all functions well, the problem is with PySwarm…

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    I tested all your Pycarrara samples and reloaded the scripts and all functions well, the problem is with PySwarm…

    There are several potential problems:

    (1) Your installation of Python 2.6.6 did not work properly.
    (2) Your installation of PyCarrara plug-in did not work correctly.

    You might try these steps:
    (1) Verify that you downloaded Python 2.6.6. I have not tried any later versions, so there's no guarantee it works correctly with PyCarrara.
    (2) Uninstall and the re-install Python.
    (3) Make sure that you put the right version of PyCarrara into your Carrara Extensions folder. If you moved the PyCarrara x64 version into Carrara x86 (32-bit), it will likely not work correctly; same if you moved PyCarrara V7 into a Carrara V8.1 or V8.5 extension folder.
    (4) Re-download the PySwarm files and replace the ones you have. It is possible something got garbled in the download.

    If none of those steps work, try it on a different computer.

    Beyond that, I would need to have a look at your files and try them on my computer. I can't solve the problem if I cannot reproduce the symptom. I will help as much as I can.

  • Philemo_CarraraPhilemo_Carrara Posts: 1,175
    edited December 1969


    Hi Philemo.

    Your interpretation of the algorithm is correct.

    A technical explanation for those following this discussion: As PySwarm currently operates, each rule (#1, 2, 3, 6, & 7) is examined based on the BOID's current position. I wrote the script to also maintain the previous iteration's velocity vector. You are suggesting that a better approach might be to assume the BOID should first look at the next position based on the saved velocity, and then correct any "situations" at that point, since the current trajectory may fix any problems (flying too close to another BOID, flying outside a container) at the current position without having to do anything. Such a "look ahead" approach has been done in other BOID algorithms, though I have not found the technical details for how it was done.

    My assumption is that such a modification would result in smoother BOID performance, and is well worth investigating! I'd like to see what you come up with.

    When evaluating changes to how the rules function, I have been first running a set of 3-4 simulation runs (Monte Carlo style, with different settings) before making the changes, and then running them again after the changes, to validate the change results in improved performance (behavior).

    I look forward to seeing your results! :)

    Hi FD,

    It's now implemented in draft 8 available for download. Also in this draft is the correction for the separation rule which works much better now.

  • DUDUDUDU Posts: 1,945
    edited December 1969

    FD, I found the solution ... Carrara must be in english version only !!!
    Everything work now.
    I made some tests with Pycarrara and I prepare a few questions for you.
    @+

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    FD, I found the solution ... Carrara must be in english version only !!!
    Everything work now.
    I made some tests with Pycarrara and I prepare a few questions for you.
    @+

    Good to hear! I'm glad you were able to get it working. =)

    I look forward to your questions.

  • FractalDimensiaFractalDimensia Posts: 0
    edited November 2013

    I just uploaded a video of a short animation I did using PySwarm V0.4.

    “Shark Tank” is the first of several animations I am creating to test PySwarm's current (V0.4) capabilities. The purpose of the first phase of this animation was to test using PySwarm on BOIDs whose motion was also driven by NLA track loops. I also wanted to test linking PySwarm motion animation with Fenric’s ERC plug-in.

    It can be viewed:
    http://youtu.be/_NbaQNNwfTg

    Please note: BOID turning in this simulation is not very realistic yet. In the second phase of this simulation, I will use a later version of PySwarm to automatically insert keyframes, replacing the need for NLA tracks. This new approach (upcoming soon) will provide a method of animating turning to create more realistic animations.

    A document briefly describing the steps I went through to generate the animation can also be downloaded:
    https://drive.google.com/file/d/0B8V9-txK8F4MeVVoX0RWQ1Uxc28/edit?usp=sharing

    FD

    Post edited by FractalDimensia on
  • PhilWPhilW Posts: 5,145
    edited December 1969

    Great to see this, I look forward to more. A couple of suggestions - Holly mentioned previously about the shadows looking too much like the actual objects and that is the case here, it almost looks like you have pairs of sharks, you need to reduce the shadow intensity (or have another light at a different angle that will add some illumination in the shadowed areas). Also the sharks' swimming motion looked too subtle, it needs to be exagerated more so that it is more visible. It will be be interesting to see your development to insert key frames!

  • HeadwaxHeadwax Posts: 9,989
    edited December 1969

    Beaut work FD, wonderful to see users take things into another dimension. If only had time to play - oh well. Thanks so much for doing this, I'll have time about June 2014 , by then you'll be hosting large scale mock attacks at Pearl harbour if I guess right. Hope that's not impoliticaily incorrect picking PH

  • Philemo_CarraraPhilemo_Carrara Posts: 1,175
    edited December 1969

    Hi to all,

    I've been thinking a lot about the limitation of PyCarrara and the necessity to modify scripts to get something, which is fine for an old IT guy like me, but may rebuke people with a more artistic mind :-)

    When I saw the shark tank video and the use of ERC, I remembered that Fabaone has imagined helpers for ERC. If you mix that with the fact that PyCarrara can memorize informations across frames (like in the RobotWalk sample screen) and every object can be moved/rotated by a modifier, , I think I may at least try to build a solution where no script or a minimum of is necessary.

    I could also make use of ERC sliders but it would require people to buy ERC (which, OTOH, is a good product and I recommend it)

    Anyway, I start building a prototype and will report any progress (or lack of it :-) )

  • PhilWPhilW Posts: 5,145
    edited December 1969

    Does this mean that you could have a settlings panel for PySwarm to set up the various parameters without needing to go back and forth between Carrara and a text editor - that would be a wonderful addition!

Sign In or Register to comment.