Page 1 of 2 1 2 >
Topic Options
#180865 - 03/18/10 10:40 PM Realistic waving flag / cloth example + wind
Andos
Clickteam


Registered: 06/29/06
Posts: 1558
Loc: Århus C, Denmark
I little cloth physics experiment that kinda evolved into a waving flag with shading and all smile

Requires Overlay Object. (available here)

It works like this:
I always add some value to each point's velocity vectors which controls their speed and direction. I always add a gravity factor, but also a semi-random wind factor (based on a lot of sine-waves) which prevents it from falling all the way down.

I then loop over all points and draw a polygon over 4 points to get a vertical 'slab'. Most of the time I draw a red polygon but also a white polygon at the center (this makes the white horizontal stripe through the flag)
At the vertical lines 6 and 7 I only draw a completely white polygon to get the vertical white stripe.

Shading is calculated by doing a dot-product on the flags surface normal vector and with the direction of the light. This gives me the amount of light each polygon has which I use to correct the color.

The result is this waving flag smile

You can control the points where the flag is anchored by checking the check button to make them visible. You drag them around inside the boundaries of the overlay object.

Would be fun to see the different kinds of flags you can make with this smile


Attachments
realisticwavingflag.mfa (171 downloads, build 249)

_________________________
www.andersriggelsen.dk
~ May the parse be with you

Top
#180866 - 03/18/10 10:45 PM Re: Realistic waving flag / cloth example + wind [Re: Andos]
Adam


Registered: 12/20/06
Posts: 615
Loc: England, UK
This is one of the most impressive effects Ive seen done in MMF2 smile Playing with the anchor points alone is a somewhat satisfying activity.
_________________________
www.Gamebuilder.info


Top
#180867 - 03/18/10 11:16 PM Re: Realistic waving flag / cloth example + wind [Re: Adam]
gerald999


Registered: 02/21/08
Posts: 365
Loc: On, Canada
OMG, This is awesome!
_________________________
Gerald





Top
#180872 - 03/19/10 12:59 AM Re: Realistic waving flag / cloth example + wind [Re: gerald999]
SEELE


Registered: 07/19/07
Posts: 1750
Loc: Terra australis incognito
Cool thing Andos!
_________________________
God's in his Heaven -
All's right with the world.



Top
#180874 - 03/19/10 02:17 AM Re: Realistic waving flag / cloth example + wind [Re: SEELE]
netninja


Registered: 06/30/06
Posts: 512
Loc: Australia
This is amazing! Nice example!
_________________________
Faerie Solitaire - Out now! Demo available too! Also on Big Fish Games!
www.Subsoap.com

Top
#180878 - 03/19/10 02:38 AM Re: Realistic waving flag / cloth example + wind [Re: netninja]
StephenL
Forum Moderator


Registered: 08/09/08
Posts: 2608
Loc: Montana
Very cool! laugh

Stephen1980
_________________________
Stephen Lanier
“Flash Extensions. Too many ideas, and not enough time to do them all right now!”
_____________________________
KlikFusion RoundTable Nivram's Examples

Top
#180938 - 03/19/10 09:08 AM Re: Realistic waving flag / cloth example + wind [Re: StephenL]
dragonguy


Registered: 04/03/08
Posts: 2879
Loc: RULE BRITANNIA!
Really Cool! How do I change the flag texture to say something like the Union Flag?
_________________________
I'm the Original Dragonguy!

Email or PM me, all game related ideas & job seekers welcome, terms & conditions may or may not apply.

Top
#180955 - 03/19/10 09:52 AM Re: Realistic waving flag / cloth example + wind [Re: dragonguy]
LB


Registered: 06/07/07
Posts: 5010
Loc: Richardson, Texas, America.
This looks 3D, it's hard to believe it's just 2D with shading. That is, until you get it to draw the parts that are behind it infront of it's self...

Just a really cool and great example! I got a steady 27 FPS here. XD
_________________________
~MMF2 Developer User~
Build 249 & Flash
XP Home SP2
"The possibilities are endless." --Stephen Lanier, 2010
~ May the parse be with you

Top
#181112 - 03/20/10 05:33 AM Re: Realistic waving flag / cloth example + wind [Re: LB]
Andos
Clickteam


Registered: 06/29/06
Posts: 1558
Loc: Århus C, Denmark
Thanks for the comments smile

To make something like the union flag you would have to figure out a way to draw the diagonal stripes "slab" by "slab". I just drew the white stripes over the red polygon, but I had to make it slightly larger than the slab because of some red showing through. I might change this example so it instead draws one part of the flag at a time. This would not only fix the problem but probably also make it easier to draw any shape in the flag.

I suspect one of the reasons this example is so slow is also because of it being drawn in Overlay Object. It will redraw the entire background every frame which is very slow. Not sure if removing the gradient backgrounds will speed it up for you.
A way around that would be to use Active Overlay while the actual overlay is invisible.
_________________________
www.andersriggelsen.dk
~ May the parse be with you

Top
#181307 - 03/21/10 09:56 PM Re: Realistic waving flag / cloth example + wind [Re: Andos]
uprize


Registered: 03/26/07
Posts: 1337
Loc: Sydney, Australia
Wow this is cool!
_________________________
previously know as bigredron

Top
Page 1 of 2 1 2 >


Site Links
Forum Index

Home Page
Online Store
Tutorials
Download Center
French Forum

Quick File Links
Multimedia Fusion 2
Updates - build 249
Standard Version
Developer Version

Extension Packs
Bonus Pack 1
Bonus Pack 2
z33z Extension Pack
LIJI Extension Pack

The Games Factory 2
Latest Update - build 249
Community Links
Fusion Wiki
MFA Repository
Klikdisc
The Daily Click
GameBuilder

GB Arcade
TDC Arcade
Madword

Extensions
Neatwares Extension List
Extension Updater

Lacewing & Moo Server
Klikfarm

Money from your games
Click Chat
9 People are chatting
Game Builder

Visit the GameBuilder Homepage

Recent Download

Dungeon Master

Latest News