Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   bFlocking artificial flocking tool (https://simplymaya.com/forum/showthread.php?t=27315)

t1ck135 28-08-2007 01:27 PM

bFlocking artificial flocking tool
 
Here's a custom Maya tool I've written in Python to generate artificial flocking or 'boids' based on the work of Craig Reynolds. Its an early version but has a few controls in that might be useful.
It might also be useful for people learning Python within Maya as it generates windows with user interface controls as well as generating objects in random locations.

bFlocking v0.1 Maya 8.5+

Have fun ;)
Si

AlphaFlyte 28-08-2007 06:09 PM

Quite an impressive project you got going here Si. I haven't taken it for the test spin yet, but I will try to find someone with Maya 8.5 in my surroundings and see how it does.
I'm glad they incorporated Python too now. It really seems like power at your finger tips and it seems quick to learn. Have you read any really great Python books? I'd love to dig a little deeper than say "Hello world" and basic loops.

Can't wait until velocity and separation is keyable. Perhaps in v0.2? =)

Thanks for sharing. It's going to be interesting to see the UI python code, as well as the flocking of course :)

mirek03 29-08-2007 12:59 AM

'In the scripts folder there may or may not be a userSetup.py. If there is not then create it '

err, no i dont have this in my folder and i do not know how to create it much less edit it. Never used python Tick, is there a tut i can find to create this usersetup.py

t1ck135 29-08-2007 01:08 AM

Thanks AlphaFlyte :)
Yeah I'm glad they incorporated Python into Maya as it is a powerful language and is incorporated into loads of things now - I used to play Eve-online and it was good to hear that they use it lots in that.
The actual catalyst to using Python and not Mel was because I still do a little work at my old job writing custom elements for a Content Management System called Plone - and it is written in Python :)
I also had a play with Mel and once you know a C style language (PHP in my case) then it is real easy to pick up and use.

No books, it was all online (and therefore free)
I just visited the Python website and started reading a few things in the beginners section http://wiki.python.org/moin/BeginnersGuide/
and guess what? I even went through the good old hello world stuff ;) Still havent gone through tuples and dictionaries yet tho..

If you want to rip out the UI code and have a play with it then please do - it is really quite straightforward, the only problems I had was that some of the options/methods dont seem as clear as in Mel but thats probably because its newer. There are comments in the code that might help understand it a bit better.

Some kind of caching is definitely the next step as realtime playback can be really bad if there are lots of boids/objects

Si

t1ck135 29-08-2007 01:12 AM

sure mirek,

Open up notepad (or if on the Mac then the equivalent text editor) and type in the required line. Now save the file as userSetup.py in the folder that it states. If using windows then it might try and save it as userSetup.py.txt so in the 'save as type' box change it to 'All Files'. This should remove the .txt bit
Now restart Maya and things should happen ;)

Si

t1ck135 29-08-2007 03:46 AM

Ah ha, just found out how to access particles as a group as well as individual particles and their attributes through Mel/Python.
This means I should be able to rewrite the system to use the particle generation method (i.e, the user can add the particles where they want on screen) and also use the particle caching system that particles have access to :)

Edit: This should also allow me to use the particle object (hodling all the particles) as the keyable object for changing velocity and separation etc...

Cool!

Si

mirek03 29-08-2007 04:48 AM

sounds like your on a happy roll tick :)

the movies are getting intensive.., i spent a couple of hours with the script but because i dint know how to write the python script (now you have shown me) I sort of ended up playing with particles and fields.

great you are getting this happening.

point.., it could take a while before I get this together.., im starting to get paralysis from the stress of too much work.., too many deadlines.., but it will get done. priorities!

M:)

t1ck135 29-08-2007 06:23 AM

hehe, its good fun getting into the particle thing (not that I've done much yet) :)

I might have a new version up at the end of the week that uses the built in particles for generation and placement. I'm just cutting out lots of unnecessary code at the minute and am hoping to get it all going - it'll make it a lot simpler to do stuff, kind of going along the lines of what Steve (gster) was saying

Si

mirek03 29-08-2007 03:14 PM

i got half way through reading that stuff Steve was doing with boids (???.., sounds like 'androids'..??) and sort of went blank.., sounds amazing. I like code but html is about my limit and CSS, maybe a little kava and action script but VERY limited.., maybe one day.., but I think id prefer to storyboard something.., maybe if i get a few years behind bars sometime I'll check pythion script (thats a joke!)

M:)

t1ck135 03-09-2007 01:56 AM

I'm gonna have to put a temporary hold on the rewrite using maya's particle system mirek. Got some things to get sorted for next week but hopefully once thats out of the way I can get back on track.

Si

mirek03 03-09-2007 09:13 AM

no problem, the movie gets locked off in a couple of weeks. Ill have a go with what I got unless you get it togeher. I was talking to the guy yestrday, he wants me to have a go at it.

M:)

mirek03 03-09-2007 09:40 AM

I think you have done a good job of it.., there are a few errors thrown up lile 'no sims' (whatever that is?? But im running my first simulation now. I am brain dead at the momet..,, so, how can I change the objects to whatever I create as flies,, as Steve said, probably cubes with wings.

t1ck135 04-09-2007 05:27 AM

the code has a line that creates a polysphere or cone but that should easily be modified to make a copy of an existing piece of geometry.
If I get a little spare time tomorrow morning I'll try and complete the rewrite where it uses mayas particle system (90% complete already). Then judging from some particle tutorials I've seen it should be easy to swap the particles with a model of your choosing and also be able to use the caching element (which I've already got working ok).

Si

mirek03 04-09-2007 06:51 AM

mate, i know you have a lot of work on.., only if you can!

I did a render and it only rendered the first frame.., I think it should be hardware render?? but my graphics card cant do it with 8.5.., i'lll have to put the ATI back in.

cheers dude

t1ck135 04-09-2007 07:04 PM

There you go mirek, version 0.2
http://www.flash-fx.net/3D/tools/bFlocking/

View the readme files for new instructions on using Maya's particles instead of them being auto generated.
All you will need to do is copy the new bFlocking.py over the old one.
I've included some default settings for swarming in the readme that might help :)

EDIT: The last version didnt work correctly with frames and so as you found you weren't able to render it properly. This version definitely now works when rendering per frame.

Si


All times are GMT. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018