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

13468912

Comments

  • 0oseven0oseven Posts: 626
    edited December 1969

    The new PIA allowed me to get started with PySwarm. Thanks for making it available.

    I very quickly set up a simple swarm of cubes and had them moving around ok. Changed a few parameters to observe behavior etc (Very pleased with my self)
    However returning to Carrara later I went through the same process with a more complicated model (airplane) but I couldnt get it to work.

    So I went back to simple objects and ran a simulation but now I get an error message. see screen shot.

    I interpret it to mean the script cannot find PyCarrara. I checked Carrara's Extensions and alll three mcx,dat, and txt files are there.
    I also noticed a new file which had been created ( not sure if it was already there and just modified but time stamp was recent) File is PyCarrara.pyc (compiled python file)
    is that something to do with the Pyswarm installation?

    The only other thing I did I tried importing a pyswarm script via the Carrara Modifier ( i tend to do things I shouldn't) the error problem seemed to occur after tthat.

    One final question - when importing the script( The correct way) What if anything needs to be "selected" in the instances tray. Options being the scene, one of the boids or all of the boids or nothing?

    If the boid is a complex model such as an airplane - i used 3duniverse's biplane - what part of the file structure needs selecting to have the script work on it.

    The BIPLANE files

    [ Biplane
    [ - Model
    [ Fuselage
    [ Tail
    [ etc
    [ etc

    sorry that was two questions.

    Hope i have provided sufficient information for you to understand and by the way I tried reinstalling pyswarm but error persists.
    Look forward to your thoughts

    PySwarm_1.JPG
    1123 x 706 - 128K
  • DUDUDUDU Posts: 1,945
    edited January 2014

    O07 hello,
    I tested, like you to start from simple boids at the beginning and that did not function.
    Best, it is to start with the basic project of FD and to adapt it to your needs, thus you are sure to have all the elements in your scene.
    @+… on Carrarator!

    Post edited by DUDU on
  • 0oseven0oseven Posts: 626
    edited December 1969

    Hi Dudu
    It did work for me to begin with because I remember adding a plane to test collision of some cubes ( I read somewhere physics is not applied to boids but I had to try didn't I ?)

    I just tried your suggestion - load default boid scene then added cube , copied boid1 keyframes to cube, deleted boid1 then renamed cube boid1.
    Results boid1 seems not to be moving with group. Weird.

    Anyway this is a bit complicated if you have to rename a lot of new objects

    Your post in CarraraTors is what got me looking at pyswarm again - thanks.When I get it working again I'll post my WIP and experience there.

  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    0oseven said:
    The new PIA allowed me to get started with PySwarm. Thanks for making it available.

    I very quickly set up a simple swarm of cubes and had them moving around ok. Changed a few parameters to observe behavior etc (Very pleased with my self)
    However returning to Carrara later I went through the same process with a more complicated model (airplane) but I couldnt get it to work.

    So I went back to simple objects and ran a simulation but now I get an error message. see screen shot.

    I interpret it to mean the script cannot find PyCarrara. I checked Carrara's Extensions and alll three mcx,dat, and txt files are there.
    I also noticed a new file which had been created ( not sure if it was already there and just modified but time stamp was recent) File is PyCarrara.pyc (compiled python file)
    is that something to do with the Pyswarm installation?

    The only other thing I did I tried importing a pyswarm script via the Carrara Modifier ( i tend to do things I shouldn't) the error problem seemed to occur after tthat.

    One final question - when importing the script( The correct way) What if anything needs to be "selected" in the instances tray. Options being the scene, one of the boids or all of the boids or nothing?

    If the boid is a complex model such as an airplane - i used 3duniverse's biplane - what part of the file structure needs selecting to have the script work on it.

    The BIPLANE files

    [ Biplane
    [ - Model
    [ Fuselage
    [ Tail
    [ etc
    [ etc

    sorry that was two questions.

    Hope i have provided sufficient information for you to understand and by the way I tried reinstalling pyswarm but error persists.
    Look forward to your thoughts

    Hi ooSeven.

    Sorry you're having problems with PySwarm.

    First, I have not seen this error before in all of my use of PyCarrara, so I can only guess at what may be causing it. The script is hanging on the PySwarm line that is attempting to import the PyCarrara plug-in interface. My first guess is that somehow the PyCarrara file has gotten corrupted. Otherwise, my second guess is that a necessary pointer to where PyCarrara resides has been corrupted. The PySwarm script was written to be imported only through the "File/Import" command. The script is not written to be used as part of the PyCarrara modifier, which is really a completely different component of the plug-in. This may indeed have caused the problem.

    Also, I noticed in your description of the contents of the "plugins" folder within Carrara you did not mention the file "PyCarrara.py". This in fact is the file that Python is looking for and says it cannot find. Also I believe the files should be in the folder referenced by "Carrara8.5/Extensions/plugins". I did not install the PyCarrara files into "Extensions".

    I would suggest reinstalling PyCarrara by closing Carrara, dragging and dropping the PyCarrara files into the Carrara folder (following the instructions provided either in the PyCarrara Users Guide or the PySwarm wiki site), and reopening Carrara. This might solve the problem.

    Regarding what to select in the Instance tray - This will not affect PySwarm. It should not matter if you have anything selected when you start the import. However, you may notice that after the import, some objects may be selected. This has to do with the PyCarrara interface into Carrara, and is not related to PySwarm.

    If you have a complex (grouped) object that you are defining as a BOID, the BOID name should be the top-level group name (the BOID object itself). In the example you gave, it would likely be the name "BIPLANE". PySwarm will manipulate the entire group as a single object, each sub-object will follow along.

    Let me also mention that in a previous post by DUDU, you should make sure your BOID is facing towards the +X axis so that PySwarm manipulates motion correctly. If your (grouped) BOID is facing a different direction, you will need to use the ORIENTATION settings ("Orient." under Transform) to reorient the object. For example, if your BOID is facing +/- Y axis when the Rotations settings are set to (0.0,0.0,0.0), then you will need to enter +/-90 for Orient. in the Z axis. You should do this BEFORE you replicate/duplicate/copy your BOIDs; otherwise, you'll have to reset each one.

    Finally, a general thought. To be honest, I am just finding time to delve into creating complex BOIDs. My Apache helicopter scene uses relatively complex structure of grouped objects, and PySwarm works satisfactorily. Whenever I get stuck with problems with new Carrara scenes I am attempting to use PySwarm on, I go back and load my faithful .CAR test scene and try importing the script. If that works, then there might be something in the scene that is the problem. I have found on occasion that either Carrara or PyCarrara gets hung up on a scene (something with the internal Carrara structure maybe?), and that I have to start a fresh scene. That inevitably corrects the problem.

    Please post what you discover. I am interested in knowing the final outcome!

    Best wishes.
    FD

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

    0oseven said:
    Hi Dudu
    It did work for me to begin with because I remember adding a plane to test collision of some cubes ( I read somewhere physics is not applied to boids but I had to try didn't I ?)

    I just tried your suggestion - load default boid scene then added cube , copied boid1 keyframes to cube, deleted boid1 then renamed cube boid1.
    Results boid1 seems not to be moving with group. Weird.

    Anyway this is a bit complicated if you have to rename a lot of new objects

    Your post in CarraraTors is what got me looking at pyswarm again - thanks.When I get it working again I'll post my WIP and experience there.

    O07, I'd be happy to take a look at your .CAR and .PY files, and see if I can find the problem. This would be helpful for me as well if there is a bug somewhere in the script!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    O07 hello,
    I tested, like you to start from simple boids at the beginning and that did not function.
    Best, it is to start with the basic project of FD and to adapt it to your needs, thus you are sure to have all the elements in your scene.
    @+… on Carrarator!

    There is a lot (already) in PySwarm to get lost in, and agree with your suggestion. It is best to start with the test file and run a number of variations to get a good idea of how PySwarm rules and settings work. Then delete the existing BOID objects, import or create some of your own, and run tests in that scene.

    I plan to do a tutorial sometime this week on setting up a Carrara scene, importing and using a complex BOID, and running through creating an animation sequence. Hopefully this will answer some questions people may have. Still working out the technical details.

    Thanks!

  • 0oseven0oseven Posts: 626
    edited December 1969

    Thanks for your response Fractal

    OK so my mistake at this point is to have started from scratch ?

    I will follow your advice for practice until new tutorials available but just for the record here's what happened since my last post.

    Tried removing PyCarrara and reinstall - this seemed to lead to me not being able to run Carrara - that is - error received on starting New scene.Basically a system crash as unable to do anything so I was forced to reinstall Carrara. Copied/overwrite the PyCarrara files again again to the extension folder at which point everything working ok. Inserted three spheres into new scene and applied default pyswarm script - spheres reacted as expected.

    But as soon as I tried the same thing with a group (another aeroplane but simpler structure ) the same PyCarrara error popped up when importing script.

    Traceback (most recent call last):
    File "PyCarrara_16C6E550", line 23, in
    ImportError: No module named PyCarrara

    === Script execution terminated ===

    After which even the simple sphere scene would not work.

    As I say this is just feedback.

    thanks again!

  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    0oseven said:
    Thanks for your response Fractal

    OK so my mistake at this point is to have started from scratch ?

    I will follow your advice for practice until new tutorials available but just for the record here's what happened since my last post.

    Tried removing PyCarrara and reinstall - this seemed to lead to me not being able to run Carrara - that is - error received on starting New scene.Basically a system crash as unable to do anything so I was forced to reinstall Carrara. Copied/overwrite the PyCarrara files again again to the extension folder at which point everything working ok. Inserted three spheres into new scene and applied default pyswarm script - spheres reacted as expected.

    But as soon as I tried the same thing with a group (another aeroplane but simpler structure ) the same PyCarrara error popped up when importing script.

    Traceback (most recent call last):
    File "PyCarrara_16C6E550", line 23, in
    ImportError: No module named PyCarrara

    === Script execution terminated ===

    After which even the simple sphere scene would not work.

    As I say this is just feedback.

    thanks again!

    I really am sorry you had to reinstall Carrara. :ohh:

    I'll have to research this some. This does not seem to be a PySwarm issue, but that doesn't help you any.

    I'd like to help you troubleshoot the problem. It would help if I could have a look at the aeroplane .CAR file, as reproducing the problem would help me find the cause. I created several scenes last night by dragging and dropping some airplane models (from those that come with Carrara), renaming them to PLANE1, PLANE2, etc. Then I ran PySwarm against them without having any problems animating them.

    Have you tried this on another computer to see if the problem is not with your computer?

    Another suggestion: Something that would help know whether it is a PyCarrara or PySwarm problem is to try to run one of the sample scenes that comes with PyCarrara. You'll find a folder named "Samples" in the PyCarrara ZIP file. There is even one called "PyCarrara_validation" designed for this purpose. If you cannot import the PyCarrara_validation.PY script into the sample PyCarrara_validation.CAR scene, then the issue is probably with your PyCarrara installation or with Carrara.

    What version of Carrara are you using?

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

    Over the weekend, I ran some PySwarm tests on larger swarms - up to 225 BOIDs, and thought I would share some numerical results since I did not get what I intuitively expected to find.

    The graph below shows the rate my computer was able to generate keyframes for different sets of active rules and for different numbers of BOIDs. What I expected to find was that the rate would drop as more BOIDs are added to the scene. Oddly, I discovered that the worst performance occurred for about 100 BOIDs, after a substantial drop from 25 to 100. But then the keyframe insertion rate levels off (or slightly improves) with more BOIDs.

    I also observed the memory effects of inserting a lot of keyframes into a scene. I ran simulations up to 90 seconds with 225 BOIDs inserting keyframes at a rate of 10 per second (for a total of 202,500 keyframes). Carrara 8.5 handled this without a problem, with hardly any change in the amount of memory the app was using (about 20MB at most). The resulting .CAR file takes 10MB of space, up from about 1MB for a similar scene with 25 BOIDs - not a substantial drain on resources.

    Carrara 8.1 or 8.5 did not have a problem processing the 90 second 225 BOID PySwarm script, updating the scene during the import, or playing the resulting animation sequence. However, the BOIDs were simple vertex object with 3,000 polygons. I plan to try more complex BOIDs this week.

    Finally, I noted that CPU use of my i7 (with 8 threads) ran at about 13% using 4 threads, so it would seem the PyCarrara/Python import is not multi-threaded. Too bad....

    PySwarm_Keyframe_Rates.jpg
    911 x 540 - 86K
  • 0oseven0oseven Posts: 626
    edited January 2014

    Thankyou Fractal

    Over the next few days I'll look at my the PyCarrara installation and see what transpires.If problems persist I'll send you files etc.

    My system is notebook I7 64 bit 2.8 ghz 8threads, 8gb memory,1gb nvidea GT540m graphics windows 7 Carrara 8.5 pro latest
    .
    No, I have not been able to try using another PC but I do have C8.1 installed so I may try installing PyCarrara on that.

    As I understand it PySwarm really is the script generator and stands alone from PyCarrara therefore scripts should import ok to either version of Carrara - did I get that right ?

    Your recommended python download is V 2.6.6 but I note there is now V2.7.6 available - should we get that ? - see edit below
    http://www.python.org/

    Just now I'm going to watch your tutorial video again.
    Cheers

    EDIT just answered one of my questions.Found this in one of your "Installation notes"

    NOTE: There are later versions of Python available, but I have not tested whether they work properly with PyCarrara (nor, as I understand, has the developer of PyCarrara). If you download a later version and find that it works, please add a post to this thread.

    Post edited by 0oseven on
  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    0oseven said:
    Over the next few days I'll look at my the PyCarrara installation and see what transpires.If problems persist I'll send you files etc.

    Okay. I look forward to what you discover.

    0oseven said:
    As I understand it PySwarm really is the script generator and stands alone from PyCarrara therefore scripts should import ok to either version of Carrara - did I get that right ?

    That is right. PIA (PySwarm Interface App) is a Python script generator. The PySwarm script that you import into Carrara using the PyCarrara plug-in is separate. That is why I think your problem is somewhere in the PyCarrara-Carrara plug-in interface.

    Your recommended python download is V 2.6.6 but I note there is now V2.7.6 available - should we get that ? - see edit below
    NOTE: There are later versions of Python available, but I have not tested whether they work properly with PyCarrara (nor, as I understand, has the developer of PyCarrara). If you download a later version and find that it works, please add a post to this thread.

    Yes. Maybe I should make the text in larger print. Python V2.6.6 is actually what Frederic Rible (who developed PyCarrara) suggests. I have just been too busy to test later versions, so that is why I suggest just following what is there. Later versions of Python offer some more features, but they don't really apply to the PyCarrara plug-in (other than some bug fixes maybe). I will test Python V2.7.6 at some point, but I didn't want to risk muddling up my system while developing PySwarm. :)

    Post edited by FractalDimensia on
  • 0oseven0oseven Posts: 626
    edited December 1969

    Fractal

    First i want say apologies are not required in respect of me having to reinstall Carrara - The work you are doing and the benefit to the community far outweighs any inconvenience we experience through the beta stage. Your contribution is awsome!

    Now I think I found the problem which as you suspected was due to incorrect pycarrara installation. Looking closely at the notes which came with PyCarrara I spotted that one file needs go in a seperate folder inside the Extensions. I had previously just copied all files to the extensions as it is easily overlooked . Others should be aware of this.

    - "PyCarrara.py" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\plugins"
    - "PyCarrara.mcx" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"
    - "PyCarrara.txt" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"
    - "PyCarrara.dat" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"

    Since correcting this Pyswarm seems to be behaving as expected.

    Another error I was getting seems related to the number of boids spcified in PIA and the boids in the scene.
    I think your notes said it was ok to have fewer boids in the scene but not more than specified by the PIA.
    But my experience is if there are fewer boids -say boid1,boid2,boid3 and the imported file calls for 5 then there is a script error. if I go back and change the PIA setting to 3 or add two more to the scene then the script completes ok.

    One other thing I'm having trouble with and its partly due to me not being very good at getting my head around 3d coordinates xyz positions etc .

    It appears PySwarm sets all rotations ( and orientation ?) to zero when it imports so if the model added to the scene has a default position of say 90deg on the x axis, it gets set to zero and is incorrectly orientated when moving about. I tried various settings of the direction and pitch etc but couldnt make things look right.

    The model I used is "Angelfish" in the carrara mesh models but had same issue with others. I looked through wiki but didn't spot anything to help.

    Should I be giving feedback on your wiki site ?
    Cheers

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    0oseven said:
    Fractal

    First i want say apologies are not required in respect of me having to reinstall Carrara - The work you are doing and the benefit to the community far outweighs any inconvenience we experience through the beta stage. Your contribution is awsome!

    Thanks for the positive feedback. You are definitely an early PySwarm pioneer, and the feedback you are providing is excellent to help me improve both the wiki site and any future tutorials. Thank you.

    0oseven said:
    Now I think I found the problem which as you suspected was due to incorrect pycarrara installation. Looking closely at the notes which came with PyCarrara I spotted that one file needs go in a seperate folder inside the Extensions. I had previously just copied all files to the extensions as it is easily overlooked . Others should be aware of this.

    - "PyCarrara.py" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\plugins"
    - "PyCarrara.mcx" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"
    - "PyCarrara.txt" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"
    - "PyCarrara.dat" to "C:\Program Files (x86)\DAZ\Carrara 7 Pro\Extensions\"

    Since correcting this Pyswarm seems to be behaving as expected.

    This is good news. I will add this detail to the wiki installation page! I may also try to develop a script to automate the PyCarrara installation process. That might also help.

    0oseven said:
    Another error I was getting seems related to the number of boids spcified in PIA and the boids in the scene.
    I think your notes said it was ok to have fewer boids in the scene but not more than specified by the PIA.
    But my experience is if there are fewer boids -say boid1,boid2,boid3 and the imported file calls for 5 then there is a script error. if I go back and change the PIA setting to 3 or add two more to the scene then the script completes ok.

    That is correct. For example, if you had 100 BOIDs in your Carrara scene, the number you reference in PIA can be any number up to 100. If you enter 50 in PIA and generate a script, PySwarm will only manipulate the first 50. BOIDs #51-#100 will not move. I have a few ideas on how to use this "feature", but will hold that for an advanced tutorial.

    One other thing I'm having trouble with and its partly due to me not being very good at getting my head around 3d coordinates xyz positions etc .

    It appears PySwarm sets all rotations ( and orientation ?) to zero when it imports so if the model added to the scene has a default position of say 90deg on the x axis, it gets set to zero and is incorrectly orientated when moving about. I tried various settings of the direction and pitch etc but couldnt make things look right.

    The model I used is "Angelfish" in the carrara mesh models but had same issue with others. I looked through wiki but didn't spot anything to help.

    I have been meaning to add this to the wiki, but haven't had time yet. I posted something in this thread earlier, but such things get lost easily.

    PySwarm assumes that BOIDs are facing in the +X axis. To find out which way your BOIDs are facing, do this:
    1. Select one of the BOIDs.
    2. Under Motion tab/Transform section, clear out the Rotation values; that is, set them all to 0.00. See screenshot.
    3. Look at which direction the BOID is facing. It should be pointing in the +X axis (the red arrow should show the direction of motion).
    4. If it is facing a different direction (such as in the first screenshot where the angelfish is pointing upwards), then you need to enter rotational angles under "Orient." In the 2nd screenshot, you'll notice I can get the angelfish pointing in the +X axis by entering +90 degrees for the X and Z axis values. You'll notice the "Rotation" angles still show 0 degrees in all 3 axes.

    PySwarm only writes keyframes to the Rotation angles, so this should correctly orient the BOID in a way that it is moving in the right direction.

    Should I be giving feedback on your wiki site ?
    Cheers

    You and all others can feel free to post any feedback and comments you feel important on the wiki site. I specifically set it up as a wiki to make it a public site, where anyone using PySwarm can post questions, issues, lessons learned, ideas, and examples.

    However, given the infancy of this tool, I suspect others are more likely to follow discussions on this thread for the near future. This might be a better forum for the next few months.

    Thanks again for your feedback.
    FD

    Orientation_Example_Shot_2.jpg
    1123 x 857 - 214K
    Orientation_Example_Shot_1.jpg
    1163 x 863 - 208K
  • DartanbeckDartanbeck Posts: 21,570
    edited December 1969

    I love this!
    Although I cannot yet play, I sure do enjoy reading through this thread, and dreaming about how I will be using PySwarm!

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    I love this!
    Although I cannot yet play, I sure do enjoy reading through this thread, and dreaming about how I will be using PySwarm!

    Dream on, my friend! :) Hope you're able to join in soon.

  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    PySwarm V0.5.1 Bug:

    I started messing around creating a number of Carrara scenes using different types of BOIDs and discovered a bug in the current release of PySwarm.

    If you have the "Initiate in Landed Mode" parameter checked (under PIA's "Landed" tab) and did NOT activate the LANDING rule, PySwarm will generate keyframes, but your BOIDs will not move. (PySwarm thinks you still want to initiate the BOIDs in LANDED mode. :-S )

    Work Around:
    Before you generate your script, be sure you do not have this parameter checked in PIA if you are not using the LANDING rule.

    I will be releasing a fix for this bug with V0.5.2, which should be ready to release by this weekend. That will likely be the last minor release before V0.6 is ready.

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

    You GO FD!!!

  • 0oseven0oseven Posts: 626
    edited December 1969

    Thankyou Fractal

    I can now sort out the orientation problem now I understand what PySwarm expects.

    Made a video which can be seen here( I hope)


    http://www.bond3d.byethost18.com/index.php?topic=51.msg238#msg238

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    0oseven said:
    Thankyou Fractal

    I can now sort out the orientation problem now I understand what PySwarm expects.

    Made a video which can be seen here( I hope)


    http://www.bond3d.byethost18.com/index.php?topic=51.msg238#msg238

    Just the kind of animation I imagined PySwarm working with! Well done and thanks for sharing!

    Would like to know how you sorted out the orientation problem. I've bumped this issue high on the priority list for V0.6

  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    You GO FD!!!

    Well, seems there are a lot of starts and stops of late! :-S

    But 3 steps forward, 1 back is still some kind of progress. ;)

    Post edited by FractalDimensia on
  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014


    0oseven said:
    One other thing I'm having trouble with and its partly due to me not being very good at getting my head around 3d coordinates xyz positions etc .

    It appears PySwarm sets all rotations ( and orientation ?) to zero when it imports so if the model added to the scene has a default position of say 90deg on the x axis, it gets set to zero and is incorrectly orientated when moving about. I tried various settings of the direction and pitch etc but couldnt make things look right.

    The model I used is "Angelfish" in the carrara mesh models but had same issue with others. I looked through wiki but didn't spot anything to help.

    I have been meaning to add this to the wiki, but haven't had time yet. I posted something in this thread earlier, but such things get lost easily.

    PySwarm assumes that BOIDs are facing in the +X axis. To find out which way your BOIDs are facing, do this:
    1. Select one of the BOIDs.
    2. Under Motion tab/Transform section, clear out the Rotation values; that is, set them all to 0.00. See screenshot.
    3. Look at which direction the BOID is facing. It should be pointing in the +X axis (the red arrow should show the direction of motion).
    4. If it is facing a different direction (such as in the first screenshot where the angelfish is pointing upwards), then you need to enter rotational angles under "Orient." In the 2nd screenshot, you'll notice I can get the angelfish pointing in the +X axis by entering +90 degrees for the X and Z axis values. You'll notice the "Rotation" angles still show 0 degrees in all 3 axes.

    PySwarm only writes keyframes to the Rotation angles, so this should correctly orient the BOID in a way that it is moving in the right direction.

    FD

    I have to eat my words now. I did some testing yesterday and discovered this approach does NOT work consistently with PySwarm. To my chagrin, it seems PyCarrara DOES reset the "Orient." values when it writes rotation keyframes (though I do not know why precisely). I will have to dig into the PyCarrara source code soon and see if I can discover details on this.

    I tried to create several work-arounds including attempts to re-orient BOIDs in their zero'ed rotation and to adjust rotational calculations, but was unsuccessful.

    For now, you can re-orient simple BOIDs (vertex objects) by going into the vertex modeller (editing the master), selecting all vertices, and then rotating the object so that it is facing in the +X axis. More complex BOIDs (group objects) require selecting all children objects, rotating them, and then repositioning them in their correct locations within the parent (group) object.

    I will make a simple solution to this problem a priority for V0.6.

    Post edited by FractalDimensia on
  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    For those interested in following this slow-moving saga, I thought I would share my current thinking with respect to creating animation walk cycles.

    As always, your thoughts and feedback are welcome. Please let me know if you have any suggestions for improving the direction I am going with this!

    First, in an attempt to reduce confusion, I have settled on the use of the following terms for PySwarm:

    PySwarm Animation: The comprehensive set of keyframes PySwarm inserts within a Carrara scene to create realistic object animation.

    BOID Movement Animation: PySwarm's insertion of keyframes in a Carrara scene that translate (reposition) and rotate (turn, bank, and pitch) BOIDs during Carrara scene time frames selected by the user. BOID movement animation was introduced in PySwarm V0.3. Movement animation will continue to evolve.

    BOID Motion Animation: PySwarm's insertion of keyframes within each BOID to create realistic body motion (flapping wings, wiggling tail, walking, etc.) BOID motion animation will be introduced in PySwarm V0.6, and evolve through later versions.

    Motion Animation Phase 1
    The first phase of motion animation will provide basic motion cycles for many natural and mechanical BOIDs.

    Examples of motion animation that will be possible with Phase 1:
    * Birds and insects flapping their wings
    * Fish moving their tails, fins, and gills
    * Car wheels rotating
    * Helicopter rotors and propellers rotating

    While this phase is being designed to manipulate BOID rigging (bones), any child object can be animated.

    Bone and child object motion animation will include the ability to:
    - Translate, rotate, and scale
    - Apply to any combination of axes (X,Y,Z)

    Motion animation control - You will be able to control:
    - animation cycle type by selecting sinusoidal, square, sawtooth, and triangle wave forms
    - amplitude of animation: min and max values
    - motion (cycle) frequency: duration of a cycle
    - keyframe insertion rate

    Up to 10 different motion animation "channels" can be defined, each manipulating different bones/child objects. Phase 1 animation will work with ERC to enhance animation further.

    You will also be able to set different amplitude and frequency values for BOID stationary, min and max speeds. PySwarm will adjust the motion animation based on these settings and each BOID's current speed. This is useful in the following kinds of scenarios (examples only):
    * Car wheels spin consistent with the car's speed
    * Fishes' tails move faster at higher speeds, or stop when landed (stationary)
    * Bird wing motion can be more exaggerated (greater amplitude) when flying faster

    Motion Animation Phase 2
    Phase 2 (in PySwarm V0.7) will enhance motion animation by focusing on creating more complex banking (left/right motion) and pitching (up/down motion) animation. Motion variations can also be controlled by BOID size.

    Examples of motion animation that will be possible with Phase 2:
    * Wheels that turn (steer) when a car is turning left or right (change of heading)
    * Birds flap their wings harder when in a climb versus a dive
    * VTOL jet engines that adjust side-to-side to handle banking and pitch
    * Smaller BOIDs' wings/tails/fins that move faster than larger BOIDs

    Motion Animation Phase 3
    The final phase will provide human walk cycles via BVH files. PySwarm will import BVH motion animation sequences into BOID motion.

    Post edited by FractalDimensia on
  • 0oseven0oseven Posts: 626
    edited December 1969

    QUOTE Fractal

    Would like to know how you sorted out the orientation problem. I’ve bumped this issue high on the priority list for V0.6
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    This problem begins with how the model is orientated in the model room - the fish points up along the z axis. When its opened in the assembly room there is a compensating rotation setting so that it looks right.

    So I went back to basics and opened the fish in the model room (had to convert to vertex model also) and rotated it to face along the x axis, which meant back in the assembly room the rotations were all zero - which is what PySwarm expects.

    At that point I had not read your note so I understand now how same thing might be achieved by changing the "orientation" to compensate for PySwarm resetting the rotations to zero and a lot easier.

    Either way its a good idea to save out the model with its new settings so you don't have to figure it out later when using it again not forgetting to do it all BEFORE you duplicate objects LOL !.

    Now I know the "trick" I can fix several other models that point the wrong way.

  • DUDUDUDU Posts: 1,945
    edited December 1969

    FD,
    I try to create a project with the PIA, but I do not know which components must be present in the scene.
    For example, I wrote in the script that the safe zone #1 is a cylinder 10x100 feet but, do I have to create a cylinder in the scene or is this a virtual cylinder ?
    Will it be possible to have a model of script with zones of exclusion?
    And also the list of the essential things in the scene by considering as one starts with an empty scene.
    Thanks.

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    FD,
    I try to create a project with the PIA, but I do not know which components must be present in the scene.
    For example, I wrote in the script that the safe zone #1 is a cylinder 10x100 feet but, do I have to create a cylinder in the scene or is this a virtual cylinder ?
    Will it be possible to have a model of script with zones of exclusion?
    And also the list of the essential things in the scene by considering as one starts with an empty scene.
    Thanks.

    DUDU,

    The absolute minimum you need in your Carrara scene to use (import) PySwarm is one BOID. Nothing else is needed, though there is very little to do with just one BOID! Most likely, though, you will likely have several or many BOIDs.
    - If you don't want to manipulate (drive) a camera, make sure "Manipulate Camera" is not checked.
    - If you don't want to manipulate a focus, make sure "Manipulate Focus" is not checked.
    - If you don't have an attractor, make sure "Activate ATTRACTION Rule" is not checked.

    (Obviously you'll need a camera and a light source!)

    With the current version (V0.5.x), you have to define your zones in PIA. You do not need to have objects in your Carrara scene for your zones. (You are right, you can think of these as virtual zones.) However, I have found it useful to put primitives in your scene and place them where you want them; then copy the objects' center and size values to the appropriate PIA fields (Containment tab). These are useful too to make sure PySwarm is setting containment correctly.

    If you want "zones of exclusion," set the zone's mode to "restricted." Also, you don't have to have a safe zone. You can create any combination of safe and restricted zones (up to 10).

    With V0.6, you will be able to reference primitives in your scene (by name) and use them as zones. Further, you'll be able to move and resize them in your scene and PySwarm will use that, something you can't do by defining zones in PIA.

    I hope that helps!
    FD

  • FractalDimensiaFractalDimensia Posts: 0
    edited December 1969

    0oseven said:
    QUOTE Fractal

    Would like to know how you sorted out the orientation problem. I’ve bumped this issue high on the priority list for V0.6
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    This problem begins with how the model is orientated in the model room - the fish points up along the z axis. When its opened in the assembly room there is a compensating rotation setting so that it looks right.

    So I went back to basics and opened the fish in the model room (had to convert to vertex model also) and rotated it to face along the x axis, which meant back in the assembly room the rotations were all zero - which is what PySwarm expects.

    At that point I had not read your note so I understand now how same thing might be achieved by changing the "orientation" to compensate for PySwarm resetting the rotations to zero and a lot easier.

    Either way its a good idea to save out the model with its new settings so you don't have to figure it out later when using it again not forgetting to do it all BEFORE you duplicate objects LOL !.

    Now I know the "trick" I can fix several other models that point the wrong way.

    0oseven,

    Sorry for not responding sooner. Been feeling under the weather....

    Thanks for sharing your thoughts. Yes, your solution is currently the only good way I know of to resolve the orientation problem. I have made some progress testing several alternative solutions, and will have a simple way to have PySwarm automatically adjust to the orientation of the BOIDs, so that you won't have to do any re-orientation work.

    FD

  • DUDUDUDU Posts: 1,945
    edited December 1969

    Here the elements on which I make my test:
    The virtual cylinder doesn't appear in the scene and here the error message which appears, what misses?
    The script is in the download link.
    Afflicted, but with the PIA, one must start from an empty scene…

    http://mhdproductions.be/Carrarators/FD.rar

    Thanks for your patience !

    Load_script.JPG
    542 x 205 - 24K
    Scene.JPG
    742 x 439 - 36K
  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    Here the elements on which I make my test:
    The virtual cylinder doesn't appear in the scene and here the error message which appears, what misses?
    The script is in the download link.
    Afflicted, but with the PIA, one must start from an empty scene…

    http://mhdproductions.be/Carrarators/FD.rar

    Thanks for your patience !

    DUDU,

    I took a look at the script file you sent me.

    I believe the problem is in the script you are attempting to import into Carrara.

    If you look at the screenshot below, you'll notice that line 53 has the following "Vector(0,00,0,00,0,00)"
    It should be: "Vector(0.00,0.00,0.00)"

    If PIA generated this script, then somehow all the "." were replaced with ",", the European symbol used in numbers. What is confusing is that this only happened in the parameter insertion section of the code (except for line 50, which is "fps = 25.0". (See the screenshot.) Other numbers in the script are the US form "0.00"

    I find this is confusing because the generation of the text is hard coded in PIA. I seriously don't know how the periods were replaced with commas.

    Did you edit the script after it was generated by PIA? Otherwise, I have no clue how this happened.

    For the short term, if you edit all the numbers in European format (0,00) to US format (0.00), the script should run fine.
    For the long term, I would need to know more to understand how this happened.

    FD

    Error_line.jpg
    494 x 199 - 41K
    Post edited by FractalDimensia on
  • 0oseven0oseven Posts: 626
    edited January 2014

    QUOTE
    Sorry for not responding sooner. Been feeling under the weather….

    Thanks for sharing your thoughts. Yes, your solution is currently the only good way I know of to resolve the orientation problem. I have made some progress testing several alternative solutions, and will have a simple way to have PySwarm automatically adjust to the orientation of the BOIDs, so that you won’t have to do any re-orientation work.

    I have played with a few more models and found some which have a lot of components do not open entirely in the model room as one set of objects so each component has to be brought in seperately and repositioned which actaully is quite a pain so if an orientation setting could be managed in the pyswarm interface that would be the way to go.

    Hope your are not suffering carraratitus and trust you are feeling better !
    cheers

    Post edited by 0oseven on
  • FractalDimensiaFractalDimensia Posts: 0
    edited January 2014

    0oseven said:
    QUOTE
    Thanks for sharing your thoughts. Yes, your solution is currently the only good way I know of to resolve the orientation problem. I have made some progress testing several alternative solutions, and will have a simple way to have PySwarm automatically adjust to the orientation of the BOIDs, so that you won’t have to do any re-orientation work.

    I have played with a few more models and found some which have a lot of components do not open entirely in the model room as one set of objects so each component has to be brought in seperately and repositioned which actaully is quite a pain so if an orientation setting could be managed in the pyswarm interface that would be the way to go.

    Hope your are not suffering carraratitus and trust you are feeling better !
    cheers

    Okay. Because I know this issue can be such a pain and since many objects you may want to use with PySwarm are not oriented in the +X axis, I am making an unofficial patch version of V0.5.1 available that will work until I can come up with a better solution in V0.6. This is not an official version because I have not had time to test it fully, but in the few test cases I created, it worked fine, and did not require editing the BOIDs in any way.

    You can download this patch shell here:
    https://drive.google.com/file/d/0B8V9-txK8F4MbHB3NHlVZ0FfZzQ/edit?usp=sharing

    (I suggest dropping the shell script in the same folder you have for V0.5.1.)

    Below are the step you will need to follow to make this solution work. It is really only a few minor changes to what you have probably been doing before. I'll walk through the entire process for creating your scene. I'll also post these steps on the wiki and reference it in the V0.5.2 release notes when I update the first post in this thread.

    You can download the example (Bomber Test) scene and script that I used to demo/test this here:
    https://drive.google.com/file/d/0B8V9-txK8F4MSWs3eGpTX1ZacU0/edit?usp=sharing

    1) Create a new scene (at the resolution you want). In my example, I chose a large scene.

    2) Drag and drop your BOID object(s) into the scene. Make sure that the orientation and rotation values for the BOID are cleared out (all set to zero). I chose the B-2 (the one DUDU was using for his study). See screenshot 1.

    3) Duplicate the BOID (or just drag and drop multiple copies into the scene). I used a replicator, set the grid to 4x4x1 (16 bombers), and clicked "Create real instances". See screenshot 2. I then deleted the replicator object, leaving the 16 grouped B-2's.

    4) Name the group and number the BOIDs. I renamed the group of B-2's "Fleet" and numbered each bomber 1-16.

    5) Note the orientation difference from the +X axis. Select the entire group (not the individual BOIDs) and rotate the group so that the BOIDs are facing the +X axis. This will re-orient the BOIDs so that the LOCAL rotation (within the group) is still 0's. Only the group's rotation has been altered. In my scene, I needed to rotate the BOIDs in the Z-axis 45 degrees. See screenshot 3 (last image).

    6) Save your scene as backup. (Always!)

    You're now ready to use PIA to generate the script.
    7) Start PIA, start a new project, and set the parameters. NOTE: For the name of your BOIDs, you will need to provide names to the full path so that PySwarm can find them, with each descendant object's name separated by a "/". In your scene, you should enter something like:

    GroupName/BOIDName

    In my scene, I entered: Fleet/B2-

    Some of the other parameters I set for my test scene were as follows:
    - End Time: 45 seconds
    - Frame Rate: 1 per second
    - # BOIDs: 16
    - Initial Speed: 100 ft/sec
    - Cohesion, Attraction, Separation, Max Speed, and Containment were activated.
    - 1 Containment zone: Box, Safe, Centered at the origin (0,0,0) with size (6000, 6000, 600)

    8) Before generating your PySwarm script, you will need to update the shell script reference. Click the "About" tab, then "Browse," navigate to the folder you downloaded the patched script to ("PySwarm Shell V0.5.1a"), select it, and click "Open."

    9) Generate the script. I saved my script as "Bomber Test.py".

    10) Import the script.

    Please note that I realize the resulting bomber BOID animation does not simulate how real B-2s fly! Further tweaking and adjustments would be required to make this animation look realistic! However, you will note that the bombers are flying in the right direction.

    I'll do several more tests using this approach in the next 1-2 days and report my findings, along with making the scenes available for download.

    I hope this helps!
    FD

    Work_Around_Shot_3.jpg
    1645 x 779 - 263K
    Work_Around_Shot_2.jpg
    1641 x 959 - 315K
    Work_Around_Shot_1.jpg
    1507 x 959 - 308K
    Post edited by FractalDimensia on
Sign In or Register to comment.