Nightwish Capone Mumford and Sons Get mp3 Cobra Starship Edge Of Sanity Bon Iver Dave Matthews Band Paramore Michael Buble Benabar She and Him MP3 search Michael Jackson

Tag Archive for 'QuadrantRenderEngine'

Fix Z-Sorting issues with the QuadrantRenderEngine

quadrantrenderengine

download-source

Another way to solve your z-sorting issues is the use of the Quadrant Render Engine. The QuadrantRenderEngine only takes one parameter (type).

The three "types" of filtering available to you are:
QuadrantRenderEngine.ALL_FILTERS
QuadrantRenderEngine.CORRECT_Z_FILTER
QuadrantRenderEngine.QUAD_SPLIT_FILTER

For a full explanation of each of the 3 types available to you with this renderer take a look at this article.

The QuadrantRenderEngine use a technique of subdividing the screen into smaller and smaller regions to resolve potential conflicts between triangles.
blog.papervision3d.org

As also noted by others, this is a great tool to have around it does come with its performance issues. You may want to test out using ViewportLayers and optimizing in other areas.

Here is the simple code you need to change your renderer when extending BasicView.as:

Actionscript:
  1. renderer = new QuadrantRenderEngine(QuadrantRenderEngine.ALL_FILTERS);

Here is the full code for this example:

Actionscript:
  1. package 
  2. {
  3.     import flash.events.Event;
  4.     import org.papervision3d.materials.ColorMaterial;
  5.     import org.papervision3d.objects.primitives.Plane;
  6.     import org.papervision3d.objects.primitives.Sphere;
  7.     import org.papervision3d.render.QuadrantRenderEngine;
  8.     import org.papervision3d.view.BasicView;
  9.     import org.papervision3d.materials.BitmapFileMaterial;
  10.    
  11.     public class Main extends BasicView
  12.     {
  13.         protected var sphere:Sphere
  14.         protected var plane:Plane;
  15.         protected var bitmapMaterial:BitmapFileMaterial;
  16.         protected var colorMaterial:ColorMaterial;
  17.  
  18.         public function Main()
  19.         {
  20.             super();
  21.            
  22.             //Try commenting out this line to see the issues.
  23.             renderer = new QuadrantRenderEngine(QuadrantRenderEngine.ALL_FILTERS);
  24.            
  25.             createChildren();
  26.             commitProperties();
  27.             startRendering();
  28.         }
  29.         protected function createChildren():void
  30.         {
  31.            
  32.             //Create a new 3D object
  33.             colorMaterial = new ColorMaterial(0x000000);
  34.             bitmapMaterial = new BitmapFileMaterial("images/ourtex.jpg")
  35.  
  36.             //Create 3D Objects
  37.             plane = new Plane(colorMaterial,1000,1000,5,5)
  38.             sphere = new Sphere(bitmapMaterial, 50, 10,10);
  39.  
  40.            
  41.             //Add to scene
  42.             scene.addChild(plane);
  43.             scene.addChild(sphere);
  44.  
  45.         }
  46.        
  47.         protected function commitProperties():void
  48.         {
  49.             //Set some properties
  50.             sphere.scale = 4;
  51.             sphere.pitch( -10);
  52.             plane.rotationX = 60;
  53.         }
  54.         override protected function onRenderTick(event:Event = null):void
  55.         {
  56.             super.onRenderTick(event);
  57.  
  58.             //Rotate
  59.             sphere.yaw(1);
  60.         }
  61.     }
  62. }

download-source

Post to Twitter Post to Delicious Delicious Post to Digg Digg This Post Post to Facebook Facebook Post to StumbleUpon Stumble This Post


Follow WovenCharlie on Twitter

Flash and the City banner
2010 Flash And The City Speaker

RSS Feed