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


C# MyCubeGrid.GetLineIntersectionExactGrid方法代码示例

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


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

示例1: IntersectCubes

        protected Vector3I? IntersectCubes(MyCubeGrid grid, out double distance)
        {
            distance = float.MaxValue;

            var line = new LineD(IntersectionStart, IntersectionStart + IntersectionDirection * IntersectionDistance);
            Vector3I position = Vector3I.Zero;
            double dstSqr = double.MaxValue;

            if (grid.GetLineIntersectionExactGrid(ref line, ref position, ref dstSqr))
            {
                distance = Math.Sqrt(dstSqr);
                return position;
            }
            return null;
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:15,代码来源:MyBlockBuilderBase.cs

示例2: Draw

        public override void Draw()
        {
            base.Draw();

            if (!MyFakes.ENABLE_ARMOR_HAND)
            {
                return;
            }

            Vector3 forward = MySector.MainCamera.ForwardVector;
            Vector3D origin = MySector.MainCamera.Position;
            Vector3D end = origin + forward * 100f;

            m_lastCubeGrid = null;
            m_lastBone = null;

            var hitInfo = MyPhysics.CastRay(origin, end, MyPhysics.CollisionLayers.ExplosionRaycastLayer);
            var hitEntity = hitInfo.HasValue ? ((MyPhysicsBody)hitInfo.Value.HkHitInfo.Body.UserObject).Entity : null;

            var grid = (hitEntity as MyCubeGrid);
            if (grid != null)
            {
                m_lastCubeGrid = grid;
                double shortestDistance = double.MaxValue;

                LineD line = new LineD(origin, end);
                Vector3I hitCube = new Vector3I();
                double distanceSquared = double.MaxValue;

                if (m_lastCubeGrid.GetLineIntersectionExactGrid(ref line, ref hitCube, ref distanceSquared))
                {
                    m_lastCube = hitCube;
                }
                else
                {
                    m_lastCube = null;
                }

                foreach (var bone in grid.Skeleton.Bones)
                {
                    var bonePos = (Vector3D)(bone.Key / (float)MyGridSkeleton.BoneDensity) * grid.GridSize + bone.Value;
                    bonePos -= new Vector3D(grid.GridSize / MyGridSkeleton.BoneDensity);
                    Vector3D pos = Vector3D.Transform(bonePos, grid.PositionComp.WorldMatrix);

                    Color color = Color.Red;

                    double distance = MyUtils.GetPointLineDistance(ref origin, ref end, ref pos);
                    if (distance < 0.1f)
                    {
                        double distanceToCamera = (origin - pos).LengthSquared();
                        if (distanceToCamera < shortestDistance)
                        {
                            shortestDistance = distanceToCamera;

                            color = Color.Blue;
                            m_lastBone = bone.Key;
                        }
                    }

                    MyRenderProxy.DebugDrawSphere(pos, 0.05f, color.ToVector3(), 0.5f, false, true);
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:63,代码来源:MySessionComponentArmorHand.cs


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