Exemple #1
0
		Intersect(Ray3 ray )
		{
			float maxS = float.MinValue;
			float minT = float.MaxValue;
			
			// do tests against three sets of planes
			for ( int i = 0; i < 3; ++i )
			{
				// ray is parallel to plane
				//if ( ::IsZero( ray.GetDirection()[i] ) )
				if( float.Epsilon > Math.Abs (ray.direction[i]))
				{
					// ray passes by box
					if ( ray.origin[i] < mMinima[i] || ray.origin[i] > mMaxima[i] )
						return false;
				}
				else
				{
					// compute intersection parameters and sort
						float s = (mMinima[i] - ray.origin[i])/ray.direction[i];
						float t = (mMaxima[i] - ray.origin[i])/ray.direction[i];
					if ( s > t )
					{
						float temp = s;
						s = t;
						t = temp;
					}
					
					// adjust min and max values
					if ( s > maxS )
						maxS = s;
					if ( t < minT )
						minT = t;
					// check for intersection failure
					if ( minT < 0.0f || maxS > minT )
						return false;
				}
			}
			
			// done, have intersection
			return true;
		}//end method Intersect
Exemple #2
0
		//startstartstartstartstartstartstartstartstartstartstartstartstartstartstartstartstart
		#region Sources obsolete - test source 
		private bool _Overlap(Ray3 ray) //20140721 chamto : Stop writing , => func Intersect
		{
			//Formula
			//		Term : parameter => Parameter of Length of Vector

			//		verterR : R(parameter) =  startPt + (dirVtNorm * parameter)
			//		Axis Decomposition : vt = s_pt + d_vt * p
			//			Axis_X : vt_X = s_pt_X + d_vt_X * p
			//			Axis_Y : vt_Y = s_pt_Y + d_vt_Y * p
			//		I do not know the parameter P !!! ->  conversion formula
			//			Axis_X : d_vt_X * p = vt_X - s_pt_X 
			//					 p = (vt_X - s_pt_X) / d_vt_X
			//			Axis_Y : p = (vt_Y - s_pt_Y) / d_vt_Y

			//Slab of AABB 
			//		Term : 
			//		Parameter list : s_x , t_x / s_y , t_y


			//1. init->x , x->y , y->z  Axis Test  



			return true;
		}