コード例 #1
0
 public override Camera CreateCamera(string name) {
     Camera cam = new OctreeCamera(name, this);
     cameraList.Add(name, cam);
     // create visible bounds aabb map entry
     camVisibleObjectsMap[cam] = new VisibleObjectsBoundsInfo();
     return cam;
 }
コード例 #2
0
ファイル: SceneNode.cs プロジェクト: wellsanin1/Game-Engine
 public void _findVisibleObjects(Camera cam, RenderQueue queue, VisibleObjectsBoundsInfo visibleBounds)
 {
     OgrePINVOKE.SceneNode__findVisibleObjects__SWIG_3(swigCPtr, Camera.getCPtr(cam), RenderQueue.getCPtr(queue), VisibleObjectsBoundsInfo.getCPtr(visibleBounds));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #3
0
ファイル: SceneNode.cs プロジェクト: wellsanin1/Game-Engine
 public void _findVisibleObjects(Camera cam, RenderQueue queue, VisibleObjectsBoundsInfo visibleBounds, bool includeChildren, bool displayNodes)
 {
     OgrePINVOKE.SceneNode__findVisibleObjects__SWIG_1(swigCPtr, Camera.getCPtr(cam), RenderQueue.getCPtr(queue), VisibleObjectsBoundsInfo.getCPtr(visibleBounds), includeChildren, displayNodes);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #4
0
ファイル: OctreeZone.cs プロジェクト: bostich83/axiom
        public override void FindVisibleNodes(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue,
                                              VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters,
                                              bool displayNodes, bool showBoundingBoxes)
        {
            //return immediately if nothing is in the zone.
            if (mHomeNodeList.Count == 0 && mVisitorNodeList.Count == 0 && mPortals.Count == 0)
            {
                return;
            }

            // Else, the zone is automatically assumed to be visible since either
            // it is the camera the zone is in, or it was reached because
            // a connecting portal was deemed visible to the camera.

            // enable sky if called to do so for this zone
            if (mHasSky)
            {
                // enable sky
                mPCZSM.EnableSky(true);
            }

            // Recursively find visible nodes in the zone
            WalkOctree(camera, ref visibleNodeList, queue, this.rootOctree, visibleBounds, false, onlyShadowCasters,
                       displayNodes,
                       showBoundingBoxes);

            // find visible portals in the zone and recurse into them
            bool vis;

            foreach (Portal portal in mPortals)
            {
                // for portal, check visibility using world bounding sphere & direction
                FrustumPlane pl = FrustumPlane.None;
                vis = camera.IsObjectVisible(portal, out pl);
                if (vis)
                {
                    // portal is visible. Add the portal as extra culling planes to camera
                    int planes_added = camera.AddPortalCullingPlanes(portal);
                    // tell target zone it's visible this frame
                    portal.getTargetZone().LastVisibleFrame      = mLastVisibleFrame;
                    portal.getTargetZone().LastVisibleFromCamera = camera;
                    // recurse into the connected zone
                    portal.getTargetZone().FindVisibleNodes(camera, ref visibleNodeList, queue, visibleBounds, onlyShadowCasters,
                                                            displayNodes, showBoundingBoxes);
                    if (planes_added > 0)
                    {
                        // Then remove the extra culling planes added before going to the next portal in this zone.
                        camera.RemovePortalCullingPlanes(portal);
                    }
                }
            }
        }
コード例 #5
0
        /** Adds the attached objects of this PCZSceneNode into the queue. */

        public void AddToRenderQueue(Camera cam, RenderQueue queue, bool onlyShadowCasters,
                                     VisibleObjectsBoundsInfo visibleBounds)
        {
            foreach (var pair in this.objectsByName)
            {
                pair.Value.NotifyCurrentCamera(cam);

                if (pair.Value.IsVisible && (!onlyShadowCasters || pair.Value.CastShadows))
                {
                    pair.Value.UpdateRenderQueue(queue);

                    if (!visibleBounds.aabb.IsNull)
                    {
                        visibleBounds.Merge(pair.Value.GetWorldBoundingBox(true), pair.Value.GetWorldBoundingSphere(true), cam);
                    }
                }
            }
        }
コード例 #6
0
        public Vector4 GetShadowSceneDepthRange(int lightIndex)
        {
            if (currentSceneManager.IsShadowTechniqueTextureBased)
            {
                return(dummyDepthRange);
            }

            if (shadowCamDepthRangesDirty)
            {
                shadowCamDepthRanges.Clear();
                foreach (Light light in currentLightList)
                {
                    // stop as soon as we run out of shadow casting lights, they are
                    // all grouped at the beginning
                    if (light.CastShadows)
                    {
                        break;
                    }

                    VisibleObjectsBoundsInfo info = currentSceneManager.GetShadowCasterBoundsInfo(light);

                    sceneDepthRange.x = mainCamBoundsInfo.minDistance;
                    sceneDepthRange.y = mainCamBoundsInfo.maxDistance;
                    sceneDepthRange.z = mainCamBoundsInfo.maxDistance - mainCamBoundsInfo.minDistance;
                    sceneDepthRange.w = 1.0f / sceneDepthRange.z;

                    shadowCamDepthRanges.Add(new Vector4(info.minDistance,
                                                         info.maxDistance,
                                                         info.maxDistance - info.minDistance,
                                                         1.0f / (info.maxDistance - info.minDistance)));
                }
                shadowCamDepthRangesDirty = false;
            }

            if (lightIndex >= shadowCamDepthRanges.Count)
            {
                return(dummyDepthRange);
            }
            else
            {
                return(shadowCamDepthRanges[lightIndex]);
            }
        }
コード例 #7
0
        /// <summary>
        ///     Adds all the attached scenenodes to the render queue.
        /// </summary>
        /// <param name="cam"></param>
        /// <param name="queue"></param>
        public void AddToRenderQueue(Camera cam, RenderQueue queue, bool onlyShadowCasters,
                                     VisibleObjectsBoundsInfo visibleBounds)
        {
            // int i;
            foreach (MovableObject obj in objectList.Values)
            {
                obj.NotifyCurrentCamera(cam);

                if (obj.IsVisible && (!onlyShadowCasters || obj.CastShadows))
                {
                    obj.UpdateRenderQueue(queue);
                    if (visibleBounds != null)
                    {
                        visibleBounds.Merge(obj.GetWorldBoundingBox(true),
                                            obj.GetWorldBoundingSphere(true),
                                            cam);
                    }
                }
            }
        }
コード例 #8
0
        public override void FindVisibleObjects(Camera cam,  VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters) {
            GetRenderQueue().Clear();
            boxList.Clear();
            visible.Clear();

            if(cullCamera) {
                Camera c = cameraList["CullCamera"];

                if(c != null) {
                    cameraInProgress = cameraList["CullCamera"];
                }
            }

            numObjects = 0;

            //walk the octree, adding all visible Octreenodes nodes to the render queue.
            WalkOctree((OctreeCamera)cam, GetRenderQueue(), octree, visibleBounds, onlyShadowCasters, false);

            // Show the octree boxes & cull camera if required
            if(this.ShowBoundingBoxes || cullCamera) {
                if(this.ShowBoundingBoxes) {
                    for(int i = 0; i < boxList.Count; i++) {
                        WireBoundingBox box = (WireBoundingBox)boxList[i];
						
                        GetRenderQueue().AddRenderable(box);
                    }
                }
				
                if(cullCamera) {
                    OctreeCamera c = (OctreeCamera)GetCamera("CullCamera");

                    if(c != null) {
                        GetRenderQueue().AddRenderable(c);
                    }
                }
            }
        }
コード例 #9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VisibleObjectsBoundsInfo obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #10
0
ファイル: PCZone.cs プロジェクト: bostich83/axiom
        /** Find and add visible objects to the render queue.
         * @remarks
         * Starts with objects in the zone and proceeds through visible portals
         * This is a recursive call (the main call should be to _findVisibleObjects)
         */

        public abstract void FindVisibleNodes(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue,
                                              VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters,
                                              bool displayNodes, bool showBoundingBoxes);
コード例 #11
0
ファイル: OctreeZone.cs プロジェクト: bostich83/axiom
        private void WalkOctree(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue, Octree octant,
                                VisibleObjectsBoundsInfo visibleBounds, bool foundvisible, bool onlyShadowCasters,
                                bool displayNodes, bool showBoundingBoxes)
        {
            //return immediately if nothing is in the node.
            if (octant.NunodeList == 0)
            {
                return;
            }

            Visibility v = Visibility.None;

            if (foundvisible)
            {
                v = Visibility.Full;
            }

            else if (octant == this.rootOctree)
            {
                v = Visibility.Partial;
            }

            else
            {
                AxisAlignedBox box = octant.Box;

                v = camera.GetVisibility(box);
            }


            // if the octant is visible, or if it's the root node...
            if (v != Visibility.None)
            {
                //Add stuff to be rendered;

                bool vis = true;

                foreach (PCZSceneNode sn in octant.NodeList.Values)
                {
                    // if the scene node is already visible, then we can skip it
                    if (sn.LastVisibleFrame != mLastVisibleFrame || sn.LastVisibleFromCamera != camera)
                    {
                        // if this octree is partially visible, manually cull all
                        // scene nodes attached directly to this level.
                        if (v == Visibility.Partial)
                        {
                            vis = camera.IsObjectVisible(sn.WorldAABB);
                        }
                        if (vis)
                        {
                            // add the node to the render queue
                            sn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                            // add it to the list of visible nodes
                            visibleNodeList.Add(sn);
                            // if we are displaying nodes, add the node renderable to the queue
                            if (displayNodes)
                            {
                                queue.AddRenderable(sn.GetDebugRenderable());
                            }
                            // if the scene manager or the node wants the bounding box shown, add it to the queue
                            if (sn.ShowBoundingBox || showBoundingBoxes)
                            {
                                sn.AddBoundingBoxToQueue(queue);
                            }
                            // flag the node as being visible this frame
                            sn.LastVisibleFrame      = mLastVisibleFrame;
                            sn.LastVisibleFromCamera = camera;
                        }
                    }
                }

                Octree child;
                bool   childfoundvisible = (v == Visibility.Full);
                if ((child = octant.Children[0, 0, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 0, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 1, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 1, 0]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 0, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 0, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[0, 1, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }

                if ((child = octant.Children[1, 1, 1]) != null)
                {
                    WalkOctree(camera, ref visibleNodeList, queue, child, visibleBounds, childfoundvisible, onlyShadowCasters,
                               displayNodes, showBoundingBoxes);
                }
            }
        }
コード例 #12
0
        /** Walks through the octree, adding any visible objects to the render queue.
        @remarks
        If any octant in the octree if completely within the the view frustum,
        all subchildren are automatically added with no visibility tests.
        */
        public void WalkOctree(OctreeCamera camera, RenderQueue queue, Octree octant, 
                               VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters, bool foundVisible) {
            //return immediately if nothing is in the node.
            if(octant.NumNodes == 0) {
                return;
            }

            Visibility v = Visibility.None;
 
            if(foundVisible) {
                v = Visibility.Full;
            }
            else if(octant == octree) {
                v = Visibility.Partial;
            }
            else {
                AxisAlignedBox box = octant.CullBounds;
                v = camera.GetVisibility(box);
            }

            // if the octant is visible, or if it's the root node...
            if(v != Visibility.None) {
                if(this.ShowBoundingBoxes) {
                    // TODO: Implement Octree.WireBoundingBox
                    //boxList.Add(octant.WireBoundingBox); 
                }

                bool vis = true;

                for(int i = 0; i < octant.NodeList.Count; i++) {
                    OctreeNode node = (OctreeNode)octant.NodeList[i];
					
                    // if this octree is partially visible, manually cull all
                    // scene nodes attached directly to this level.

                    if(v == Visibility.Partial) {
                        vis = camera.IsObjectVisible(node.WorldAABB);
                    }

                    if(vis)  {
                        numObjects++;
                        node.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                        visible.Add(node);

                        if(DisplayNodes) {
                            GetRenderQueue().AddRenderable(node);
                        }

                        // check if the scene manager or this node wants the bounding box shown.
                        if(node.ShowBoundingBox || this.ShowBoundingBoxes) {
                            node.AddBoundingBoxToQueue(queue);
                        }
                    }
                }
				
                if(octant.Children[0,0,0] != null ) WalkOctree(camera, queue, octant.Children[0,0,0], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[1,0,0] != null ) WalkOctree(camera, queue, octant.Children[1,0,0], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[0,1,0] != null ) WalkOctree(camera, queue, octant.Children[0,1,0], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[1,1,0] != null ) WalkOctree(camera, queue, octant.Children[1,1,0], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[0,0,1] != null ) WalkOctree(camera, queue, octant.Children[0,0,1], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[1,0,1] != null ) WalkOctree(camera, queue, octant.Children[1,0,1], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[0,1,1] != null ) WalkOctree(camera, queue, octant.Children[0,1,1], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );

                if(octant.Children[1,1,1] != null ) WalkOctree(camera, queue, octant.Children[1,1,1], visibleBounds, onlyShadowCasters, ( v == Visibility.Full ) );
            }			
        }
コード例 #13
0
 public void processVisibleObject(MovableObject mo, Camera cam, bool onlyShadowCasters, VisibleObjectsBoundsInfo visibleBounds)
 {
     OgrePINVOKE.RenderQueue_processVisibleObject(swigCPtr, MovableObject.getCPtr(mo), Camera.getCPtr(cam), onlyShadowCasters, VisibleObjectsBoundsInfo.getCPtr(visibleBounds));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="camera"></param>
 public override void FindVisibleObjects(Camera camera, VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters)
 {
     base.FindVisibleObjects(camera, visibleBounds, onlyShadowCasters);
 }
コード例 #15
0
ファイル: DefaultZone.cs プロジェクト: axiom3d/axiom
        /*
         *      // Recursively walk the zones, adding all visible SceneNodes to the list of visible nodes.
         */

        public override void FindVisibleNodes(PCZCamera camera, ref List <PCZSceneNode> visibleNodeList, RenderQueue queue,
                                              VisibleObjectsBoundsInfo visibleBounds, bool onlyShadowCasters,
                                              bool displayNodes, bool showBoundingBoxes)
        {
            //return immediately if nothing is in the zone.
            if (mHomeNodeList.Count == 0 && mVisitorNodeList.Count == 0 && mPortals.Count == 0)
            {
                return;
            }

            // Else, the zone is automatically assumed to be visible since either
            // it is the camera the zone is in, or it was reached because
            // a connecting portal was deemed visible to the camera.

            // enable sky if called to do so for this zone
            if (HasSky)
            {
                // enable sky
                mPCZSM.EnableSky(true);
            }

            // find visible nodes at home in the zone
            bool vis;

            foreach (PCZSceneNode pczsn in mHomeNodeList)
            {
                //PCZSceneNode pczsn = *it;
                // if the scene node is already visible, then we can skip it
                if (pczsn.LastVisibleFrame != mLastVisibleFrame || pczsn.LastVisibleFromCamera != camera)
                {
                    FrustumPlane fPlane;
                    // for a scene node, check visibility using AABB
                    vis = camera.IsObjectVisible(pczsn.WorldAABB, out fPlane);
                    if (vis)
                    {
                        // add it to the list of visible nodes
                        visibleNodeList.Add(pczsn);
                        // add the node to the render queue
                        pczsn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                        // if we are displaying nodes, add the node renderable to the queue
                        if (displayNodes)
                        {
                            queue.AddRenderable(pczsn.GetDebugRenderable());
                        }
                        // if the scene manager or the node wants the bounding box shown, add it to the queue
                        if (pczsn.ShowBoundingBox || showBoundingBoxes)
                        {
                            pczsn.AddBoundingBoxToQueue(queue);
                        }
                        // flag the node as being visible this frame
                        pczsn.LastVisibleFrame      = mLastVisibleFrame;
                        pczsn.LastVisibleFromCamera = camera;
                    }
                }
            }
            // find visible visitor nodes

            foreach (PCZSceneNode pczsn in mVisitorNodeList)
            {
                // if the scene node is already visible, then we can skip it
                if (pczsn.LastVisibleFrame != mLastVisibleFrame || pczsn.LastVisibleFromCamera != camera)
                {
                    FrustumPlane fPlane;
                    // for a scene node, check visibility using AABB
                    vis = camera.IsObjectVisible(pczsn.WorldAABB, out fPlane);
                    if (vis)
                    {
                        // add it to the list of visible nodes
                        visibleNodeList.Add(pczsn);
                        // add the node to the render queue
                        pczsn.AddToRenderQueue(camera, queue, onlyShadowCasters, visibleBounds);
                        // if we are displaying nodes, add the node renderable to the queue
                        if (displayNodes)
                        {
                            queue.AddRenderable(pczsn.GetDebugRenderable());
                        }
                        // if the scene manager or the node wants the bounding box shown, add it to the queue
                        if (pczsn.ShowBoundingBox || showBoundingBoxes)
                        {
                            pczsn.AddBoundingBoxToQueue(queue);
                        }
                        // flag the node as being visible this frame
                        pczsn.LastVisibleFrame      = mLastVisibleFrame;
                        pczsn.LastVisibleFromCamera = camera;
                    }
                }
            }

            // find visible portals in the zone and recurse into them
            foreach (Portal portal in mPortals)
            {
                FrustumPlane fPlane;
                // for portal, check visibility using world bounding sphere & direction
                vis = camera.IsObjectVisible(portal, out fPlane);
                if (vis)
                {
                    // portal is visible. Add the portal as extra culling planes to camera
                    int planes_added = camera.AddPortalCullingPlanes(portal);
                    // tell target zone it's visible this frame
                    portal.getTargetZone().LastVisibleFrame      = mLastVisibleFrame;
                    portal.getTargetZone().LastVisibleFromCamera = camera;
                    // recurse into the connected zone
                    portal.getTargetZone().FindVisibleNodes(camera, ref visibleNodeList, queue, visibleBounds, onlyShadowCasters,
                                                            displayNodes, showBoundingBoxes);
                    if (planes_added > 0)
                    {
                        // Then remove the extra culling planes added before going to the next portal in this zone.
                        camera.RemovePortalCullingPlanes(portal);
                    }
                }
            }
        }