本文整理汇总了C#中BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable.RayCast方法的典型用法代码示例。如果您正苦于以下问题:C# EntityCollidable.RayCast方法的具体用法?C# EntityCollidable.RayCast怎么用?C# EntityCollidable.RayCast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable
的用法示例。
在下文中一共展示了EntityCollidable.RayCast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSubmergedHeight
float GetSubmergedHeight(EntityCollidable collidable, float maxLength, float boundingBoxHeight, ref System.Numerics.Vector3 rayOrigin, ref System.Numerics.Vector3 xSpacing, ref System.Numerics.Vector3 zSpacing, int i, int j, out System.Numerics.Vector3 volumeCenter)
{
Ray ray;
Vector3Ex.Multiply(ref xSpacing, i, out ray.Position);
Vector3Ex.Multiply(ref zSpacing, j, out ray.Direction);
Vector3Ex.Add(ref ray.Position, ref ray.Direction, out ray.Position);
Vector3Ex.Add(ref ray.Position, ref rayOrigin, out ray.Position);
ray.Direction = upVector;
//do a bottom-up raycast.
RayHit rayHit;
//Only go up to maxLength. If it's further away than maxLength, then it's above the water and it doesn't contribute anything.
if (collidable.RayCast(ray, maxLength, out rayHit))
{
//Position the ray to point from the other side.
Vector3Ex.Multiply(ref ray.Direction, boundingBoxHeight, out ray.Direction);
Vector3Ex.Add(ref ray.Position, ref ray.Direction, out ray.Position);
Vector3Ex.Negate(ref upVector, out ray.Direction);
//Transform the hit into local space.
RigidTransform.TransformByInverse(ref rayHit.Location, ref surfaceTransform, out rayHit.Location);
float bottomY = rayHit.Location.Y;
float bottom = rayHit.T;
System.Numerics.Vector3 bottomPosition = rayHit.Location;
if (collidable.RayCast(ray, boundingBoxHeight - rayHit.T, out rayHit))
{
//Transform the hit into local space.
RigidTransform.TransformByInverse(ref rayHit.Location, ref surfaceTransform, out rayHit.Location);
Vector3Ex.Add(ref rayHit.Location, ref bottomPosition, out volumeCenter);
Vector3Ex.Multiply(ref volumeCenter, .5f, out volumeCenter);
return Math.Min(-bottomY, boundingBoxHeight - rayHit.T - bottom);
}
//This inner raycast should always hit, but just in case it doesn't due to some numerical problem, give it a graceful way out.
volumeCenter = System.Numerics.Vector3.Zero;
return 0;
}
volumeCenter = System.Numerics.Vector3.Zero;
return 0;
}