Bend modifier – part II
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.
First of all, thanks for the great feedback I got after the first post on bending. I really appreciate it.
UPDATE Sept 9th, 2008. The Bend modifier is now part of AS3Dmod library. Use that one instead of the class linked below.
Click here for a demo. The algorithm has been refined and the class public methods have been changed. Here's an updated use-case:
do3d = new SomeDisplayObject3D();
bend = new Bend(do3d);
scene.addChild(do3d);
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:
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!