Bend modifier - part II

UPDATE Sept 9th, 2008. The Bend modifier is now part of AS3Dmod library. Use that one instead of the class linked below.

First of all, thanks for the great feedback I got after the first post on bending. I really appreciate it.

This time, I post an updated version of the Bend class for Papervision3D that works with every simple DisplayObject3D - that is, a DisplayObject3D that does not contain any child objects. Click here for a demo. The algorithm has been refined and the class public methods have been changed. Here's an updated use-case:

Actionscript:
  1. do3d = new SomeDisplayObject3D()...
  2. bend = new Bend(do3d );
  3. scene.addChild(do3d );
  4. bend.bend(Bend.X, Bend.Z, 2, 0.4);

The bend() method accepts four arguments, out of which the two first are new:

  • The axis of the bend
  • The direction of the bend

Now: I tried to write the theory behind those axes. I really did! But then this post was becoming boring and highly incomprehensible, so I gave up.

The best thing to do is to experiment with those setting. Each argument can take one of the three values: Bend.X, Bend.Y and Bend.Z. Different primitives will need different settings for the bending to look correct, but on the other hand, playing with them can lead to quite fascinating and weird-looking shapes, so be sure to try different combinations.

If you do not have time to experiment however, I created a special method, that magically bends the object the right way:

Actionscript:
  1. bend.quickBend(2, 0.4);

The two other arguments are 'force' and 'offset'. Both are described in detail in the source code. Additionally, I also published the source of the demo here. Have fun!

18 Responses to “Bend modifier - part II”

  1. Nate Chatellier Says:

    Very nice update!! It sounds like you got my request from your first post in there..? I’ll start playing with it tonight. Thanks again!

  2. Nate Chatellier Says:

    So I got it up and running with the current rev (592) of pv3d. If anyone else is trying to do this, please copy and paste the following imports over the current list of imports and it will work:

    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.Collada;
    import org.papervision3d.objects.Cone;
    import org.papervision3d.objects.Cube;
    import org.papervision3d.objects.Cylinder;
    import org.papervision3d.objects.Sphere;
    import org.papervision3d.objects.Plane;
    import org.papervision3d.core.proto.MaterialObject3D;
    import org.papervision3d.core.geom.Vertex3D;

    And, alas, there is still no feature to limit the Bend’s effect, so it only works on half of a plane instead of the full plane (for example). Still an outstanding class and I really appreciate your work Bartek, but I would LOVE to see a limiting parameter added :)

  3. carlos Says:

    That’s awesome! Very useful.
    I guess the next step now would be adding a custom source point for the bending; instead of the middle of shape, it could happen from an arbitrary coordinate. For example, it would be very useful to animate a character wagging its tail or a page flipping.

    Great work!

  4. Zack Jordan Says:

    Hey Bartek. You’ve got some great stuff coming out here; I’ve seen a couple shoutouts on the PV3D blog. Keep ‘em coming.

  5. bartek drozdz Says:

    @nate. You asked for the limit feature - you’ve got it! Chekout the latest version from SVN and take a look at the ‘constraint’ public property in the class. It can be either LEFT, RIGHT or NONE (I’ve created static fields for that) - which combined with the offset parameter will do the limiting you are looking for. I will document it soon.
    Also - I compile it under the Great White branch, that is why my imports are different, but I am happy that it works for the trunk too.

    @carlos I was thinking about that, but I won’t be adding this feature now. If you want to animate a dogs tail, try to combine bending with rotation.

    PLUS. I have been also asked if the Bend class does work with Tweener. Well, now it does! :)
    A demo and some documentation on that is coming soon.

  6. Evan Says:

    hi Bartek,

    I came across your blog/website a few weeks ago and I must say it is a real gem and tops on my rss list now.

    a year ago I struggled with bending a plane with papervision (for a curling plane page flip effect I was after) but now with your excellent work now will this not only be much easier but bending any do3d has incredible possibilities.

    thanks so much for your contributions.

    Evan

  7. Fabrice Closier Says:

    Very nice to see it works now on any meshes.
    Well done!

  8. Michael Battle - Work & Play » FIVe3D and PV3D goes bendy - Flash and Actionscript Experiments! Says:

    […] back on the PV3D ranch, a new modifier branch has started with this blog post and pretty cool demo - kudos to Bartek […]

  9. Charlie Says:

    For the double sided 100 dollar bill did you just use 2 planes or did you find a different way to include a 2nd side? Or is that really just a very think cube? :)

    Charlie

  10. horidream’s blog » Blog Archive » Papervision3D的”弯曲修改器” Says:

    […] 使用方法 « 粒子系统实现的火焰效果 […]

  11. bartek drozdz Says:

    @charlie I used 2 planes, with a onesided material applied to each. The second plane is flipped 180 degrees. I found this solution on pv3d.org, but now I can’t find the link to that article.

  12. { P I X E L W E L D E R S } | Pokervision3D Says:

    […] is what happens when you mouse over your cards (the closest hand). That is Bartek Drozdz’s bend modifier in action. I think it’s pretty eye-catching. […]

  13. pimsn Says:

    hey,
    thats seriously awesome. i played with it and all was nice in the beginning, but now i’m not getting it to bend anymore for some strange reason. it rather looks like perspective transformation. any idea what the problem is there?

  14. Chris Says:

    Great class, we have been working with it a lot lately, I have one question.
    How can I get the coordinates of the end points? Can you share the formula that you are using so I can calculate them? Or can it be property that can be retrieved?

    I tried looking through the source, but I didn’t quite understand the formulas being used.

    Thanks

  15. Mike Says:

    Thanks for sharing this. My quest to create 3D swimming fish just got saved :P

  16. Mitchell Says:

    I am having a hard time getting this to work. Can someone send me an example project with a fla file included?

  17. Matt Pelham Says:

    I agree with Chris and Carlos. This is a great script but its limitations so far are its inability to stack bends, inability to bend along a custom rotation and its inability to export its finished values. If you’re looking for a more advanced class, check out http://agit8.turbulent.ca/bwp/2008/02/25/dynamic-shape-morphing-with-papervision-3d/ to see some progression with Meshes, the source has been released for free!

  18. bartek drozdz Says:

    @Matt Pelham if you check out my latest post about the as3dmod library - http://www.everydayflash.com/blog/index.php/2008/09/03/as3dmod/ - you will find that stacking and exporting finished values (collapsing the modifier) is something I took care of. As for the question of bending along a custom rotation - I really need it too :) so hopefully it will be available soon.

Leave a Reply