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


C# BoundingSphereD.IntersectRaySphere方法代码示例

本文整理汇总了C#中BoundingSphereD.IntersectRaySphere方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingSphereD.IntersectRaySphere方法的具体用法?C# BoundingSphereD.IntersectRaySphere怎么用?C# BoundingSphereD.IntersectRaySphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingSphereD的用法示例。


在下文中一共展示了BoundingSphereD.IntersectRaySphere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckInput

        private void CheckInput()
        {
            MatrixD headMatrix = MyAPIGateway.Session.ControlledObject.GetHeadMatrix(true);
            RayD ray = new RayD(headMatrix.Translation, headMatrix.Forward);

            BoundingSphereD holoSphere = new BoundingSphereD(m_offset.ToWorld(m_block), m_radiusHolo.Value);
            double tmin, tmax;

            if (!holoSphere.IntersectRaySphere(ray, out tmin, out tmax) || tmin > CrosshairRange)
                return;

            int scroll = MyAPIGateway.Input.DeltaMouseScrollWheelValue();
            if (scroll != 0)
            {
                int scrollSteps = (int)Math.Round(scroll * InputScrollMulti);
                float rangeMulti = 1f;
                while (scrollSteps > 0)
                {
                    rangeMulti *= ScrollRangeMulti;
                    scrollSteps--;
                }
                while (scrollSteps < 0)
                {
                    rangeMulti /= ScrollRangeMulti;
                    scrollSteps++;
                }
                m_rangeDetection.Value *= rangeMulti;
            }

            if (MyAPIGateway.Input.IsNewRightMousePressed())
            {
                m_centreEntityId.Value = 0L;
            }
            else if (MyAPIGateway.Input.IsNewLeftMousePressed())
            {
                IMyEntity firstHit = null;
                double firstHitDistance = CrosshairRange;

                foreach (SeenHolo sh in m_holoEntities.Values)
                    if (sh.Holo.Render.Visible && sh.Holo.PositionComp.WorldAABB.Intersect(ref ray, out tmin, out tmax) && tmin < firstHitDistance)
                    {
                        firstHit = sh.Seen.Entity;
                        firstHitDistance = tmin;
                    }

                if (firstHit != null)
                    m_centreEntityId.Value = firstHit.EntityId;
            }
        }
开发者ID:Souper07,项目名称:Autopilot,代码行数:49,代码来源:Projector.cs

示例2: GetBoneOnSphere

        private Vector3 GetBoneOnSphere(Vector3I center, Vector3I bonePos, MyCubeGrid grid)
        {
            Vector3D worldCenter = BoneToWorld(center, Vector3.Zero, grid);
            Vector3D worldBone = BoneToWorld(bonePos, Vector3.Zero, grid);

            BoundingSphereD sphere = new BoundingSphereD(worldCenter, grid.GridSize);
            Vector3D direction = worldCenter - worldBone;
            direction.Normalize();
            RayD ray = new RayD(worldBone, direction);

            double tmin, tmax;
            if (sphere.IntersectRaySphere(ray, out tmin, out tmax))
            {
                Vector3D onSphere = worldBone + direction * tmin;

                var worldOnSphere = Vector3D.Transform(onSphere, grid.PositionComp.WorldMatrixInvScaled);
                worldOnSphere += new Vector3D(grid.GridSize / MyGridSkeleton.BoneDensity);
                return (worldOnSphere - (Vector3D)(bonePos / (float)MyGridSkeleton.BoneDensity) * grid.GridSize);
            }
            else
            {
                return Vector3.Zero;
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:24,代码来源:MySessionComponentArmorHand.cs


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