ywywdh / papervision3d

Automatically exported from code.google.com/p/papervision3d
0 stars 0 forks source link

FrustumCuller and RectangleTriangleCuller are culling parts that should be visible #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. code below recreates issue

What is the expected output? What do you see instead?
smooth exit of plane from scene.  plane is culled before leaving view.

What version of the product are you using? On what operating system?
Papervision3D_2.0_beta_1_src on Win XP SVP3, boht Flash 9 and Flash 10

Please provide any additional information below.

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;
                }
        } 

Original issue reported on code.google.com by david.ch...@gmail.com on 23 Sep 2008 at 6:25

GoogleCodeExporter commented 9 years ago
Andy, I'll pick up on the normal culler (which doesn't seem to be the issue to 
me).
Could you confirm this ? 

Original comment by r.hauw...@gmail.com on 17 Oct 2008 at 1:51

GoogleCodeExporter commented 9 years ago
Andy and Ralph,

I tested this with 763 and
    renderer.clipping = new FrustumClipping(FrustumClipping.NEAR);

Same issue.  Out of my league here but I'm working to apply your fantastic tool 
on my
MFA thesis *grins*.  No doubt I missed a bit or two somewhere but the above 
case I
pulled from a real app I'm working on and I'm running into this a lot.  It 
seems to
me some others may be on the same obstacle.  I did take a look into it, 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.  This fixes (er, 
hides?)
my simple sample code on the exiting of the plane; it still jumps into 
existence.  My
full app is in a skybox and sides keep disappearing on me like the plane 
example,
opening giant holes in the sky.  What power ;)  Now if only I had the power to 
fix it
*sighs*  Thoughts?

Best, DJC

In FrustumCuller.sphereInFrustum() I don't see any factor for obj.scale 
property?. 
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.  Ignorance = bliss?  I think not :)

Original comment by david.ch...@gmail.com on 25 Oct 2008 at 1:40

GoogleCodeExporter commented 9 years ago
David, your solution lies in using the FrustumClipping! Ralph.

Original comment by r.hauw...@gmail.com on 17 Nov 2008 at 12:57