示例#1
0
		/// <summary>
		/// Classify position relative to plane
		/// </summary>
		/// <param name="plane">Plane</param>
		/// <param name="frontItem">Front item if split required</param>
		/// <param name="backItem">Back item if split required</param>
		/// <returns>Intersection classification</returns>
		public PlaneIntersectionType Intersects( Plane plane, out IBSPItem frontItem, out IBSPItem backItem )
		{
			frontItem = null;
			backItem = null;

            return bounds.Intersects( plane );
		}
示例#2
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="plane">Plane</param>
		/// <param name="normal">Normal</param>
		protected BSPTree( BSPTree parent, IList<IBSPItem> items, PartitionHandler partitionHandler )
		{
			this.parent = parent;
			bounds = GetBounds( items );
			partition = DeterminePartition( items, bounds, partitionHandler );

			if ( items.Count == 1 )
			{
				this.items.Add( items[ 0 ] );
			}
			else
			{
				List<IBSPItem> backItems = new List<IBSPItem>();
				List<IBSPItem> frontItems = new List<IBSPItem>();

				foreach ( IBSPItem item in items )
				{
					Add( item, backItems, frontItems );
				}

				if ( backItems.Count > 0 ) back = new BSPTree( this, backItems, partitionHandler );
				if ( frontItems.Count > 0 ) front = new BSPTree( this, frontItems, partitionHandler );
			}
		}
示例#3
0
		/// <summary>
		/// Add mesh to model
		/// </summary>
		public void Render( MeshGeometry3D target, Point3D cameraPos, double alpha )
		{
			for ( int posIndex = 0; posIndex < geometry.Positions.Count; posIndex += 4 )
			{
				// Just get first vertex normal (assume all the same)
				Plane plane = new Plane( positions[ posIndex ], geometry.Normals[ posIndex ] );

				if ( plane.Classify( cameraPos ) == Halfspace.Positive )
				{
					AddRectangleIndices( target );

					for ( int i = 0; i < 4; ++ i )
					{
						// Add vertex positions
						target.Positions.Add( positions[ posIndex + i ] );
						target.TextureCoordinates.Add( new System.Windows.Point( ( ( materialOffset - 0.5 ) * alpha ) + 0.5, 0 ) );
					}
				}
			}
		}