Exemple #1
0
		public PCZSceneNode( SceneManager creator, string name )
			: base( creator, name )
		{
			homeZone = null;
			anchored = false;
			allowedToVisit = true;
			lastVisibleFrame = 0;
			lastVisibleFromCamera = null;
			enabled = true;
		}
Exemple #2
0
		/*
		// 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 );
					}
				}
			}
		}
Exemple #3
0
		/** 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 );
Exemple #4
0
        /** 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);
Exemple #5
0
		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 == 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 );

			}
		}
Exemple #6
0
		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,
					   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 );
					}
				}
			}
		}
		// Create a camera for the scene
		public override Camera CreateCamera( string name )
		{
			// Check name not used
			if ( cameraList.ContainsKey( name ) )
			{
				throw new AxiomException( "A camera with the name " + name + " already exists. PCZSceneManager.CreateCamera" );
			}

			Camera c = new PCZCamera( name, this );
			cameraList.Add( name, c );

			// create visible bounds aab map entry
			//TODO: would be very nice to implements shadows processing like ogre does now...
			//mCamVisibleObjectsMap[c] = VisibleObjectsBoundsInfo();

			// tell all the zones about the new camera
			foreach ( PCZone zone in this.zones )
			{
				zone.NotifyCameraCreated( c );
			}

			return c;
		}
Exemple #8
0
        /*
         *      // 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);
                    }
                }
            }
        }
Exemple #9
0
		public PCZone( PCZSceneManager creator, string name )
		{
			mLastVisibleFrame = 0;
			mLastVisibleFromCamera = null;
			mName = name;
			mZoneTypeName = "ZoneType_Undefined";
			mEnclosureNode = null;
			mPCZSM = creator;
			HasSky = false;
		}