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

FractalDimensiaFractalDimensia Posts: 0
edited January 2014 in Carrara Discussion

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.)

Latest Version
V0.6 of PySwarm for PyCarrara is now available.

Access
You can get the latest information about downloading and installing the required components of PySwarm with the following link:
http://pyswarm.wikia.com/wiki/Download_and_installing_PySwarm#Latest_Version_of_the_PySwarm_Package

Note that PySwarm now comes with an installer package to make installation easier.

Be sure to follow the link to the wiki page on the installation procedure:
http://pyswarm.wikia.com/wiki/PySwarm_Installation_and_Removal_Procedures

Contents
The contents of the V0.6 package includes:
* Revised PIA (V2)
* New PySwarm script shell (V0.6)
* Six demo .CAR and PySwarm project parameter files to study, experiment, learn from, and expand

Note that PIA V1 and previous versions of PySwarm will no longer be supported.

V0.6 Enhancements:
The details of the modifications to this release can be found:
http://pyswarm.wikia.com/wiki/PySwarm_V0.6_Release_Notes

Online Users Guide
You can access the general Users Guide here:
http://pyswarm.wikia.com/wiki/PySwarm_Users_Guide_(Main_Page)

I will continue to expand the online guide.

To read about PIA, you can find a complete section here:
http://pyswarm.wikia.com/wiki/PySwarm_Interface_Application_(Main_Page)

I have started a troubleshooting page designed to offer suggestions when encountering problems with installing Python and PyCarrara, using PIA, and importing PySwarm scripts. I will continue to add to this page.
http://pyswarm.wikia.com/wiki/Troubleshooting_PySwarm


Special thanks to Philemo, who provided insights about how to code the MAX_TURNING rule, suggestions on CONTAINMENT coding, and ideas for redesigning the script. Anyone else interested in participating please post here or email me! My email address is:
[email protected]

Also, special thanks to Philemo, Dartanbeck, PhilW, EP, DUDU, 0Oseven, and all those who have offered encouragements, ideas, and suggestions about how to advance this product. Please keep the thoughts and ideas coming! I look forward to seeing posts in this thread showing what you have done with PySwarm!

========================================================

Version History:
0.3: Initial release (10/25/2013)
0.3.1: Bug fix when no camera or focus are used (10/25/2013)
0.3.2: Bug fix when using "Attractor" object (10/29/2013)
0.4: New features added (11/4/2013)
0.4.1: Four bug fixes (11/18/2013)
0.4.2: Slight enhancements (12/11/2013)
0.5: Major release (12/29/2013)
0.5.1: Bug fixes (01/02/2014)
0.5.2: Several enhancments and bug fixes (01/16/2014)
0.6: Major release (01/25/2014)

I'll continue to publish update releases and more demos to this thread in the future. This header post will provide links to the latest versions. Some of the features currently be working on are listed at the end of the Users Guide.

Support:
Please post any issues, comments, and questions you have about PySwarm in this thread.

Happy swarming!

Post edited by FractalDimensia on
«13456711

Comments

  • mmoirmmoir Posts: 334
    edited December 1969

    FD,
    This is great looking stuff . Nicely done.

  • DartanbeckDartanbeck Posts: 6,942
    edited December 1969

    Fan-freaking-tastic!
    Is it me... or was that really fast?!!! Doesn't seem that long ago you've just begun this project. I had no clue I'd be downloading it so soon :)

    Thank You FD!!!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    mmoir said:
    FD,
    This is great looking stuff . Nicely done.

    Thanks, mmoir. I hope you find it useful!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    Fan-freaking-tastic!
    Is it me... or was that really fast?!!! Doesn't seem that long ago you've just begun this project. I had no clue I'd be downloading it so soon :)

    Thank You FD!!!

    Well, it took me 8 calendar days to get this far. I might need a few days off before I get started on the next round. :)

  • DartanbeckDartanbeck Posts: 6,942
    edited December 1969

    You totally ROCK, my friend!

  • Sci Fi FunkSci Fi Funk Posts: 652
    edited December 1969

    Well done for bringing Python to life in this way. Keep going!

  • info2_5206216b80info2_5206216b80 Posts: 118
    edited December 1969

    Wauw, very good.

    In the video most is in 2d (X,Y), is everything also possible with Z values?

    Isn't it possible for the ones not good with scripting, like me, to create it using an exe file? Insert values in a menu > create script.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    Pjotter said:
    Wauw, very good.

    In the video most is in 2d (X,Y), is everything also possible with Z values?

    Isn't it possible for the ones not good with scripting, like me, to create it using an exe file? Insert values in a menu > create script.

    The goal is that PySwarm will work in all 3 dimensions, but I am just now testing motion in the z axis. There is still some work to do on that. At the moment, the individuals undulate as a group in the z axis as they move. I know why its happening that way; just not sure yet what is "wrong" with the behavior and how the best way to modify the script. I'm working on a simulation called "Shark Tank" to test this more.

    I wrote the script so it is extremely easy to add PySwarm to your Carrara animations. All you need is to add the PyCarrara plug-in. If you don't know anything about coding/scripting, just make adjustments to the parameters (near the beginning of the script), and ignore the details below. I have thought about writing a program that is more interactive, and then dumps a PySwarm script file using values set in a window; but that is farther downstream once the features and parameter set is more stable. :)

  • PhilWPhilW Posts: 1,645
    edited December 1969

    Great work, I'll certainly download this and have a play when I get the chance, this is a great development for the Carrara community!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    *** Update ***

    It seems in all my testing of the script, I let a defect slip through. In V0.3, if you choose no camera or camera focus to manipulate, the script won't work and Python aborts.

    I've replaced the download link in the first post with a fix to this (V0.3.1), which is the same user guide and .CAR files, except with a modified PySwarm script file. Alternatively, you can download JUST the script file here:
    https://drive.google.com/file/d/0B8V9-txK8F4MYW84ZV9ldzNzZ3c/edit?usp=sharing

  • DartanbeckDartanbeck Posts: 6,942
    edited December 1969

    Now that's customer support! Thanks, yet again!

  • Sci Fi FunkSci Fi Funk Posts: 652
    edited December 1969

    Well done.

    Can I just clarify? Does this include collision detection? I'm thinking of a crowded corridor scene where people are bumping into each other.

  • PhilWPhilW Posts: 1,645
    edited December 1969

    I think this is what the separation parameter is all about, it can be set so that people avoid each other - think of it like defining each actor's personal space.

  • FractalDimensiaFractalDimensia Posts: 0
    edited October 2013

    PhilW said:
    I think this is what the separation parameter is all about, it can be set so that people avoid each other - think of it like defining each actor's personal space.

    Good question, Steve.

    And Phil's response is correct. If you set the Separation adjustment ("keep_away_adj") value low, the individuals do not seem to care much for their separation, and will walk on top of each other (so to speak). Very high values, and they do crazy things to avoid moving inside the personal space (the "keep_away_distance"). You would have to play with the parameters to see what works best.

    Remember that the SEPARATION rule is sort of the reverse of COHESION. More precisely, COHESION gets the individuals to want to move to the center of their mass, while SEPARATION is a one-on-one rule - that one only takes effect when two individuals move in closer than the distance to another. Most of the jerkiness you might have seen in my demos is caused by this "state of confusion" between moving closer and staying away.

    Of course, it is important to remember that PySwarm inserts keyframes. So once you get the individuals behaving "close enough," you can go in and individually tweak where you have collisions.

    Also, Steve, if you want to play around with how you might simulate people moving down a hallway, you might actually try this:
    1) set the CONTAINMENT values to be just inside the corridor
    2) turning off the COHESION rule completely (let CONTAINMENT force them to stay together)
    3) set SEPARATION to a middle range
    4) use the ATTRACTION rule to draw the people down the hallway (setting the ATTRACTION object at the other end)
    5) remember to set the max_speed to be the walking speed (in feet per second), which for walking I estimate to be about 5.5 at a relatively fast walk, 4 for a stroll.

    You can easily set these and use the .CAR test file (using the ball-like BOIDS) to test it out. Once you have that, replace the BOIDS with humans, and rerun the PySwarm script. That should get you close.

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


    Also, Steve, if you want to play around with how you might simulate people moving down a hallway, you might actually try this:
    1) set the CONTAINMENT values to be just inside the corridor
    2) turning off the COHESION rule completely (let CONTAINMENT force them to stay together)
    3) set SEPARATION to a middle range
    4) use the ATTRACTION rule to draw the people down the hallway (setting the ATTRACTION object at the other end)
    5) remember to set the max_speed to be the walking speed (in feet per second), which for walking I estimate to be about 5.5 at a relatively fast walk, 4 for a stroll.

    Since this scenario fit the current improvements I am making to PySwarm, I spent a few hours putting together a quick render of this idea. I used the settings above. With a few more hours of tweaking, and giving the robots a walk cycle, this might start to look realistic...

    http://youtu.be/RyG0p8qVGS4

  • PhilWPhilW Posts: 1,645
    edited December 1969

    OK, I've downloaded PyCarrara (which I didn't have before) and PySwarm. When I try to load the script as directed in the manual, I get a message that Python26.dll is missing. I had a look on the Python site and just got confused with talk of various versions of Python 2 and 3 - can you advise what I need to do to get this working, as you probably understand what you are doing on this more than I do!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    PhilW said:
    OK, I've downloaded PyCarrara (which I didn't have before) and PySwarm. When I try to load the script as directed in the manual, I get a message that Python26.dll is missing. I had a look on the Python site and just got confused with talk of various versions of Python 2 and 3 - can you advise what I need to do to get this working, as you probably understand what you are doing on this more than I do!

    Hi phil. Typing on my phone so will be brief.

    In Frederic"s doc you will find a description about installing Python. Use the link he provides to download Python 2.6.6. I have not tried a more recent version yet. After installing Python Follow the directions to drop the files into your Carrara folder that holds plug ins.

    I hope that gets you started.

  • PhilWPhilW Posts: 1,645
    edited December 1969

    Thanks for your help - I wasn't sure which doc / link you were talking about, but I managed to find Python 2.6.6 and have installed it and got PySwarm working so all is good! Now to have a play.

  • PhilWPhilW Posts: 1,645
    edited October 2013

    I am starting to go through the PySwarm manual in more detail and an additional parameter occurred to me that you may want to consider and I thought I'd add it here before I forgot about it.

    At the moment when an object turns, it stays upright throughout (or at least I believe so, I haven't really started playing in earnest!). Would it be possible to add a banking parameter so that the object (eg. a bird) could bank as it turns, this would produce more natural movement for some types of object. As I am writing this, I realise that this means keeping track of the change in direction as well as the direction itself, which you are probably not currently needing to do, so it is probably a little more complex than I was at first thinking! Still, I hope it is a useful idea.

    Also, would it be possible to add variation in the starting height?

    EDIT: Sorry, I just read on to the end and you have already thought of these!!

    Post edited by PhilW on
  • PhilWPhilW Posts: 1,645
    edited December 1969

    Me again! I have started playing with changing parameters and something is not working as I think it should - not sure if it is me doing something wrong, or if there is an issue with PySwarm. I turned on the Attraction rule and used "Attractor" as the object (in your test scene). That worked fine. I then set key frames for the Attractor at 10sec, 20sec and 30sec, but when I re-ran the script. the objects did not follow the attractor but stayed around its original position. Any ideas?

  • FractalDimensiaFractalDimensia Posts: 0
    edited October 2013

    PhilW said:
    Me again! I have started playing with changing parameters and something is not working as I think it should - not sure if it is me doing something wrong, or if there is an issue with PySwarm. I turned on the Attraction rule and used "Attractor" as the object (in your test scene). That worked fine. I then set key frames for the Attractor at 10sec, 20sec and 30sec, but when I re-ran the script. the objects did not follow the attractor but stayed around its original position. Any ideas?

    Hi Phil!

    I am glad you're taking the time to play with the script some. You're forging new ground as everything up until now has been just my experimentation.

    I realize I may not have put this in the manual, but I discovered PyCarrara plug-in uses the HotPoint of the object for its position. So if you've moved the attractor object (for example) away from the HotPoint and having it revolve around that point in your keyframes, the objects will swarm the wrong place. You might try putting the attractor along a track. (?) I have a note to myself to explore this more as it would make more sense to extract the object's center instead. I just haven't had time yet to figure out if and/or how to get to that information through PyCarrara.

    If this is not the case, then I'll need more information to know what is going on.

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

    PhilW said:
    Thanks for your help - I wasn't sure which doc / link you were talking about, but I managed to find Python 2.6.6 and have installed it and got PySwarm working so all is good! Now to have a play.

    I will update the first post in this thread to give details about how to install Python and PyCarrara for others experiencing this. I also struggled a bit with getting everything installed and working.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    PhilW said:
    I am starting to go through the PySwarm manual in more detail and an additional parameter occurred to me that you may want to consider and I thought I'd add it here before I forgot about it.

    At the moment when an object turns, it stays upright throughout (or at least I believe so, I haven't really started playing in earnest!). Would it be possible to add a banking parameter so that the object (eg. a bird) could bank as it turns, this would produce more natural movement for some types of object. As I am writing this, I realise that this means keeping track of the change in direction as well as the direction itself, which you are probably not currently needing to do, so it is probably a little more complex than I was at first thinking! Still, I hope it is a useful idea.

    Also, would it be possible to add variation in the starting height?

    EDIT: Sorry, I just read on to the end and you have already thought of these!!

    Well, it is good to see others are thinking along the same lines as me! ;)

    FYI - Actually, the bank and roll are not that hard as I actually do calculate the heading change vector (heading and speed) before updating the object's current one. This will be in the next release (V0.4).

    In V0.4, I have changed how object positions and velocities are initialized. There will be THREE different ways:
    1) Randomly placed within the containment area (which I hope addresses your random height request?)
    2) Using objects' current location and direction facing (so you can actually "prop" the scene with how you want the objects to start moving)
    3) Inside a circle of a defined radius (similar to how V0.3 works)

    Thanks for the feedback!

  • PhilWPhilW Posts: 1,645
    edited December 1969

    PhilW said:
    I am starting to go through the PySwarm manual in more detail and an additional parameter occurred to me that you may want to consider and I thought I'd add it here before I forgot about it.

    At the moment when an object turns, it stays upright throughout (or at least I believe so, I haven't really started playing in earnest!). Would it be possible to add a banking parameter so that the object (eg. a bird) could bank as it turns, this would produce more natural movement for some types of object. As I am writing this, I realise that this means keeping track of the change in direction as well as the direction itself, which you are probably not currently needing to do, so it is probably a little more complex than I was at first thinking! Still, I hope it is a useful idea.

    Also, would it be possible to add variation in the starting height?

    EDIT: Sorry, I just read on to the end and you have already thought of these!!

    Well, it is good to see others are thinking along the same lines as me! ;)

    FYI - Actually, the bank and roll are not that hard as I actually do calculate the heading change vector (heading and speed) before updating the object's current one. This will be in the next release (V0.4).

    In V0.4, I have changed how object positions and velocities are initialized. There will be THREE different ways:
    1) Randomly placed within the containment area (which I hope addresses your random height request?)
    2) Using objects' current location and direction facing (so you can actually "prop" the scene with how you want the objects to start moving)
    3) Inside a circle of a defined radius (similar to how V0.3 works)

    Thanks for the feedback!

    Sounds like a good set of starting options, and yes that would satisfy my starting height request.

    I don't think you need to look at deriving an object's centre, I think the hot point works fine and gives the user more control. In my test, I did not change the hot point of the attractor. You can have a look at what I have done here: https://dl.dropboxusercontent.com/u/4297440/PySwarm V0.3.1 - TestCopyPhilW.zip

    I was really surprised at how few times PyCarrara seems to have been downloaded! But I am sure that with your PySwarm, this may become a whole lot more.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    PhilW said:
    Sounds like a good set of starting options, and yes that would satisfy my starting height request.

    I don't think you need to look at deriving an object's centre, I think the hot point works fine and gives the user more control. In my test, I did not change the hot point of the attractor. You can have a look at what I have done here: https://dl.dropboxusercontent.com/u/4297440/PySwarm V0.3.1 - TestCopyPhilW.zip

    I was really surprised at how few times PyCarrara seems to have been downloaded! But I am sure that with your PySwarm, this may become a whole lot more.

    Okay, had a quick look and it seems you found a problem. Thanks, Phil, for the heads up. I'll upload a fix later today, and add a post to this thread. On another note, I'll have to do more testing of future versions before releasing them. (I've complained about DAZ3D not doing adequate testing of Carrara before release, so I should practice what I preach! ;) )

    My guess on the limited use of PyCarrara has more to do with the pre-requisite to understand programming/scripting in Python than about not having many capabilities. On the scale of complexity, Python ranks in the "simple" end of the spectrum. Still, "simple" is a relative term. ;)

    As I've posted elsewhere, while recently reviewing the plug-in, it struck me just how powerful PyCarrara really is. I've only begun to scratch the surface. And I still have several more areas to explore that are completely tangential to PySwarm. But PySwarm seemed a good way to whet my palate!

    Beyond creating something useful for Carrarans (PySwarm), my ultimate goal is to convince other programmers it is worth the investment to dive into this plug-in, and find new ways to make PyCarrara's features available to everyone in creating great simulations.

  • PhilWPhilW Posts: 1,645
    edited December 1969

    Always good to get a few people testing as they may try things that you wouldn't even think of! Tnanks for looking into this so quickly.

    As to more people using PyCarrara, now that they have the template of what you are doing, I am sure that more people should take a look. Hey, I may even brush off my own programing skills (unused in over 20 years! Back in the 80s I wrote a whole game in Assembler code...) to do the odd script.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    PhilW said:
    Always good to get a few people testing as they may try things that you wouldn't even think of! Tnanks for looking into this so quickly.

    As to more people using PyCarrara, now that they have the template of what you are doing, I am sure that more people should take a look. Hey, I may even brush off my own programing skills (unused in over 20 years! Back in the 80s I wrote a whole game in Assembler code...) to do the odd script.

    That's bringing back memories for me as well. I had my hand in writing several interactive games in a prior life. I'm certain all that is what guided me into Carrara. :)

    You'll find Python much easier to work with than assembler. Maybe PySwarm will help spawn a whole new Carrara revolution of developing reusable Python scripts! ;) HA! Now that is a thought. If there are enough people interested, I might even try my hand at doing some video tutorials on this topic. But I'm still a long ways from that!

    BTW, my second use of PyCarrara is to integrate the use of music and other sound files to manipulate objects. Frederic only briefly explored this with a few sample scripts, but they were with MIDI files. I've already done some basic tests using .MP3 and .WAV sound/music files, so I know it is possible to drive animation with sounds in other more readily available and standard formats. (Imagine using the sound of breaking glass to drive the explosion of a glass goblet or the hum of a motor to drive the shaking action of an engine. No need to attempt post-sync'ing your video and audio for one thing.) I'm still working on how to design a user interface that makes this principle available for non-programming Carrarans. I'm hoping to be able to post a few demos of this idea in the next month.

  • PhilWPhilW Posts: 1,645
    edited December 1969

    Wow, you don't let the grass grow, do you! I hope that your work will inspire more people to look into scripting.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    PhilW said:
    Wow, you don't let the grass grow, do you! I hope that your work will inspire more people to look into scripting.

    Like the saying, "I don't want to die with my in-basket empty." ;)

  • DartanbeckDartanbeck Posts: 6,942
    edited December 1969

    Well I just read through the pdf and find this to be a beautiful interface, as it were ;)
    This is excellent! Thank you! I still have to get PyCarrara, so there's one more dl... but it says I also have to get Python. I imagine that's just a search away, too.

    Again, thanks for this!

Sign In or Register to comment.
Rocket Fuel