Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 28-08-2007, 02:27 PM   #1
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 28-08-2007, 07:09 PM   #2
AlphaFlyte
Subscriber
 
AlphaFlyte's Avatar
 
Join Date: Nov 2003
Location: Sweden
Posts: 326
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
__________________
Currently working on reclaiming Space
The Salvation Prophecy
AlphaFlyte is offline   Reply With Quote
Old 29-08-2007, 01:59 AM   #3
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

'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
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 29-08-2007, 02:08 AM   #4
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 29-08-2007, 02:12 AM   #5
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 29-08-2007, 04:46 AM   #6
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net

Last edited by t1ck135 : 29-08-2007 at 04:50 AM.
t1ck135 is offline   Reply With Quote
Old 29-08-2007, 05:48 AM   #7
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 29-08-2007, 07:23 AM   #8
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 29-08-2007, 04:14 PM   #9
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 03-09-2007, 02:56 AM   #10
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 03-09-2007, 10:13 AM   #11
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 03-09-2007, 10:40 AM   #12
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 04-09-2007, 06:27 AM   #13
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
t1ck135 is offline   Reply With Quote
Old 04-09-2007, 07:51 AM   #14
mirek03
Subscriber
 
mirek03's Avatar
 
Join Date: Feb 2006
Location: Australia
Posts: 2,752
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
__________________
take it easy and life will be easy
mirek03 is offline   Reply With Quote
Old 04-09-2007, 08:04 PM   #15
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net

Last edited by t1ck135 : 04-09-2007 at 08:09 PM.
t1ck135 is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.