Cloth simulation modifier in AS3Dmod


flagI was recently invited to create a cloth modifier for AS3Dmod by Bartek Drozdz, similar to the 2D version I did earlier. In the unlikely case you haven’t heard about it before, AS3Dmod is a cool modifier library compatible with the most popular 3D Acionscript engines (Papervision3D, Away3D, Sandy and Alternativa3D). To put it simply, it takes existing 3d meshes and changes its shape on a per-vertex basis, and also allows you to animate them without needing an animated model. Lucky for me, as I was interested in doing a 3D version, and this was the perfect setup to do it in :)
The cloth modifier provides some methods and functions to adjust its behaviour (rigidity, air friction) as well as to apply external forces such as gravity or wind. You can also set boundaries to act as fake walls or floors. This modifier works best with meshes that have a flat edge, such as planes, boxes/cubes, cylinders, … This so they can be locked in place at an edge and actually give you something to look at instead of having a mesh that gets blown out of the view straight away :)
One last remark is that the cloth should be the first in the modifier stack. It needs its previous state, and any prior modifiers changing its state will not have any effect.
On to the demos!
  • Flag sim with parameters to play with (Papervision3D, 600 triangles): Demo | Source
  • Hanging cloth with fake floor and wind (Away3D, 450 triangles): Demo | Source
  • Strange cube being blown about (Away3D, 1200 triangles): Demo | Source
Get AS3Dmod on Google Code.

13 thoughts on “Cloth simulation modifier in AS3Dmod

  1. I have saw too this interested lib. It more interested for me because it requires FP9. My friend without new Core XX CPU got interested slowdowns with as3mod’s swf demo )))

  2. Beautiful! I’ve compiled it myself (with some very minor tweaks for CS4), and it works, but it really chugs along terribly. It seems to go about 20x slower that it should :( And yet the demos above rocket along.

    Any ideas why?

    PS: I have the latest Tweener, away3D and polygonal classes, so i don’t think it’s that.

    PPS: My tweak for CS4 was to remove the Embed tag and use a library bitmap instead, instantiating it with the line…

    material = new BitmapMaterial(new _textureAsset(311,668));

  3. Hi Chichilatte,

    Apart from the texture asset, are there any other changes? The amount of triangles in your source 3D object impacts the performance a lot, since every connection between vertices means extra calculations. If that’s not the case, try compiling a release version and see how fast that goes, it might just be the debugger.

  4. Raay, i fixed the problem! I was using an old Away3D.swc library. I made a new swc in FlexBuilder using the latest repo version and it goes like the blazes :)

    But it has added an extra 50k to all my swfs. agg.

    Note: here’s how i made my swc (the Away3d swc doesn’t seem to be publicly available, only the .as source from the repo)…

    thanks for yr help david++

  5. a question, i downloaded the examples but i cant find the class, where is it, is no within as3dmod package in google…

  6. Mr., David i would like to ask u a question, its possible to use the as3mod on a collada in way3d? i was trying to make on, but i always get black screens

  7. I’m not sure, actually. Since it’s animated, it could be that away3D animates the vertices after as3dMod updates them (ie: the as3dmod modifiers are undone). But you should definitely not get a black screen: the worst that could happen is that you see the model in its normal state.

  8. im using this code:

    model1 = Collada.parse(Charmesh, {scaling:.3, material:material});
    _modifierStack = new ModifierStack(new LibraryAway3d(), model1);

    // create cloth modifier and add it to the stack
    _cloth = new Cloth();

    private var model1:ObjectContainer3D;
    //texture for mario
    private var Charmap:Class;

    //collada file for mario
    private var Charmesh:Class;

    at the end in away3d you work with mesh or objectcontainer, so maybe im doing something stupid as usual, cause it works with the mesh, but cant get to work with the containers… it is only me?

  9. Sorry, in my last post I thought you were using an MD2 instead of a collada (I’ve been working with md2 the whole day today :) ).
    I don’t think that As3DMod supports any hierarchy. It only takes the vertices of a mesh and displaces them, which is probably the problem you’re facing (and why ObjectContainer doesn’t work). You could loop through the collada’s children and assign a modifier to any mesh you encounter. The modifiers will always happen relative to their own coordinate system’s origin point tho.

  10. lol, yes it happens, sometimes im not so clear when i try to explain things.

    ok the good news is that i found a way, due that i was overlooking that the .dae are in fact an entire scene, i wouldnt be abble to attack the geometries directly so what i got to do in this case was to stick some theories together, and at the end what i did was to call as a mesh the part of the scene that contained the geometries of the model (o_O’ say it fast twice) and voila,
    got my model in collada with perlin, wind, well u call it, in fact what i did was to convert not the obect container, but the part with geometries to a mesh in away so i could use it :D so happy now.

Leave a Reply

Your email address will not be published. Required fields are marked *