コード例 #1
0
ファイル: PCZSceneQuery.cs プロジェクト: axiom3d/axiom
        public override void Execute(ISceneQueryListener listener)
        {
            var list         = new List <PCZSceneNode>();
            var checkedNodes = new List <PCZSceneNode>();

            foreach (PlaneBoundedVolume volume in volumes)
            {
                //find the nodes that intersect the AAB
                ((PCZSceneManager)creator).FindNodesIn(volume, ref list, this.startZone, (PCZSceneNode)this.excludeNode);

                //grab all moveables from the node that intersect...
                foreach (PCZSceneNode node in list)
                {
                    // avoid double-check same scene node
                    if (!checkedNodes.Contains(node))
                    {
                        continue;
                    }

                    checkedNodes.Add(node);

                    foreach (MovableObject m in node.Objects)
                    {
                        if ((m.QueryFlags & queryMask) != 0 && (m.TypeFlags & this.queryTypeMask) != 0 && m.IsAttached &&
                            volume.Intersects(m.GetWorldBoundingBox()))
                        {
                            listener.OnQueryResult(m);
                            // deal with attached objects, since they are not directly attached to nodes
                            if (m.MovableType == "Entity")
                            {
                                //Check: not sure here...
                                var e = (Entity)m;
                                foreach (MovableObject c in e.SubEntities)
                                {
                                    if ((c.QueryFlags & queryMask) > 0 && volume.Intersects(c.GetWorldBoundingBox()))
                                    {
                                        listener.OnQueryResult(c);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // reset startzone and exclude node
            this.startZone   = null;
            this.excludeNode = null;
        }
コード例 #2
0
ファイル: PCZSceneQuery.cs プロジェクト: WolfgangSt/axiom
		/// <summary>
		///     Finds any entities that intersect the AAB for the query.
		/// </summary>
		/// <param name="listener">
		///     The listener to call when we find the results.
		/// </param>
		public override void Execute( ISceneQueryListener listener )
		{
			List<PCZSceneNode> list = new List<PCZSceneNode>();
			//find the nodes that intersect the AAB
			( (PCZSceneManager)creator ).FindNodesIn( box, ref list, startZone, (PCZSceneNode)excludeNode );

			//grab all moveables from the node that intersect...

			foreach ( PCZSceneNode node in list )
			{
				foreach ( MovableObject m in node.Objects )
				{
					if ( ( m.QueryFlags & queryMask ) != 0 &&
						( m.TypeFlags & queryTypeMask ) != 0 &&
						m.IsAttached &&
						box.Intersects( m.GetWorldBoundingBox() ) )
					{

						listener.OnQueryResult( m );
						// deal with attached objects, since they are not directly attached to nodes
						if ( m.MovableType == "Entity" )
						{
							//Check: not sure here...
							Entity e = (Entity)m;
							foreach ( MovableObject c in e.SubEntities )
							{
								if ( ( c.QueryFlags & queryMask ) > 0 )
								{
									listener.OnQueryResult( c );
								}
							}
						}
					}

				}
			}
			// reset startzone and exclude node
			startZone = null;
			excludeNode = null;
		}
コード例 #3
0
ファイル: SceneManager.cs プロジェクト: mono-soc-2011/axiom
		public override void Execute( ISceneQueryListener listener )
		{
			MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories;
			foreach ( KeyValuePair<string, MovableObjectFactory> map in factories )
			{
				MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type );
				foreach ( MovableObject movableObject in movableObjects.Values )
				{
					// skip group if query type doesn't match
					if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 )
					{
						break;
					}

					// skip if unattached or filtered out by query flags
					if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 )
					{
						continue;
					}

					for ( int v = 0; v < this.volumes.Count; v++ )
					{
						PlaneBoundedVolume volume = (PlaneBoundedVolume)this.volumes[ v ];
						// Do AABB / plane volume test
						if ( ( movableObject.QueryFlags & this.queryMask ) != 0
							 && volume.Intersects( movableObject.GetWorldBoundingBox() ) )
						{
							listener.OnQueryResult( movableObject );
							break;
						}
					}
				}
			}
		}
コード例 #4
0
ファイル: SceneManager.cs プロジェクト: mono-soc-2011/axiom
		public override void Execute( ISceneQueryListener listener )
		{
			Sphere testSphere = new Sphere();

			MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories;
			foreach ( KeyValuePair<string, MovableObjectFactory> map in factories )
			{
				MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type );
				foreach ( MovableObject movableObject in movableObjects.Values )
				{
					// skip group if query type doesn't match
					if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 )
					{
						break;
					}

					// skip if unattached or filtered out by query flags
					if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 )
					{
						continue;
					}

					testSphere.Center = movableObject.ParentNode.DerivedPosition;
					testSphere.Radius = movableObject.BoundingRadius;

					// if the results came back positive, fire the event handler
					if ( this.sphere.Intersects( testSphere ) )
					{
						listener.OnQueryResult( movableObject );
					}
				}
			}
		}
コード例 #5
0
ファイル: SceneManager.cs プロジェクト: mono-soc-2011/axiom
		public override void Execute( ISceneQueryListener listener )
		{
			MovableObjectFactoryMap factories = Root.Instance.MovableObjectFactories;
			foreach ( KeyValuePair<string, MovableObjectFactory> map in factories )
			{
				MovableObjectCollection movableObjects = this.creator.GetMovableObjectCollection( map.Value.Type );
				foreach ( MovableObject movableObject in movableObjects.Values )
				{
					// skip group if query type doesn't match
					if ( ( this.QueryTypeMask & movableObject.TypeFlags ) == 0 )
					{
						break;
					}

					// skip if unattached or filtered out by query flags
					if ( !movableObject.IsAttached || ( movableObject.QueryFlags & this.queryMask ) == 0 )
					{
						continue;
					}

					if ( this.box.Intersects( movableObject.GetWorldBoundingBox() ) )
					{
						listener.OnQueryResult( movableObject );
					}
				}
			}
		}
コード例 #6
0
		public override void Execute( ISceneQueryListener listener )
		{
			this.listener = listener;
			this.foundIntersections.Clear();
			ProcessNode( ( (BspSceneManager)creator ).Level.RootNode );
		}
コード例 #7
0
ファイル: PCZSceneQuery.cs プロジェクト: ryan-bunker/axiom3d
		public override void Execute( ISceneQueryListener listener )
		{
			var list = new List<PCZSceneNode>();
			var checkedNodes = new List<PCZSceneNode>();

			foreach ( PlaneBoundedVolume volume in volumes )
			{
				//find the nodes that intersect the AAB
				( (PCZSceneManager)creator ).FindNodesIn( volume, ref list, this.startZone, (PCZSceneNode)this.excludeNode );

				//grab all moveables from the node that intersect...
				foreach ( PCZSceneNode node in list )
				{
					// avoid double-check same scene node
					if ( !checkedNodes.Contains( node ) )
					{
						continue;
					}

					checkedNodes.Add( node );

					foreach ( MovableObject m in node.Objects )
					{
						if ( ( m.QueryFlags & queryMask ) != 0 && ( m.TypeFlags & this.queryTypeMask ) != 0 && m.IsAttached &&
						     volume.Intersects( m.GetWorldBoundingBox() ) )
						{
							listener.OnQueryResult( m );
							// deal with attached objects, since they are not directly attached to nodes
							if ( m.MovableType == "Entity" )
							{
								//Check: not sure here...
								var e = (Entity)m;
								foreach ( MovableObject c in e.SubEntities )
								{
									if ( ( c.QueryFlags & queryMask ) > 0 && volume.Intersects( c.GetWorldBoundingBox() ) )
									{
										listener.OnQueryResult( c );
									}
								}
							}
						}
					}
				}
			}
			// reset startzone and exclude node
			this.startZone = null;
			this.excludeNode = null;
		}
コード例 #8
0
ファイル: SceneQuery.cs プロジェクト: ryan-bunker/axiom3d
		/// <summary>
		///		Executes the query and returns each match through a listener interface.
		/// </summary>
		/// <remarks>
		///		Note that this method does not store the results of the query internally
		///		so does not update the 'last result' value. This means that this version of
		///		execute is more lightweight and therefore more efficient than the version
		///		which returns the results as a collection.
		/// </remarks>
		/// <param name="listener"></param>
		public abstract void Execute( ISceneQueryListener listener );
コード例 #9
0
        public override void Execute(ISceneQueryListener listener)
        {
            // TODO: BillboardSets? Will need per-billboard collision most likely
            // Entities only for now
            foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) {
                foreach (MovableObject obj in objectMap.Values) {
                    // skip if unattached or filtered out by query flags
                    if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) {
                        continue;
                    }

                    if (box.Intersects(obj.GetWorldBoundingBox())) {
                        listener.OnQueryResult(obj);
                    }
                }
            }
        }
コード例 #10
0
        public override void Execute(ISceneQueryListener listener)
        {
            // TODO: BillboardSets? Will need per-billboard collision most likely
            // Entities only for now
            Sphere testSphere = new Sphere();

            foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) {
                foreach (MovableObject obj in objectMap.Values) {
                    // skip if unattached or filtered out by query flags
                    if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) {
                        continue;
                    }

                    testSphere.Center = obj.ParentNode.DerivedPosition;
                    testSphere.Radius = obj.BoundingRadius;

                    // if the results came back positive, fire the event handler
                    if (sphere.Intersects(testSphere)) {
                        listener.OnQueryResult(obj);
                    }
                }
            }
        }
コード例 #11
0
        public override void Execute(ISceneQueryListener listener)
        {
            foreach (Dictionary<string, MovableObject> objectMap in creator.MovableObjectMaps) {
                foreach (MovableObject obj in objectMap.Values) {
                    // skip if unattached or filtered out by query flags
                    if (!obj.IsAttached || (obj.QueryFlags & queryMask) == 0) {
                        continue;
                    }

                    for (int v = 0; v < volumes.Count; v++) {
                        PlaneBoundedVolume volume = (PlaneBoundedVolume)volumes[v];
                        // Do AABB / plane volume test
                        if ((obj.QueryFlags & queryMask) != 0 && volume.Intersects(obj.GetWorldBoundingBox())) {
                            listener.OnQueryResult(obj);
                            break;
                        }
                    }
                }
            }
        }
コード例 #12
0
 /// <summary>
 ///		Executes the query and returns each match through a listener interface.
 /// </summary>
 /// <remarks>
 ///		Note that this method does not store the results of the query internally
 ///		so does not update the 'last result' value. This means that this version of
 ///		execute is more lightweight and therefore more efficient than the version
 ///		which returns the results as a collection.
 /// </remarks>
 /// <param name="listener"></param>
 public abstract void Execute(ISceneQueryListener listener);