本文整理汇总了C#中Axiom.Math.AxisAlignedBox.Intersection方法的典型用法代码示例。如果您正苦于以下问题:C# AxisAlignedBox.Intersection方法的具体用法?C# AxisAlignedBox.Intersection怎么用?C# AxisAlignedBox.Intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axiom.Math.AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox.Intersection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: intersects
//.........这里部分代码省略.........
// the sphere of the portal
if ( mDerivedSphere.Intersects( pczsn.WorldAABB ) &&
mDerivedPlane.GetSide( pczsn.WorldAABB ) == PlaneSide.Both )
{
// intersection but no crossing
// note this means that the node is CURRENTLY touching the portal.
if ( mDerivedPlane.GetSide( pczsn.DerivedPosition ) != PlaneSide.Negative )
{
// the node is on the positive (front) or exactly on the CP of the portal
return PortalIntersectResult.INTERSECT_NO_CROSS;
}
else
{
// the node is on the negative (back) side of the portal - it might be in the wrong zone!
return PortalIntersectResult.INTERSECT_BACK_NO_CROSS;
}
}
// no intersection CURRENTLY. (there might have been an intersection
// during the time between last frame and this frame, but it wasn't a portal
// crossing, and it isn't touching anymore, so it doesn't matter.
return PortalIntersectResult.NO_INTERSECT;
}
else if ( mType == PORTAL_TYPE.PORTAL_TYPE_AABB )
{
// for aabb's we check if the center point went from being inside to being outside
// the aabb (or vice versa) for crossing.
AxisAlignedBox aabb = new AxisAlignedBox( mDerivedCorners[ 0 ], mDerivedCorners[ 1 ] );
//bool previousInside = aabb.contains(pczsn->getPrevPosition());
bool currentInside = aabb.Contains( pczsn.DerivedPosition );
if ( mDirection == Vector3.UnitZ )
{
// portal norm is "outward" pointing, look for going from outside to inside
//if (previousInside == false &&
if ( currentInside == true )
{
return PortalIntersectResult.INTERSECT_CROSS;
}
}
else
{
// portal norm is "inward" pointing, look for going from inside to outside
//if (previousInside == true &&
if ( currentInside == false )
{
return PortalIntersectResult.INTERSECT_CROSS;
}
}
// doesn't cross, but might be touching. This is a little tricky because we only
// care if the node aab is NOT fully contained in the portal aabb because we consider
// the surface of the portal aabb the actual 'portal'. First, check to see if the
// aab of the node intersects the aabb portal
if ( aabb.Intersects( pczsn.WorldAABB ) )
{
// now check if the intersection between the two is not the same as the
// full node aabb, if so, then this means that the node is not fully "contained"
// which is what we are looking for.
AxisAlignedBox overlap = aabb.Intersection( pczsn.WorldAABB );
if ( overlap != pczsn.WorldAABB )
{
return PortalIntersectResult.INTERSECT_NO_CROSS;
}
}
return PortalIntersectResult.NO_INTERSECT;
}
else
{
// for spheres we check if the center point went from being inside to being outside
// the sphere surface (or vice versa) for crossing.
//Real previousDistance2 = mPrevDerivedCP.squaredDistance(pczsn->getPrevPosition());
Real currentDistance2 = mDerivedCP.DistanceSquared( pczsn.DerivedPosition );
Real mRadius2 = mRadius * mRadius;
if ( mDirection == Vector3.UnitZ )
{
// portal norm is "outward" pointing, look for going from outside to inside
//if (previousDistance2 >= mRadius2 &&
if ( currentDistance2 < mRadius2 )
{
return PortalIntersectResult.INTERSECT_CROSS;
}
}
else
{
// portal norm is "inward" pointing, look for going from inside to outside
//if (previousDistance2 < mRadius2 &&
if ( currentDistance2 >= mRadius2 )
{
return PortalIntersectResult.INTERSECT_CROSS;
}
}
// no crossing, but might be touching - check distance
if ( System.Math.Sqrt( System.Math.Abs( mRadius2 - currentDistance2 ) ) <= mRadius )
{
return PortalIntersectResult.INTERSECT_NO_CROSS;
}
return PortalIntersectResult.NO_INTERSECT;
}
}
return PortalIntersectResult.NO_INTERSECT;
}