[Papervision3D] question re culling in Papervision3D_2.0_beta_1_src

DJC imdavetoo at yahoo.com
Wed Sep 24 09:35:48 PDT 2008


I am stumbling around in the culling code and I've found some things that do
not look right to me.

In DefaultTriangleCuller, line 25 reads:
    if(vertex0.visible && vertex1.visible && vertex2.visible){   // [[ might
be visible, else cull ]]
thus all vertices must be visible in the projection, or the triangle is
culled.
I think it should read:
    if(vertex0.visible || vertex1.visible || vertex2.visible){
so that any vertex being visible means it won't be culled.

In FrustumCuller.sphereInFrustum() I don't see any factor for obj.scale. 
Radius is correct at a scale of 1.0 but remains the same regardless of scale
changes so objects may be over or under-culled.

Both theory and math on this are well beyond me... wish I could fix this for
the team but by the time that could happen, well... *grins*   Little help?

DJC
  

DJC wrote:
> 
> The code below creates two planes and a camera rotating between them. 
> They seem to be dis/re-appearing; I want smooth exits and entries.  Plane
> culling happens before the bounding box (or sphere?) leaves the frustum -
> and after they re-enter.
> 
> What to do?
> 
> Thanks! 
> DJC
> 
> == 
> 
> 	import flash.display.Sprite;
> 	import flash.display.BitmapData;
> 	import flash.events.Event;
> 
> 	import org.papervision3d.render.BasicRenderEngine;
> 	import org.papervision3d.view.Viewport3D;
> 	import org.papervision3d.cameras.Camera3D;
> 	import org.papervision3d.scenes.Scene3D;
> 	import org.papervision3d.materials.BitmapMaterial;
> 	import org.papervision3d.objects.primitives.Plane;
> 	
> 	public class Test extends Sprite {
> 		private var renderer:BasicRenderEngine;
> 		private var viewport:Viewport3D;
> 		private var scene:Scene3D;
> 		private var camera:Camera3D;
> 		
> 		public function Test() {
> 			renderer = new BasicRenderEngine();
> 			viewport = new Viewport3D(320, 300, true, false);		// autoscale true,
> interactive false
> 			this.addChild(viewport);
> 			camera = new Camera3D(90, 10, 5000, false);				// fov, near, far, cull
> 			scene = new Scene3D();
> 			
> 			var material:BitmapMaterial = new BitmapMaterial(new BitmapData(1600,
> 400, false, 0xFF3333));
> 			
> 			var p:Plane = new Plane(material, material.bitmap.width,
> material.bitmap.height);
> 			p.z = 0;
> 			scene.addChild(p);
> 			
> 			var p2:Plane = new Plane(material, material.bitmap.width,
> material.bitmap.height);
> 			p2.z = -2000;  
> 			p2.rotationY = 180;
> 			scene.addChild(p2);
> 			
> 			addEventListener(Event.ENTER_FRAME, loop);
> 		}
> 		
> 		private function loop(e:Event):void{
> 			renderer.renderScene(scene, camera, viewport);
> 			camera.rotationY += 1;
> 		}
> 	}
> 
> 

-- 
View this message in context: http://www.nabble.com/question-re-culling-in-Papervision3D_2.0_beta_1_src-tp19566773p19652876.html
Sent from the Papervision3D mailing list archive at Nabble.com.




More information about the Papervision3D mailing list