Tag Archive for 'Bend'

Papervision Double Sided Plane (err sorta) :/

Papervision double sided plane

As far as I know there are 2 options when creating a double sided plane. Double sided meaning a different material for each side.

Option 1:
Create two planes. Plane 1 with a z sorting of 1 and the other with 0 and the rotationY of one of those planes set to 180. You could then contain this in one display container.

Version 2:
Create one cube with a depth of 0. Then you just apply a material to the front and back. OK OK OK so this is not really a Plane… but I like this approach because it allows me to more easily use things like Bend Modifier.

If anyone has a better or more improved approach I would love to hear about it.

Here is what the code for Option 1:

[as]
package com.cs54.ui
{
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import com.everydayflash.pv3d.modifiers.Bend;
import flash.display.DisplayObject;public class Tree2Planes extends DisplayObject3D
{
[Embed(source="/assets/tree-side-1.png")]
public var TreeFront        :Class;[Embed(source="/assets/tree-side-2.png")]
public var TreeBack            :Class;

protected var treeFront        :DisplayObject;
protected var treeBack        :DisplayObject;

protected var treeFrontMat    :MovieMaterial;
protected var treeBackMat    :MovieMaterial;

protected var treeMatList    :MaterialsList;

protected var _height        :Number = 175;
protected var _width        :Number = 191;
protected var _container    :DisplayObject3D;

protected var plane1        :Plane;
protected var plane2        :Plane;

public function Tree2Planes():void
{
treeMatList     = new MaterialsList();
treeFront        = new TreeFront();
treeBack         = new TreeBack();

//Tree Materials
treeFrontMat     = new MovieMaterial(treeFront, true);
treeBackMat     = new MovieMaterial(treeBack, true);

treeFrontMat.allowAutoResize = false;

plane1        = new Plane(treeFrontMat,_width,_height);
plane2        = new Plane(treeBackMat,_width,_height);

plane1.z = 1;
plane1.rotationY = 180;

_container = new DisplayObject3D();

addChild(_container);
_container.addChild(plane1);
_container.addChild(plane2);

}

public function get height():Number
{
return _height;
}
public function get width():Number
{
return _width;
}

}

}

[/as]

Here is what the code for Option 2:

[as]

package com.cs54.ui
{
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;
import com.everydayflash.pv3d.modifiers.Bend;
import flash.display.DisplayObject;

public class Tree extends DisplayObject3D
{
[Embed(source="/assets/tree-side-1.png")]
public var TreeFront        :Class;

[Embed(source="/assets/tree-side-2.png")]
public var TreeBack            :Class;

protected var treeFront        :DisplayObject;
protected var treeBack        :DisplayObject;

protected var treeFrontMat    :MovieMaterial;
protected var treeBackMat    :MovieMaterial;

protected var treeMatList    :MaterialsList;

protected var treeCube        :Cube;
protected var _height        :Number = 175;
protected var _width        :Number = 191;
protected var _container    :DisplayObject3D;

public function Tree():void
{

treeMatList     = new MaterialsList();
treeFront        = new TreeFront();
treeBack         = new TreeBack();

//Tree Materials
treeFrontMat     = new MovieMaterial(treeFront, true);
treeBackMat     = new MovieMaterial(treeBack, true);

treeFrontMat.allowAutoResize = false;

treeFrontMat.animated = true;

treeMatList.addMaterial( treeFrontMat, “front” );
treeMatList.addMaterial( treeBackMat, “back” );

treeCube     = new Cube(treeMatList, _width, 0, _height, 6, 6, 6);

var bend:Bend = new Bend(treeCube);

bend.quickBend(1, .1);

addChild(treeCube);

}

public function get height():Number
{
return _height;
}
public function get width():Number
{
return _width;
}

}

}

[/as]


Follow papervision2 on Twitter

RSS Feed