EnhacedPlane and PlaneGrid PV3D classes

Reynaldo May 4th, 2008

Hi!

It’s been a really long time since I posted anything and there are a ton of reasons for that including moving to New York, getting a new job and finding a new place. But you can trust that I will be posting on a more regular basis from now on ;)

I decided to come back with a couple of classes I cerated for use with the Great White branch of PaperVision3D.

EnhancedPlane
This class allows you to create a Plane primitive with two dynamic faces to which you can add different materials. In other words, it’ll have two unique sides!

Use:

var frontMaterial:ColorMaterial = new ColorMaterial(0x00FFFF);
var backMaterial:ColorMaterial = new ColorMaterial(0xFFFF00);

var materials:MaterialsList = new MaterialsList({front:frontMaterial,	back:backMaterial});

var myEnhancedPlane:EnhancedPlane = new EnhancedPlane(materials, 250, 250, 16);
this.scene.addChild(myEnhancedPlane);

The first argument the class accepts is a MaterialList with the “front” and “back” materials specified. After that, the class accepts 4 optional arguments: width, height, segments and name.

PlaneGrid
This class allows you to create a grid of (same width, same height) planes real easily!

Use:

var planesArray:Array = new Array();
for(var a:Number = 0; a<18; a++){
     var material:ColorMaterial = new ColorMaterial(0x00FFFF);
     var plane:Plane = new Plane(material, 320, 480);
     planesArray.push(plane);
}
var planeGrid:PlaneGrid = new PlaneGrid(planesArray, 6, 3, 5, 320, 480, "left");
this.scene.addChild(planeGrid);

The first argument is an array holding the planes you would like to be in the grid, the rest of the parameters are columns, rows, spacing, plane width, plane height, and alignment respectfully. The alignment can either be: “left”, “right” or “center”.

Both of the classes extend the DisplayObject3D so you can treat them like any other 3D display object/primitive.

You can get the classes here

[EDIT]

Thanks to my good friend Matt, I fixed a small error in the the EnhancedPlane class. Thanks dude! I also uploaded an example on how to set up your EnhancedPlane to have interactivity on both sides. You can find the example here.

One Response to “EnhacedPlane and PlaneGrid PV3D classes”

  1. Gregon 27 May 2008 at 2:11 pm

    Handy classes, thanks man.

    I had made a minor change to your EnhancedPlane class in order to keep the back image from flipping. I changed

    back.pitch(180);
    to
    back.material.opposite = true;

    which just puts the image on the back face of the plane I guess.

Trackback URI | Comments RSS

Leave a Reply

  • Friends

  • Props

  • Donations

  • website counter
  • Archives

  • Feedburner