当前位置: 首页>>代码示例>>C#>>正文


C# EntityCollidable.RayCast方法代码示例

本文整理汇总了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;
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:39,代码来源:FluidVolume.cs


注:本文中的BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable.RayCast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。