3d Twist Modifier


twist.jpg

Bartok 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 Modifier set. The first in the line of upcoming modifiers is the Twist modifier. This modifier works just like you would imagine it would - you simply tell it the amount you want to twist, and the axis you want to twist around.

Here's how to use it:

Actionscript:
  1. var mat:BitmapFileMaterial = new WireframeMaterial();
  2. cube = new Cube(new MaterialsList({all:mat}),500, 500, 500, 4, 4, 4);
  3. scene.addChild(cube);
  4.  
  5. var t:Twist = new Twist(cube);
  6.  
  7. var degrees:Number = 30;
  8. var axis:Number3D = new Number3D(0, 1, 0); //rotate around an axis sticking straight up the Y axis
  9. var center:Number3D = new Number3D(0, 0, 0); //the axis starts at 0, 0, 0
  10.  
  11. t.twist(degrees, axis, center);

That's it! Take note, that if you call Twist.twist again - it will twist the vertices from their ORIGINAL positions - not from their already twisted positions. However, you could add another twist after you do the first, and you could twist in multiple directions simultaneously.  This modifier will probably be updated - I'm not convinced my math was perfect - but for now you can do some fun stuff with it.  Take note - it requires you to use an object with geometry in it - it doesn't work with child objects.  So if you want to use it on a DAE for example, you would need to pass the child object that has the actual faces.

I'm planning on developing a more complete API to handle modifiers like you would see in 3D Studio Max.  If there are any good ones you would like me to work on, leave a comment or shoot me an email and let me know!

View the Demo

and

Get the source


13 Comments, Comment or Ping

  1. Beautiful work Andy. Thanks so much for sharing.

    June 13th, 2008

  2. Keep going Andy, great progress you’re making!

    June 13th, 2008

  3. aYo

    S W E E T

    June 13th, 2008

  4. andy

    fantastic.

    June 13th, 2008

  5. Very impressive, I’m wondering if you guys are going to take PV3D to flash player 10 platform any time soon :)
    Imagining the direction this engine is going and Astro’s hardware support, it would be a shame not too.

    June 14th, 2008

  6. gally

    i played a bit with it, it’s just great. Thanks for sharing all this stuff, you’re definitly a motor for pv3D.

    June 19th, 2008

  7. Very nice.

    July 24th, 2008

  8. Icek

    Great work, but how to access stage, viewport and camera from within do3d?
    Do I need to do everything inside BasicView/IView?

    My problem is: I created do3d named Book. Inside Book, there are several BookPages (also do3d), and inside BookPages i got another do3d, and inside this do3d i want to do some dragging actions. Now I need to transmit variables (stage, viewport and camera) via each do3d constructor, but i think, that this method sucks. Other way is to use Singleton as Variable Locators, but this also doesn’t sound good.
    So, how to this?

    PS. Sorry for my bad english.

    December 10th, 2008

  9. Great work – and thanks for sharing. I just put a demo of a way to use the twist on my blog: http://www.iliketoplay.dk/blog
    regards, Michael

    December 12th, 2008

  10. Giuseppe

    hi, terrific class!
    i’d like to ask wich would be the quickest way to reset the original state of the cube. Should I store the original positions of the points od the untwisted 3d matrix or is there any other method? thanks.

    February 6th, 2009

  1. Twist -pv3d - Rest Term - July 11, 2008
  2. as3dmod demo | I like to blog - December 11, 2008

Reply to “3d Twist Modifier”