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


C# BoundingBox.Inflate方法代码示例

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


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

示例1: GuidedMissileLauncher

        public GuidedMissileLauncher(WeaponTargeting weapon)
        {
            m_weaponTarget = weapon;
            myLogger = new Logger("GuidedMissileLauncher", CubeBlock);
            m_relayPart = RelayClient.GetOrCreateRelayPart(m_weaponTarget.CubeBlock);

            var defn = CubeBlock.GetCubeBlockDefinition();

            Vector3[] points = new Vector3[3];
            Vector3 forwardAdjust = Vector3.Forward * WeaponDescription.GetFor(CubeBlock).MissileSpawnForward;
            points[0] = CubeBlock.LocalAABB.Min + forwardAdjust;
            points[1] = CubeBlock.LocalAABB.Max + forwardAdjust;
            points[2] = CubeBlock.LocalAABB.Min + Vector3.Up * CubeBlock.GetCubeBlockDefinition().Size.Y * CubeBlock.CubeGrid.GridSize + forwardAdjust;

            MissileSpawnBox = BoundingBox.CreateFromPoints(points);
            if (m_weaponTarget.myTurret != null)
            {
                //myLogger.debugLog("original box: " + MissileSpawnBox, "GuidedMissileLauncher()");
                MissileSpawnBox.Inflate(CubeBlock.CubeGrid.GridSize * 2f);
            }

            //myLogger.debugLog("MissileSpawnBox: " + MissileSpawnBox, "GuidedMissileLauncher()");

            myInventory = ((MyEntity)CubeBlock).GetInventoryBase(0);

            Registrar.Add(weapon.FuncBlock, this);
            m_weaponTarget.GuidedLauncher = true;
        }
开发者ID:Souper07,项目名称:Autopilot,代码行数:28,代码来源:GuidedMissileLauncher.cs

示例2: FixSnapTransformationBase6

        protected void FixSnapTransformationBase6()
        {
            Debug.Assert(m_copiedGrids.Count != 0);
            if (m_copiedGrids.Count == 0)
                return;

            var pasteMatrix = GetPasteMatrix();
            var hitGrid = m_hitEntity as MyCubeGrid;

            if (hitGrid == null)
                return;
            
            // Fix rotation of the first pasted grid
            Matrix hitGridRotation = hitGrid.WorldMatrix.GetOrientation();
            Matrix firstRotation = m_previewGrids[0].WorldMatrix.GetOrientation();
            // PARODY
            hitGridRotation = Matrix.Normalize(hitGridRotation);
            // PARODY
            firstRotation = Matrix.Normalize(firstRotation);
            Matrix newFirstRotation = Matrix.AlignRotationToAxes(ref firstRotation, ref hitGridRotation);
            Matrix rotationDelta = Matrix.Invert(firstRotation) * newFirstRotation;

            // Fix transformations of all the pasted grids
            int gridIndex = 0;
            foreach (var grid in m_previewGrids)
            {
                Matrix rotation = grid.WorldMatrix.GetOrientation();
                rotation = rotation * rotationDelta;
                Matrix rotationInv = Matrix.Invert(rotation);

                Vector3D position = m_pastePosition;

                MatrixD newWorld = MatrixD.CreateWorld(position, rotation.Forward, rotation.Up);
                Debug.Assert(newWorld.GetOrientation().IsRotation());
                grid.PositionComp.SetWorldMatrix(newWorld);
            }


            bool smallOnLargeGrid = hitGrid.GridSizeEnum == MyCubeSize.Large && m_previewGrids[0].GridSizeEnum == MyCubeSize.Small;

            if (smallOnLargeGrid)
            {
                Vector3 pasteOffset = MyCubeBuilder.TransformLargeGridHitCoordToSmallGrid(m_pastePosition, hitGrid.PositionComp.WorldMatrixNormalizedInv, hitGrid.GridSize);
                m_pastePosition = hitGrid.GridIntegerToWorld(pasteOffset);
                if (MyFakes.ENABLE_VR_BUILDING) // Move pasted grid to aabb edge
                {
                    Vector3 normal = Vector3I.Round(Vector3.TransformNormal(m_hitNormal, hitGrid.PositionComp.WorldMatrixNormalizedInv));
                    Vector3 normalStepLocalInHitGrid = normal * (m_previewGrids[0].GridSize / hitGrid.GridSize);
                    Vector3 normalStepLocalInPreviewGrid = Vector3I.Round(Vector3D.TransformNormal(Vector3D.TransformNormal(normal, hitGrid.WorldMatrix),
                        m_previewGrids[0].PositionComp.WorldMatrixNormalizedInv)); 
                    var localAABB = m_previewGrids[0].PositionComp.LocalAABB;
                    localAABB.Min /= m_previewGrids[0].GridSize;
                    localAABB.Max /= m_previewGrids[0].GridSize;
                    Vector3 offsetOrigin = m_dragPointToPositionLocal / m_previewGrids[0].GridSize;
                    Vector3 offsetLocalInPreviewGrid = Vector3.Zero;
                    Vector3 offsetLocalInHitGrid = Vector3.Zero;
                    BoundingBox cubeBox = new BoundingBox(-Vector3.Half, Vector3.Half);
                    cubeBox.Inflate(-0.05f);
                    cubeBox.Translate(-offsetOrigin + offsetLocalInPreviewGrid - normalStepLocalInPreviewGrid);
                    while (localAABB.Contains(cubeBox) != ContainmentType.Disjoint)
                    {
                        offsetLocalInPreviewGrid -= normalStepLocalInPreviewGrid;
                        offsetLocalInHitGrid -= normalStepLocalInHitGrid;
                        cubeBox.Translate(-normalStepLocalInPreviewGrid);
                    }

                    m_pastePosition = hitGrid.GridIntegerToWorld(pasteOffset - offsetLocalInHitGrid);
                }
            }
            else
            {
                // Find a collision-free position for the first paste grid along the raycast normal
                Vector3I collisionTestStep = Vector3I.Round(Vector3.TransformNormal(m_hitNormal, hitGrid.PositionComp.WorldMatrixNormalizedInv));
                Vector3I pasteOffset = hitGrid.WorldToGridInteger(m_pastePosition);

                int i;
                for (i = 0; i < 100; ++i) // CH:TODO: Fix the step limit
                {
                    if (hitGrid.CanMergeCubes(m_previewGrids[0], pasteOffset))
                        break;
                    pasteOffset += collisionTestStep;
                }

                if (i == 0)
                {
                    for (i = 0; i < 100; ++i) // CH:TODO: Fix the step limit
                    {
                        pasteOffset -= collisionTestStep;
                        if (!hitGrid.CanMergeCubes(m_previewGrids[0], pasteOffset))
                            break;
                    }
                    pasteOffset += collisionTestStep;
                }

                if (i == 100)
                {
                    pasteOffset = hitGrid.WorldToGridInteger(m_pastePosition);
                }

                m_pastePosition = hitGrid.GridIntegerToWorld(pasteOffset);
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MyGridClipboard.cs

示例3: AddMountForShape

 private HkdBreakableShape AddMountForShape(HkdBreakableShape shape, Matrix transform, ref BoundingBox blockBB)
 {
     Vector4 min;
     Vector4 max;
     shape.GetShape().GetLocalAABB(0.01f, out min, out max);//.Transform(CubeGrid.PositionComp.WorldMatrix);
     var bb = new BoundingBox(new Vector3(min), new Vector3(max));
     bb = bb.Transform(transform);
     bb.Min /= CubeGrid.GridSize; //normalize for mount point
     bb.Max /= CubeGrid.GridSize;
     
     bb.Inflate(0.04f);//add tolerance (fracture shapes are smaller than block)
     bb.Min += blockBB.HalfExtents;
     bb.Max += blockBB.HalfExtents;
     
     if (blockBB.Contains(bb) == ContainmentType.Intersects)
     {
         bb.Inflate(-0.04f);
         foreach (var directionEnum in Base6Directions.EnumDirections)
         {
             int dirEnum = (int)directionEnum;
             Vector3 direction = Base6Directions.Directions[dirEnum];
             Vector3 absDir = Vector3.Abs(direction);
             var mp = new MyCubeBlockDefinition.MountPoint();
             mp.Start = bb.Min;
             mp.End = bb.Max;
             var start = mp.Start * absDir / (blockBB.HalfExtents * 2) - absDir * 0.04f;
             var end = mp.End * absDir / (blockBB.HalfExtents * 2) + absDir * 0.04f;
             bool add = false;
             bool one = false;
             if (start.Max() < 1 && end.Max() > 1 && direction.Max() > 0)
             {
                 add = true;
                 one = true;
             }
             else if (start.Min() < 0 && end.Max() > 0 && direction.Min() < 0)
             {
                 add = true;
             }
             if (!add)
             {
                 continue;
             }
             mp.Start -= mp.Start * absDir - absDir * 0.04f;
             mp.End -= mp.End * absDir + absDir * 0.04f;
             if (one)
             {
                 mp.Start += absDir * blockBB.HalfExtents * 2;
                 mp.End += absDir * blockBB.HalfExtents * 2;
             }
             mp.Start -= blockBB.HalfExtents - Vector3.One / 2;
             mp.End -= blockBB.HalfExtents - Vector3.One / 2;
             mp.Normal = new Vector3I(direction);
             MountPoints.Add(mp);
         }
     }
     return shape;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:57,代码来源:MyFracturedBlock.cs

示例4: ExtendThroughBox

    /// <summary>
    /// Utility function for creating a PlaneSurface through a Box.
    /// </summary>
    /// <param name="plane">Plane to extend.</param>
    /// <param name="box">Box to extend through.</param>
    /// <param name="fuzzyness">Box will be inflated by this amount.</param>
    /// <returns>A Plane surface through the box or null.</returns>
    internal static PlaneSurface ExtendThroughBox(Plane plane, BoundingBox box, double fuzzyness)
    {
      if (fuzzyness != 0.0) { box.Inflate(fuzzyness); }

      Point3d[] corners = box.GetCorners();
      int side = 0;
      bool valid = false;

      for (int i = 0; i < corners.Length; i++)
      {
        double d = plane.DistanceTo(corners[i]);
        if (d == 0.0) { continue; }

        if (d < 0.0)
        {
          if (side > 0) { valid = true; break; }
          side = -1;
        }
        else
        {
          if (side < 0) { valid = true; break; }
          side = +1;
        }
      }

      if (!valid) { return null; }

      Interval s, t;
      if (!plane.ExtendThroughBox(box, out s, out t)) { return null; }

      if (s.IsSingleton || t.IsSingleton)
        return null;

      return new PlaneSurface(plane, s, t);
    }
开发者ID:mennodeij,项目名称:rhinocommon,代码行数:42,代码来源:opennurbs_intersect.cs

示例5: ReadContentRange

        internal void ReadContentRange(ref MyVoxelDataRequest req)
        {
            if (Closed) return;

            float lodVoxelSize = (1 << req.Lod) * MyVoxelConstants.VOXEL_SIZE_IN_METRES;

            Vector3I min = req.minInLod;
            Vector3I max = req.maxInLod;

            ProfilerShort.Begin("Distance field computation");
            try
            {
                Vector3I v = min;
                Vector3 localPos = v * lodVoxelSize - m_translation;
                Vector3 localPosStart = localPos;

                BoundingBox request = new BoundingBox(localPos, localPos + (max - min) * lodVoxelSize);
                request.Inflate(lodVoxelSize);

                MyVoxelRequestFlags flags = 0;

                ContainmentType cont = ContainmentType.Intersects;

                bool intersects;

                if (!req.Flags.HasFlag(MyVoxelRequestFlags.DoNotCheck))
                {
                    BoundingSphere sphere = new BoundingSphere(
                    Vector3.Zero,
                    OuterRadius + lodVoxelSize);

                    sphere.Intersects(ref request, out intersects);
                    if (!intersects)
                    {
                        cont = ContainmentType.Disjoint;
                        goto end;
                    }

                    sphere.Radius = InnerRadius - lodVoxelSize;

                    ContainmentType ct;
                    sphere.Contains(ref request, out ct);
                    if (ct == ContainmentType.Contains)
                    {
                        cont = ct;
                        goto end;
                    }

                    cont = IntersectBoundingBoxInternal(ref request, lodVoxelSize);
                    if (cont != ContainmentType.Intersects)
                        goto end;
                }


                bool hit = false;

                // store request history
                EnqueueHistory(req);

                // Setup cache for current map;
                PrepareCache();

                var writeOffsetLoc = req.Offset - min;
                for (v.Z = min.Z; v.Z <= max.Z; ++v.Z)
                {
                    for (v.Y = min.Y; v.Y <= max.Y; ++v.Y)
                    {
                        v.X = min.X;
                        var write2 = v + writeOffsetLoc;
                        var write = req.Target.ComputeLinear(ref write2);
                        for (; v.X <= max.X; ++v.X)
                        {
                            float signedDist = SignedDistanceLocal(localPos, lodVoxelSize) / lodVoxelSize;

                            var fillRatio = MathHelper.Clamp(-signedDist, -1f, 1f) * 0.5f + 0.5f;
                            byte content = (byte)(fillRatio * MyVoxelConstants.VOXEL_CONTENT_FULL);

                            if (content != 0)
                            {
                                hit = true;
                            }
                            req.Target.Content(write, content);
                            write += req.Target.StepLinear;
                            localPos.X += lodVoxelSize;
                        }
                        localPos.Y += lodVoxelSize;
                        localPos.X = localPosStart.X;
                    }
                    localPos.Z += lodVoxelSize;
                    localPos.Y = localPosStart.Y;
                }

                if (!hit)
                {
                    PruningStats.Miss();
                }
                else
                {
                    PruningStats.Hit();
                }
//.........这里部分代码省略.........
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:101,代码来源:MyPlanetShapeProvider.cs

示例6: IntersectBoundingBox

        public ContainmentType IntersectBoundingBox(ref BoundingBox box, float lodLevel)
        {
            box.Inflate(1f);

            bool intersects;
            BoundingSphere sphere = new BoundingSphere(
                    Vector3.Zero,
                    OuterRadius + lodLevel);

            sphere.Intersects(ref box, out intersects);
            if (!intersects)
            {
                return ContainmentType.Disjoint;
            }

            sphere.Radius = InnerRadius - lodLevel;

            ContainmentType ct;
            sphere.Contains(ref box, out ct);
            if (ct == ContainmentType.Contains)
            {
                return ContainmentType.Contains;
            }

            return IntersectBoundingBoxInternal(ref box, lodLevel);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:26,代码来源:MyPlanetShapeProvider.cs

示例7: PrepareRulesForBoxInternal

        private void PrepareRulesForBoxInternal(ref BoundingBox request)
        {
            if (m_rangeBiomes == null) m_rangeBiomes = new List<PlanetMaterialRule>[256];

            BoundingBox box;
            request.Translate(-m_planetShape.Center());

            // Inflate so we don't miss any rules.
            request.Inflate(request.Extents.Length() * .1f);

            GetRuleBounds(ref request, out box);

            foreach (var bio in m_biomes.Values)
            {
                if (ReferenceEquals(m_rangeBiomes[bio.Value], bio.Rules) || m_rangeBiomes[bio.Value] == null || m_providerForRules != this)
                    m_rangeBiomes[bio.Value] = new List<PlanetMaterialRule>();

                bio.MateriaTree.OverlapAllBoundingBox(ref box, m_rangeBiomes[bio.Value], clear: true);
            }
            m_rangeClean = false;
            m_providerForRules = this;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:22,代码来源:MyPlanetMaterialProvider.cs

示例8: GuidedMissileLauncher

		public GuidedMissileLauncher(WeaponTargeting weapon)
		{
			m_weaponTarget = weapon;
			FuncBlock = CubeBlock as IMyFunctionalBlock;
			myLogger = new Logger("GuidedMissileLauncher", CubeBlock);

			var defn = CubeBlock.GetCubeBlockDefinition();

			Vector3[] points = new Vector3[3];
			points[0] = CubeBlock.LocalAABB.Min;
			points[1] = CubeBlock.LocalAABB.Max;
			points[2] = CubeBlock.LocalAABB.Min + Vector3.Up * CubeBlock.GetCubeBlockDefinition().Size.Y * CubeBlock.CubeGrid.GridSize;

			MissileSpawnBox = BoundingBox.CreateFromPoints(points);
			if (m_weaponTarget.myTurret != null)
			{
				myLogger.debugLog("original box: " + MissileSpawnBox, "GuidedMissileLauncher()");
				MissileSpawnBox.Inflate(CubeBlock.CubeGrid.GridSize * 2f);
			}

			myLogger.debugLog("MissileSpawnBox: " + MissileSpawnBox, "GuidedMissileLauncher()");

			myInventory = (CubeBlock as Interfaces.IMyInventoryOwner).GetInventory(0);

			m_weaponTarget.AllowedState = WeaponTargeting.State.GetOptions;
			Registrar.Add(weapon.FuncBlock, this);
		}
开发者ID:helppass,项目名称:Autopilot,代码行数:27,代码来源:GuidedMissileLauncher.cs

示例9: PrepareRulesForBoxInternal

        private void PrepareRulesForBoxInternal(ref BoundingBox request)
        {
            if (m_rangeBiomes == null) m_rangeBiomes = new List<PlanetMaterialRule>[256];

            BoundingBox box;
            request.Translate(-m_planetShape.Center());

            // Inflate so we don't miss any rules.
            request.Inflate(request.Extents.Length() * .1f);

            GetRuleBounds(ref request, out box);

            foreach (var bio in m_biomes.Values)
            {
                if (Object.ReferenceEquals(m_rangeBiomes[bio.Value], bio.Rules) || m_rangeBiomes[bio.Value] == null || m_providerForRules != this)
                    m_rangeBiomes[bio.Value] = new List<PlanetMaterialRule>();

                m_rangeBiomes[bio.Value].Clear();

                bio.MateriaTree.Query(delegate(int x)
                {
                    m_rangeBiomes[bio.Value].Add(bio.MateriaTree.GetUserData<PlanetMaterialRule>(x)); return true;
                }, ref box);
            }
            m_rangeClean = false;
            m_providerForRules = this;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:27,代码来源:MyPlanetMaterialProvider.cs


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