Tuesday, January 12, 2010

Loopable Flag

recently i had a job that required me to create a looping animation of a flag. i was very fortunate to find such a tutorial on THE AREA.com located here:
the tutorial was invaluable and allowed me to achieve the effect. as i went thru it i found tools and techniques i wasn't aware of and thought it would be helpful to put some more details about the process into writing.
scale is always an important factor when computing any kind of simulation. make sure your units are set the to match the image.

----------
create a plane in the front viewport using the settings in the image.

----------
in the original tutorial he creates seams running the length of the flag, in this one i'm creating them around the border. i added an edit poly, selected the edges that define the border and chamfered them.

----------
select the plane and from the modifier panel and add cloth. click add objects and choose the Plane01 object. match these settings w/the image by choosing satin from the presets menu. this sets the dynamics for the entire flag.

----------
open the sub-object group section under the cloth modifier. i needed to pin the two corners of the flag, so i selected the corners, applied some soft selection, clicked "make group" and then click preserve. this locks the corners of the flag and will prevent them from the dynamics calculation. (in the original tutorial a selection set is made out of the vertices that make up the border and are applied the settings of burlap or rubber. this increases calculation times and i didn't need it for my sim)

----------
i ended up using two wind space warps linked to dummies. the dummies have noise controllers added to their rotational values for some randomness. i needed more "violent" motion in the flag and that's why there are two.

----------
next add the wind forces via the cloth forces button. i also lowered the gravity so the flag would appear larger. i then clicked the simulate button and waited 5 hours for 1000 frames to calculate. (i'm using dual quads @ 2.33 ghz w/8 gigs of ram)

----------
when the sim is complete and looks good add the point cache on top of the cloth modifier. click record and save the resulting cache file on your network in case you need render servers to see the file. you can then delete the cloth modifier. you'll notice that the max file before the point cache is several hundred mgs depending on the length of your animation and after it's much smaller that's because the animation data was transferred to the cache file, that cache file will be several hundred mgs.

----------
in the playback type area choose playback graph from the drop down, go the the last frame of your animation turn on the animate button change the frame number to match the length of you animation. this is done so that you can move the animation in track view. make a copy of the flag.

----------
first thing to do is isolate a section of the flag for the loop, in this case mine is 200 frames towards the end of the sim. in order to get the flag animation to loop offset the flag copy animation by moving its' keyframes by the amount of animation or in this case 200 frames.

----------
as pointed out by vitsly a simple morph will not work, he came up w/the brilliant idea to use a "wipe" style morph by using the vol select modifier. using the settings in the image including the soft selection. turn on the animate button and in this case move the vol select gizmo to the left until there's no soft selection effect on the verities. (the vol select should be moving in the same direction as the wind) since we're not on frame zero and keyframe was automatically create @ frame zero, in track view move the keyframe @ zero to the end of your animation in this case frame 800. this step is crucial because the keyframe created on frame zero is the exact center of the gizmo on the object and thus will create an exact loop.

----------
add the morpher modifier and use the settings in the image and that's it. again hats off to vitsly for a very cleaver solution to a complex problem!!!!

----------
wireframe of the animation:
----------

2 comments:

  1. Very handy tutorial! Thank you for posting this

    ReplyDelete
  2. 3dean, surely the answer is no, but a lame question...
    ive got a deadline a couple of hours to go, its going to take a lot of time doing it, u know what i mean :( , if only i could use the source file.. seriously i need help..

    ReplyDelete