A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: [MX]Wind Simulation

  1. #1
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343

    [MX]Wind Simulation

    Hello, first let me say I suck at math. However I do know how to code in AS fairly well. I am working on a flash project where I want to have a picture of trees that I've taken to seem as if they are moving in the wind. There isn't really any detail to the image, it was changed to pure grayscale, then inverted to be the negative of the image. Looks like something from a Hitchcock film. If it would help further I can upload the image to be looked at. Thanks in advance for any help.

    Mo

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    145
    so what is specifically your problem?

  3. #3
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    You won't be able to get a realistic effect from a single bitmap. The best I can think of would be randomly skewing it, and it will just look fake in a dumb way.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  4. #4
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343
    ArielGenesis; specifically my problem is I don't know where to start to produce the effect I'm after. I'm looking for ideas of any kind.

    691172002; I had pretty much decided that a single bitmap wouldn't work as you said. I traced the bitmap within Flash and figured I would make each branch either a mc or a graphic. As for the "wind" effect, I thought about skewing each branch like you said but agree it would look fake and stupid. I knew simulating gravity to an extent was possible in Flash so I wasn't sure if this was. However I had no idea as to where to even begin. I may just try to animate it out on the timeline, I'm not sure. I was also going to have a wind sound play when the branches moved. The louder the volume the more the branches moved. Timeline animating this will more then likely result in a large file.

    Thanks to both of you for your replies

    Mo

  5. #5
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    If you just traced it, there will be gaps in the background where the branches were. Imo your best bet is a fractal tree drawn via code since you can get very realistic swaying, but fractal trees have their own look (and lag).

    Unless this is a critical part of your project, I suggest looking for something else. It is very possible, but is a lot of work.

    What version of actionscript are you using?
    Here is an example, with 3.0 you may be able to animate something of this complexity:
    http://www.kirupa.com/developer/acti...os_fractal.htm
    Its up to you if you think it will fit in with the bitmap.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  6. #6
    Senior Member
    Join Date
    May 2006
    Posts
    145
    woww, nice tree

    I believe by using multiple image, a strong intuition in math and physics, and of course AS, a bend and skew tree might look realistic enough. or if your aim is not realism but enjoyment, it could be funny and unique too.

  7. #7
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Sounds interesting. I am subscribed...
    who is this? a word of friendly advice: FFS stop using AS2

  8. #8
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343
    6911; I checked out the link you left. Very interesting. Definitely a possibility. As for the AS version, I am using 1.0. Hoping to soon be getting Flash CS3 though. I'm not sure which direction I'll end up going yet The amount of work required doesn't bother me. I'd gladly do the work if it results in a cool effect that doesn't look retarded. At any rate I greatly appreciate your thoughts. Thank you.

    Ariel; I had thought about running the route of multiple images like you suggested. And I may do a mix between scripting and mulitple image tweening with skew. I am out for realism on this particular project. However, now that you mention it, I do see where there'd be alot of applications for such an effect. Also as you had said if one had a "strong intuition in math and physics"....that alone ruled me out! I get confused when numbers are mixed in with letters in math. I thank you though for taking the time to offer some ideas as to how to attempt such a project.

    I uploaded the image that I wanted to use for the wind effect just so you guys could see what I was planning to use it on.

    Mo
    Last edited by Mo1010427; 02-17-2008 at 03:39 AM.

  9. #9
    Senior Member
    Join Date
    May 2006
    Posts
    145
    woww great.
    the tree is great
    but to move the bushes, that would be hard.

    And I think doing vector fractal for the tree is a great idea. but still, you need math and physics. the only way to get through math and physics is to make a frame per frame animation. the only way make computer generated simulation is to learn a math and physics even for simple one, which unfortunately does not refer to this. If you want to learn. I think there will be a lot of people who will help you to learn math and physics in forums, like this one.

  10. #10
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Here is an AS3.0 example I made. I highly, highly suggest running it in the standalone player (download it) since it looks like crap when resized the slightest amount.
    It generates a new tree every 50 frames.

    http://img516.imageshack.us/img516/6448/ftreesp9.swf

    Source is here but I use the standalone compiler so I don't know how easy it will be to integrate into what you have.
    http://www.sharemation.com/691175002/FTree.zip
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  11. #11
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343
    Ariel; The bushes I'm not necessarily worried about moving. Those could even be ommited from the image. The biggie was the main tree. I think I will start doing a little research on physics and the sort to get a better idea of things. It seems that I'm always finding myself doing more and more complicated projects....this results in more and more math :-p

    6911; I checked out your link once again. I actually like how the branch swayed. Was that skewed to achieve the effect? I tried looking at the zip file on sharemation but it says I have to login using a username and password. I was most concerned with the slight bending of the branches which helps sell the feeling of the trees blowing. Your example captured that. It looks as if you skewed the image mostly, but then made the main branches appear to flex slightly. I'm very interested in how you accomplished that.

    Thanks guys

    Mo

  12. #12
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Sorry about the password thing, I have fixed that.

    Essentially I draw a fractal tree, store the mathematical data of each branch, and alter the angles slightly each frame (redrawing each branch in its new position). I haven't counted, but I guesstimate that there can be nearly a thousand branches being simulated and drawn.
    Actionscript 3.0 actually really surprised me here, I didn't think it would have the performance.

    Its the most visible on the largest branches, but each branch is changing angle every frame, with some tweaking of the constants, you could probably get an even more realistic effect.

    It's powered by a pretty warped case of recursion (it was the quickest way I could think of throwing it together), but it works.

    This effect could also reproduce bushes nicely (reduce the length of the branches, make them angle out more...), I can make the class more user-friendly if you would like, right now it is really messy.

    Have you used AS3.0 or BitmapData before?
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  13. #13
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343
    Unfortunatly no on both cases. I've actually never even heard of BitmapData before. Right now I'm using MX, which is AS 1 only. I'm hoping to get CS3 but I'll also have to build a new PC since this one will in no way be able to run it. I might be able to use a swf decompiler just so that way I can look at the AS code that you used so I can get a better idea. Obviously though I realize MX won't support some of the scripting. I'm headed to bed here pretty quick, but I'll check out the source first chance I get.

    Mo

  14. #14
    Senior Member
    Join Date
    May 2006
    Posts
    145
    Well I suggest you to get your new computer first. doing vector not is AS3 is a pain in the butt for running the engine. so 691175002: nice job. I understand the concept but I am totally new to vectors so, wow.

    I think you can use 691175002's code. Just a little bit more tweaking and some values to make it more realistic then, there you go!!! may be if you include fibonaci sequence somewhere in the tree making, you can get it more realistic!

  15. #15
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    As far as I know, CS3 doesn't have higher system requirements. I can't see why it would.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  16. #16
    Senior Member Mo1010427's Avatar
    Join Date
    May 2005
    Posts
    343
    Sorry for the long delay in my responding, it's amazing how busy one can get without even trying.

    6911; I looked over your AS, gonna take me a bit to figure it all out, but I'll get it. It's interesting to see how AS3 looks alot like VB as opposed to how AS1 looks alot like Java. Anyhow, I greatly appreciate all your help!

    Ariel; I think I am going to take the route you mentioned and purchase the new machine first. There are several other things that MX simply isn't capable of that would be a huge benefit to me. One is the flush method for .sol's. You said I might be able to use a fibonaci sequence, I'm not sure what that is but I plan on researching it throughly to figure all this stuff out. I sincerely appreciate your advice on this subject matter as well!

    You guys take it easy. Thanks a million!

    Mo

  17. #17
    Senior Member
    Join Date
    May 2006
    Posts
    145
    hahaha good to hear that!

    Fibonacci sequence, of course you know that,
    1,1,2,3,5,8,13,21,34,55,....
    where a the next number is the a number added by the previous one
    you can look here for more:http://en.wikipedia.org/wiki/Fibonac...bers_in_nature

    and what's so great about it? I happen to know that nature somehow arrange it self, like how length of a branch (not sure) in Fibonacci sequence. So I suppose if you use this, you might be able to get more realistic tree!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center