Bend modifier for Papervision3D

Bending objects is one of the classic features of any 3D package. I thought it would be nice to be able to bend stuff in Papervision3D too.

First, I had to spend a couple of days trying to understand the concept of bending. It is fairly obvious when you see it, but when it comes to express bending with mathematical formulas, it is not. Plus, I am not very strong in math, and that doesn't help :)

Eventually I grasped the concept: bending means distributing all the vertices of an object around a point in space. The closer the point is from the object, the stronger the bend. I will prepare a separate post explaining this theory soon. For now, just play with the demo.

Currently the Bend class only accepts Planes, but I am working on a version that will be able to bend anything else. The source for the Bend class is here. It is a very basic version and the algorithm is not yet optimized, but it should give everyone who's interested a fairly good idea on how it is done. You can also grab the class and use it with your planes created in Papervision3D. Here's a basic use case:

Actionscript:
  1. plane = new Plane(someMaterial,  200, 200, 20, 20);
  2. bend = new Bend(plane);
  3. scene.addChild(plane);
  4. bend.bend(Bend.X, Bend.Z, 1, 0.5);

Check the source file for detailed info about the arguments.

UPDATE June 16th 2008. Check the next post for a newer version of Bend class (demo included).

In general this kind of transformations are called modifiers and can be organized in stacks. This means that one modifier can be applied to an object, and then another one can be applied to the result of this transformation. For an interesting list of possible modifiers check here (examples are from 3dsMAX).

Modifiers stack is a powerful tool in 3dsMAX, it would definitely be good to have something like this in Papervision3D, don't you think?

24 Responses to “Bend modifier for Papervision3D”

  1. Proti Says:

    Well, another great job. Good stuff.

  2. Matt Przybylski Says:

    Very cool.

  3. Stephan Says:

    Love it!

    I wish I came across this a month or so ago. I ended up writing something really simple that used a simple acceleration/ease to step through all the vertecies and raise them incrementally along the z axis.

    Your class takes it up a step and uses the proper math to get a really circular curve. GREAT JOB!!!!

  4. Source | Bending modifier for Papervision3D « Flash Enabled Blog Says:

    […] Bartek thought it would be nice to be able to bend stuff in Papervision3D too. Read his post and download the source […]

  5. Nate Chatellier Says:

    It appears your Bend class does not work with the latest pv3d revision (the newly merged Great White and Effects branches). For starters, the lines:
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.core.geom.renderables.Vertex3D;

    should now be:
    import org.papervision3d.objects.Plane;
    import org.papervision3d.core.geom.Vertex3D;

    Even after changing these, I’m still not getting the class to work right, but I’m looking into it. Maybe I’m not even using the class right? Although it seems straight forward enough. I couldn’t check since I didn’t see the source for the $100 demo.

    The demo looks great, nice work. Hopefully I can get it running soon :)

  6. bartek drozdz Says:

    @nate thanks! I did not checkout the latest revision, but I will do that and update this.

  7. pedro Says:

    Great work, congrats!

  8. Bending modifier for Papervision3D « Papervision3D - Developers Says:

    […] modifier for Papervision3D Bartek Drozdz from Everyday Flash has posted an interesting Bend class that bends planes along their X and Y axis. Very useful for a number of cases, including a PV3D […]

  9. xero / fontvir.us Says:

    very cool effect! thanx for the sources!

  10. César Rodríguez Says:

    Great ! Thanks for share !

  11. Nate Chatellier Says:

    So I got it all up and running in the current pv3d rev. It really is a great class! I’m attempting to use it to create the illusion that you are “peaking at a Texas Hold’em card”. It seems like there is a 3rd parameter needed to do this properly. For example, let’s say I want the force to be 1.5, but I only want this to effect the top half of the player card. I could split the playing card into two separate planes, that appear to be one, and then apply a 1.5 force with the offset = 0. But this would be way less efficient. Any chance you could add this? ::wishful thinking::

  12. bartek drozdz Says:

    @nate Great to hear that! I see what you are looking for with the card - I was thinkking about something like ‘limit’ parameter, which I guess would be what you need. I will add that.

    For the moment I focused on optimizing the math in the class and make that so that it works with any 3D Object. I’ve already done some good progress, and I will post the updated sources pretty soon.

  13. janusz sobolewski Says:

    hi Bartek, greetings from Warsaw, that’s pretty zajebisty stuff! nice work, thanx

  14. zupko.info » Blog Archive » 3d Twist Modifier Says:

    […] Drozdz posted a demo the other day of a Bend Modifier. The fact that no modifiers exist in pv3d is a crime - so I decided I would start off an official […]

  15. aYo Says:

    Andy,
    Thats deeply cool.
    ~a~

  16. FlashBookmarks Says:

    Twist and Bend nice work!:)

  17. Marcel Fahle Says:

    dobra slonko, podoba mi sie bardzo ;)

  18. Dominic Says:

    thats really amazing! can’t wait to play arround with it

  19. wonderwhy-er Says:

    Pretty cool experiment. I suppose that it is a beginning of a whole new block of cool things for PV3D :)

  20. gally Says:

    wooooooooooooooooooooooooooooooooooow

  21. Rafael Rinaldi Says:

    Very nice.

  22. Recent URLs tagged 3dgraphics - Urlrecorder Says:

    […] recorded first by arollin on 2008-07-24→ Bend modifier for Papervision3D […]

  23. Orlando Leite Says:

    Hey Bro, good job!

    I don’t know if you already did that, but let me show.

    I did some modification in your code to turn it compative with some tween classes.

    Now I can do, using Tweener like a example:
    bend = new Bend( plane, Bend.X, Bend.Y, 0, 0.5 );
    Tweener.addTween( bend, { force:1, offset:1, delay:1, time:3 } );

    the modified source you get here: http://orlleite.googlepages.com/Bender.zip

    Thx!

  24. bartek drozdz Says:

    @Orlando Leite Thanks mate! I will update the Bend class soon. I know that there are some issues with tweening in there - itwill be solved. I also plan to add some new functionallities.

Leave a Reply