public Octree(Octree parent)
        {
            this.wireBoundingBox = null;
            this.HalfSize = new Vector3();

            this.parent = parent;
            this.NumNodes = 0;
        }
        public void Init(AxisAlignedBox box, int depth) {
            rootSceneNode = new OctreeNode(this, "SceneRoot");

            maxDepth = depth;

            octree = new Octree(null);

            octree.Box = box;

            Vector3 Min = box.Minimum;
            Vector3 Max = box.Maximum;

            octree.HalfSize = (Max - Min) / 2;

            numObjects = 0;

            Vector3 scalar = new Vector3(1.5f,1.5f,1.5f);

            scaleFactor.Scale = scalar;
        }
示例#3
0
        public void Init(AxisAlignedBox box, int depth)
        {
            rootSceneNode = new OctreeNode(this, "SceneRoot");
            rootSceneNode.SetAsRootNode();
            defaultRootNode = rootSceneNode;

            this.maxDepth = depth;

            this.octree = new Octree(null);

            this.octree.Box = box;

            Vector3 Min = box.Minimum;
            Vector3 Max = box.Maximum;

            this.octree.HalfSize = (Max - Min) / 2;

            this.numObjects = 0;

            var scalar = new Vector3(1.5f, 1.5f, 1.5f);

            this.scaleFactor.Scale = scalar;
        }
示例#4
0
			public WalkQueueObject( Octree octant, bool foundVisible )
			{
				FoundVisible = foundVisible;
				Octant = octant;
			}
示例#5
0
		public void Init( AxisAlignedBox box, int depth )
		{
			rootSceneNode = new OctreeNode( this, "SceneRoot" );
			rootSceneNode.SetAsRootNode();
			defaultRootNode = rootSceneNode;

			maxDepth = depth;

			octree = new Octree( null );

			octree.Box = box;

			Vector3 Min = box.Minimum;
			Vector3 Max = box.Maximum;

			octree.HalfSize = ( Max - Min ) / 2;

			numObjects = 0;

			Vector3 scalar = new Vector3( 1.5f, 1.5f, 1.5f );

			scaleFactor.Scale = scalar;
		}
        /** 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 ) );
            }
        }
        /*public void AddOctreeNode(OctreeNode node, Octree octree)
        {

        }*/
        /** Resizes the octree to the given size */
        public void Resize(AxisAlignedBox box)
        {
            List<SceneNode> nodes = new List<SceneNode>();

            FindNodes(this.octree.Box, nodes, null, true, this.octree);

            octree = new Octree(null);
            octree.Box = box;

            foreach (OctreeNode node in nodes) {
                node.Octant = null;
                UpdateOctreeNode(node);
            }
        }
示例#8
0
 public WalkQueueObject(Octree octant, bool foundVisible)
 {
     this.FoundVisible = foundVisible;
     this.Octant       = octant;
 }
示例#9
0
		public void FindNodes( AxisAlignedBox box, SceneNodeCollection sceneNodeList, SceneNode exclude, bool full, Octree octant )
		{
			List<OctreeNode> localList = new List<OctreeNode>();
			if ( octant == null )
			{
				octant = this.octree;
			}

			if ( !full )
			{
				AxisAlignedBox obox = octant.CullBounds;

				Intersection isect = this.Intersect( box, obox );

				if ( isect == Intersection.Outside )
				{
					return;
				}

				full = ( isect == Intersection.Inside );
			}

			foreach ( OctreeNode node in octant.NodeList.Values )
			{
				if ( node != exclude )
				{
					if ( full )
					{
						localList.Add( node );
					}
					else
					{
						Intersection nsect = this.Intersect( box, node.WorldAABB );

						if ( nsect != Intersection.Outside )
						{
							localList.Add( node );
						}
					}
				}
			}

			if ( octant.Children[ 0, 0, 0 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 0, 0, 0 ] );

			if ( octant.Children[ 1, 0, 0 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 1, 0, 0 ] );

			if ( octant.Children[ 0, 1, 0 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 0, 1, 0 ] );

			if ( octant.Children[ 1, 1, 0 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 1, 1, 0 ] );

			if ( octant.Children[ 0, 0, 1 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 0, 0, 1 ] );

			if ( octant.Children[ 1, 0, 1 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 1, 0, 1 ] );

			if ( octant.Children[ 0, 1, 1 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 0, 1, 1 ] );

			if ( octant.Children[ 1, 1, 1 ] != null )
				FindNodes( box, sceneNodeList, exclude, full, octant.Children[ 1, 1, 1 ] );

		}
示例#10
0
		public void AddOctreeNode( OctreeNode node, Octree octant, int depth )
		{
			AxisAlignedBox box = node.WorldAABB;

			//if the octree is twice as big as the scene node,
			//we will add it to a child.
			if ( ( depth < maxDepth ) && octant.IsTwiceSize( box ) )
			{
				int x, y, z;

				octant.GetChildIndexes( box, out x, out y, out z );

				if ( octant.Children[ x, y, z ] == null )
				{
					octant.Children[ x, y, z ] = new Octree( octant );

					Vector3[] corners = octant.Box.Corners;

					Vector3 min, max;

					if ( x == 0 )
					{
						min.x = corners[ 0 ].x;
						max.x = ( corners[ 0 ].x + corners[ 4 ].x ) / 2;
					}
					else
					{
						min.x = ( corners[ 0 ].x + corners[ 4 ].x ) / 2;
						max.x = corners[ 4 ].x;
					}

					if ( y == 0 )
					{
						min.y = corners[ 0 ].y;
						max.y = ( corners[ 0 ].y + corners[ 4 ].y ) / 2;
					}

					else
					{
						min.y = ( corners[ 0 ].y + corners[ 4 ].y ) / 2;
						max.y = corners[ 4 ].y;
					}

					if ( z == 0 )
					{
						min.z = corners[ 0 ].z;
						max.z = ( corners[ 0 ].z + corners[ 4 ].z ) / 2;
					}

					else
					{
						min.z = ( corners[ 0 ].z + corners[ 4 ].z ) / 2;
						max.z = corners[ 4 ].z;
					}

					octant.Children[ x, y, z ].Box.SetExtents( min, max );
					octant.Children[ x, y, z ].HalfSize = ( max - min ) / 2;

				}

				AddOctreeNode( node, octant.Children[ x, y, z ], ++depth );
			}
			else
			{
				octant.AddNode( node );
			}
		}
 public void AddOctreeNode(OctreeNode node, Octree octant) {
     AddOctreeNode(node, octant, 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 FindNodes(AxisAlignedBox box, SceneNodeCollection sceneNodeList, SceneNode exclude, bool full,
                              Octree octant)
        {
            var localList = new List <OctreeNode>();

            if (octant == null)
            {
                octant = this.octree;
            }

            if (!full)
            {
                AxisAlignedBox obox = octant.CullBounds;

                Intersection isect = Intersect(box, obox);

                if (isect == Intersection.Outside)
                {
                    return;
                }

                full = (isect == Intersection.Inside);
            }

            foreach (OctreeNode node in octant.NodeList.Values)
            {
                if (node != exclude)
                {
                    if (full)
                    {
                        localList.Add(node);
                    }
                    else
                    {
                        Intersection nsect = Intersect(box, node.WorldAABB);

                        if (nsect != Intersection.Outside)
                        {
                            localList.Add(node);
                        }
                    }
                }
            }

            if (octant.Children[0, 0, 0] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[0, 0, 0]);
            }

            if (octant.Children[1, 0, 0] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[1, 0, 0]);
            }

            if (octant.Children[0, 1, 0] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[0, 1, 0]);
            }

            if (octant.Children[1, 1, 0] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[1, 1, 0]);
            }

            if (octant.Children[0, 0, 1] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[0, 0, 1]);
            }

            if (octant.Children[1, 0, 1] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[1, 0, 1]);
            }

            if (octant.Children[0, 1, 1] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[0, 1, 1]);
            }

            if (octant.Children[1, 1, 1] != null)
            {
                FindNodes(box, sceneNodeList, exclude, full, octant.Children[1, 1, 1]);
            }
        }
示例#14
0
        public void AddOctreeNode(OctreeNode node, Octree octant, int depth)
        {
            AxisAlignedBox box = node.WorldAABB;

            //if the octree is twice as big as the scene node,
            //we will add it to a child.
            if ((depth < this.maxDepth) && octant.IsTwiceSize(box))
            {
                int x, y, z;

                octant.GetChildIndexes(box, out x, out y, out z);

                if (octant.Children[x, y, z] == null)
                {
                    octant.Children[x, y, z] = new Octree(octant);

                    Vector3[] corners = octant.Box.Corners;

                    Vector3 min, max;

                    if (x == 0)
                    {
                        min.x = corners[0].x;
                        max.x = (corners[0].x + corners[4].x) / 2;
                    }
                    else
                    {
                        min.x = (corners[0].x + corners[4].x) / 2;
                        max.x = corners[4].x;
                    }

                    if (y == 0)
                    {
                        min.y = corners[0].y;
                        max.y = (corners[0].y + corners[4].y) / 2;
                    }

                    else
                    {
                        min.y = (corners[0].y + corners[4].y) / 2;
                        max.y = corners[4].y;
                    }

                    if (z == 0)
                    {
                        min.z = corners[0].z;
                        max.z = (corners[0].z + corners[4].z) / 2;
                    }

                    else
                    {
                        min.z = (corners[0].z + corners[4].z) / 2;
                        max.z = corners[4].z;
                    }

                    octant.Children[x, y, z].Box.SetExtents(min, max);
                    octant.Children[x, y, z].HalfSize = (max - min) / 2;
                }

                AddOctreeNode(node, octant.Children[x, y, z], ++depth);
            }
            else
            {
                octant.AddNode(node);
            }
        }
示例#15
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, bool foundVisible)
        {
            var q    = new Queue <WalkQueueObject>();
            var temp = new WalkQueueObject(octant, foundVisible);

            q.Enqueue(temp);

            while (q.Count > 0)
            {
                temp = q.Dequeue();

                //return immediately if nothing is in the node.
                if (temp.Octant.NumNodes == 0)
                {
                    continue;
                }

                Visibility v = Visibility.None;

                if (temp.FoundVisible)
                {
                    v = Visibility.Full;
                }
                else if (temp.Octant == this.octree)
                {
                    v = Visibility.Partial;
                }
                else
                {
                    AxisAlignedBox box = temp.Octant.CullBounds;
                    v = camera.GetVisibility(box);
                }


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

                    bool vis = true;

                    foreach (OctreeNode node in temp.Octant.NodeList.Values)
                    {
                        // 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)
                        {
                            this.numObjects++;
                            node.AddToRenderQueue(camera, queue);

                            this.visible.Add(node);

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

                            // check if the scene manager or this node wants the bounding box shown.
                            if (node.ShowBoundingBox || ShowBoundingBoxes)
                            {
                                node.AddBoundingBoxToQueue(queue);
                            }
                        }
                    }

                    if (temp.Octant.Children[0, 0, 0] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[0, 0, 0], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 0, 0, 0 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[1, 0, 0] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[1, 0, 0], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 1, 0, 0 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[0, 1, 0] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[0, 1, 0], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 0, 1, 0 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[1, 1, 0] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[1, 1, 0], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 1, 1, 0 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[0, 0, 1] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[0, 0, 1], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 0, 0, 1 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[1, 0, 1] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[1, 0, 1], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 1, 0, 1 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[0, 1, 1] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[0, 1, 1], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 0, 1, 1 ], ( v == Visibility.Full ) );
                        //continue;
                    }

                    if (temp.Octant.Children[1, 1, 1] != null)
                    {
                        q.Enqueue(new WalkQueueObject(temp.Octant.Children[1, 1, 1], v == Visibility.Full));
                        //WalkOctree( camera, queue, octant.Children[ 1, 1, 1 ], ( v == Visibility.Full ) );
                        //continue;
                    }
                }
            }
        }
示例#16
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, bool foundVisible )
		{

			Queue<WalkQueueObject> q = new Queue<WalkQueueObject>();
			WalkQueueObject temp = new WalkQueueObject( octant, foundVisible );

			q.Enqueue( temp );

			while ( q.Count > 0 )
			{

				temp = q.Dequeue();

				//return immediately if nothing is in the node.
				if ( temp.Octant.NumNodes == 0 )
				{
					continue;
				}

				Visibility v = Visibility.None;

				if ( temp.FoundVisible )
				{
					v = Visibility.Full;
				}
				else if ( temp.Octant == octree )
				{
					v = Visibility.Partial;
				}
				else
				{
					AxisAlignedBox box = temp.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 )
					{
						boxList.Add( temp.Octant.WireBoundingBox );
					}

					bool vis = true;

					foreach ( OctreeNode node in temp.Octant.NodeList.Values )
					{
						// 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 );

							visible.Add( node );

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

							// check if the scene manager or this node wants the bounding box shown.
							if ( node.ShowBoundingBox || this.ShowBoundingBoxes )
							{
								node.AddBoundingBoxToQueue( queue );
							}
						}
					}

					if ( temp.Octant.Children[ 0, 0, 0 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 0, 0, 0 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 0, 0, 0 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 1, 0, 0 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 1, 0, 0 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 1, 0, 0 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 0, 1, 0 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 0, 1, 0 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 0, 1, 0 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 1, 1, 0 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 1, 1, 0 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 1, 1, 0 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 0, 0, 1 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 0, 0, 1 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 0, 0, 1 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 1, 0, 1 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 1, 0, 1 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 1, 0, 1 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 0, 1, 1 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 0, 1, 1 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 0, 1, 1 ], ( v == Visibility.Full ) );
						//continue;
					}

					if ( temp.Octant.Children[ 1, 1, 1 ] != null )
					{
						q.Enqueue( new WalkQueueObject( temp.Octant.Children[ 1, 1, 1 ], v == Visibility.Full ) );
						//WalkOctree( camera, queue, octant.Children[ 1, 1, 1 ], ( v == Visibility.Full ) );
						//continue;
					}
				}
			}
		}
示例#17
0
		public void AddOctreeNode( OctreeNode node, Octree octant )
		{
			AddOctreeNode( node, octant, 0 );
		}
        public void FindNodes(AxisAlignedBox box, List<SceneNode> sceneNodeList, SceneNode exclude, bool full, Octree octant) {
            System.Collections.ArrayList localList = new System.Collections.ArrayList();
            if(octant == null) {
                octant = this.octree;
            }

            if(!full) {
                AxisAlignedBox obox = octant.CullBounds;

                Intersection isect = this.Intersect(box,obox);

                if(isect == Intersection.Outside) {
                    return;
                }

                full = (isect == Intersection.Inside);
            }

            for(int i=0;i<octant.NodeList.Count;i++) {
                OctreeNode node = (OctreeNode)octant.NodeList[i];

                if(node != exclude) {
                    if(full) {
                        localList.Add(node);
                    }
                    else {
                        Intersection nsect = this.Intersect(box,node.WorldAABB);

                        if(nsect != Intersection.Outside) {
                            localList.Add(node);
                        }
                    }
                }
            }

            if ( octant.Children[0,0,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,0,0]);

            if ( octant.Children[1,0,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,0,0]);

            if ( octant.Children[0,1,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,1,0] );

            if ( octant.Children[1,1,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,1,0]);

            if ( octant.Children[0,0,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,0,1]);

            if ( octant.Children[1,0,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,0,1]);

            if ( octant.Children[0,1,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,1,1]);

            if ( octant.Children[1,1,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,1,1]);

        }
示例#19
0
		/*public void AddOctreeNode(OctreeNode node, Octree octree)
		{


		}*/

		/** Resizes the octree to the given size */
		public void Resize( AxisAlignedBox box )
		{
			NodeCollection nodes = new NodeCollection();

			FindNodes( this.octree.Box, base.sceneNodeList, null, true, this.octree );

			octree = new Octree( null );
			octree.Box = box;

			foreach ( OctreeNode node in nodes.Values )
			{
				node.Octant = null;
				UpdateOctreeNode( node );
			}
		}
 public void FindNodes(Sphere sphere, List<SceneNode> sceneNodeList, SceneNode exclude, bool full, Octree octant) {
     //TODO: Implement
 }
示例#21
0
		public void FindNodes( Sphere sphere, SceneNodeCollection sceneNodeList, SceneNode exclude, bool full, Octree octant )
		{
			//TODO: Implement
		}
        public void FindNodes(AxisAlignedBox box, List<SceneNode> sceneNodeList, SceneNode exclude, bool full, Octree octant)
        {
            System.Collections.ArrayList localList = new System.Collections.ArrayList();
            if(octant == null) {
                octant = this.octree;
            }

            if(!full) {
                AxisAlignedBox obox = octant.CullBounds;

                Intersection isect = this.Intersect(box,obox);

                if(isect == Intersection.Outside) {
                    return;
                }

                full = (isect == Intersection.Inside);
            }

            for(int i=0;i<octant.NodeList.Count;i++) {
                OctreeNode node = (OctreeNode)octant.NodeList[i];

                if(node != exclude) {
                    if(full) {
                        localList.Add(node);
                    }
                    else {
                        Intersection nsect = this.Intersect(box,node.WorldAABB);

                        if(nsect != Intersection.Outside) {
                            localList.Add(node);
                        }
                    }
                }
            }

            if ( octant.Children[0,0,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,0,0]);

            if ( octant.Children[1,0,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,0,0]);

            if ( octant.Children[0,1,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,1,0] );

            if ( octant.Children[1,1,0] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,1,0]);

            if ( octant.Children[0,0,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,0,1]);

            if ( octant.Children[1,0,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,0,1]);

            if ( octant.Children[0,1,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[0,1,1]);

            if ( octant.Children[1,1,1] != null ) FindNodes( box, sceneNodeList, exclude, full, octant.Children[1,1,1]);
        }