[Papervision3D] First-steps question
joa e.
j at je2050.de
Sat Feb 10 10:49:39 EST 2007
Taking a look at the examples Ricardo was showing here
(http://www.ricardocabello.com/?postid=312) I started to play also
around with it. It was good that Ricardo was not providing all the
source files because now I started with a simple thing and you guys can
tell, what is wrong.
Actually the only missing thing is the cube class. Now I started with a
simple Cube class and would like to get some suggestions. Take this code
as an outside perspective. I have the feeling that some stuff could be
done simpler? Also I have to set the material doubleSided but only
because the planes are not aligned correct I guess.
You can see the example output as well at
http://je2050.de/showroom.php?file=cubes
It was more a quick test and is actually only the stuff Ricardo was
already showing. But does anyone know why the GlowFilter is not used
sometimes?
Anyways. Here is the code and I hope you can give me some hints.
import org.papervision3d.core.Matrix3D;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.objects.Plane;
import org.papervision3d.scenes.DisplayObject3D;
class Cube extends DisplayObject3D
{
private var top: Plane;
private var bottom: Plane;
private var right: Plane;
private var left: Plane;
private var back: Plane;
private var front: Plane;
public function Cube( material: MaterialObject3D, width: Number,
height: Number )
{
top = new Plane( material, width, height, 1, 1 );
bottom = new Plane( material, width, height, 1, 1 );
right = new Plane( material, width, height, 1, 1 );
left = new Plane( material, width, height, 1, 1 );
back = new Plane( material, width, height, 1, 1 );
front = new Plane( material, width, height, 1, 1 );
top.transformVertices( Matrix3D.rotationX( Math.PI * .5 ) );
top.transformVertices( Matrix3D.translationMatrix( 0, -height
* .5, 0 ) );
bottom.transformVertices( Matrix3D.rotationX( Math.PI * .5 ) );
bottom.transformVertices( Matrix3D.translationMatrix( 0, height
* .5, 0 ) );
right.transformVertices( Matrix3D.rotationY( Math.PI * .5 ) );
right.transformVertices( Matrix3D.translationMatrix( width *
.5, 0, 0 ) );
left.transformVertices( Matrix3D.rotationY( Math.PI * .5 ) );
left.transformVertices( Matrix3D.translationMatrix( -width *
.5, 0, 0 ) );
back.transformVertices( Matrix3D.translationMatrix( 0, 0,
width * .5 ) );
front.transformVertices( Matrix3D.translationMatrix( 0, 0,
-width * .5 ) );
addChild( top, 'top' );
addChild( bottom, 'bottom' );
addChild( right, 'right' );
addChild( left, 'left' );
addChild( back, 'back' );
addChild( front, 'front' );
}
}
More information about the Papervision3D
mailing list