I figured it was about time I go over the BasicView (a very simple implementation of setting up your viewport/scene/camera all in one object). The thing that is amazing to me is that you can implement and display a 3D object in 34 lines of code using BasicView.
In this example we're going to simply display a Plane primitive (so don't expect to see any amazing visuals). Lets jump into the code and see how it breaks down.
package {
import flash.display.Sprite;
import flash.events.Event;
//for BasicView you will need to import CameraType instead of a specific camera
import org.papervision3d.cameras.CameraType;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.render.BasicRenderEngine;
//import the BasicView class
import org.papervision3d.view.BasicView;
public class BasicViewDemo extends Sprite
{
//Declare your BasicView variable
private var view:BasicView;
private var color:ColorMaterial;
private var plane:Plane;
public function BasicViewDemo()
{
//The BasicView parameters are as follows
//BasicView(width, height, scaleToStage, interactive, camera type);
view = new BasicView(600, 400, false, false, CameraType.FREE);
//When you instantiate the camera type
//there are three type, DEBUG, FREE, TARGET.
plane = new Plane(new ColorMaterial(0x880000), 300, 300, 1, 1);
//assign the BasicView renderer property to a renderer of your choice.
//for this example I'll assign it to a BasicRenderEngine renderer.
view.renderer = new BasicRenderEngine();
//any objects that you want to add to your scene
//needs to be added through view.scene
view.scene.addChild(plane);
addEventListener(Event.ENTER_FRAME, onRenderViewport);
//add the BasicView object to the display list
addChild(view);
}
private function onRenderViewport(e:Event):void
{
//to render your scene use the view.singleRender(); method
view.singleRender();
}
}
}
View Example: click here
View Source: click here
skip to main |
skip to sidebar
Jim Foley's Brain. Flex, Flash, Papervision 3D, Swift 3D and other cool stuff.
Back on top ^
created by Nuvio | Webdesign
MAD VERTICES © 2008 Ken ahlin | Converted to XML Blogger Template by ThemeLib
Hi Jim
Thanks For your great effort to make these tutorial.
Jim I have query regarding the making of image gallery using the papervision. I didn't how to solve this.
My problem is that like if you want to make a simple image in as3
I usually make a "ThumbClass" class in that add textfield, Loader class object to add image, and linked that class to thumbMC Movielclip in which there is sort of animation controlled by mouseOver in the "ThumbClass"
Now when I try to do same think using the papervision MovieMaterial geeting problem in mouseOver
I just want to play the rectangle animation on mouse Over
I did i have to use something else with it
please I am new in papervision and not get this solution
thanks in advance
vivek
Your example is complex a little
Here is a simple way
package
{
import flash.display.Sprite;
import org.papervision3d.cameras.CameraType;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.view.BasicView;
public class BasicViewDemo extends Sprite
{
private var view:BasicView;
private var color:ColorMaterial;
private var plane:Plane;
public function BasicViewDemo()
{
view = new BasicView(600, 400, false, false, CameraType.FREE);
plane = new Plane(new ColorMaterial(0x880000), 300, 300, 1, 1);
view.camera.zoom = 70;
view.scene.addChild(plane);
view.singleRender();
addChild(view);
}
}
}
Just wondering why dont you extend as a Basicview? Instaed of extending as a Sprite?
MainView extends BasicView{
}
Is it not a better idea to extend AbstractView in Basic View???