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


C# BoundingBoxD类代码示例

本文整理汇总了C#中BoundingBoxD的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD类的具体用法?C# BoundingBoxD怎么用?C# BoundingBoxD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MyEncounterId

 public MyEncounterId(BoundingBoxD box, int seed, int encounterId)
 {
     BoundingBox = box;
     Seed = seed;
     EncounterId = encounterId;
     PlacePosition = Vector3D.Zero;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyObjectBuilder_Encounters.cs

示例2: DebugDraw

        public override bool DebugDraw()
        {
            // Duplicit. Use MyFakes.DEBUG_DRAW_MODEL_DUMMIES;
            /*if (m_model != null)
            {
                foreach (var d in m_model.Dummies)
                {
                    VRageRender.MyRenderProxy.DebugDrawOBB(d.Value.Matrix * WorldMatrix, Color.Blue.ToVector3(), 1.0f, false, false);
                    VRageRender.MyRenderProxy.DebugDrawAxis(d.Value.Matrix * WorldMatrix, 1, false);
                }
            }*/

            if (MyDebugDrawSettings.DEBUG_DRAW_CUBE_BLOCK_AABBS)
            {
                Color color = Color.Red;
                Color green = Color.Green;

                var centerGrid = m_cubeBlock.BlockDefinition.Center;

                var min = (m_cubeBlock.Min * m_cubeBlock.CubeGrid.GridSize) - new Vector3(m_cubeBlock.CubeGrid.GridSize / 2.0f);
                var max = (m_cubeBlock.Max * m_cubeBlock.CubeGrid.GridSize) + new Vector3(m_cubeBlock.CubeGrid.GridSize / 2.0f);
                BoundingBoxD bbox = new BoundingBoxD(min, max);

                var worldMat = m_cubeBlock.CubeGrid.WorldMatrix;
                MySimpleObjectDraw.DrawTransparentBox(ref worldMat, ref bbox, ref color, MySimpleObjectRasterizer.Wireframe, 1, 0.01f);
            }

            return true;
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:29,代码来源:MyDebugRenderComponentCubeBlock.cs

示例3: DrawHighlight

        public void DrawHighlight()
        {
            var block = m_tool.GetTargetGrid().GetCubeBlock(m_tool.TargetCube);
            //Debug.Assert(block != null, "Call programmer");
            if (block == null) // This is just a workaround, so that the above assert does not crash the game on release
                return;

            Matrix blockWorldMatrixF;
            block.Orientation.GetMatrix(out blockWorldMatrixF);
            MatrixD blockWorldMatrix = blockWorldMatrixF;
            MatrixD gridWorld = m_tool.GetTargetGrid().Physics.GetWorldMatrix();
            blockWorldMatrix = blockWorldMatrix * Matrix.CreateTranslation(block.Position) * Matrix.CreateScale(m_tool.GetTargetGrid().GridSize) * gridWorld;

            /*Vector3 pos = Vector3.Transform(new Vector3(0.0f, 0.0f, 0.0f), blockRotation);
            MyRenderProxy.DebugDrawAxis(blockRotation, m_targetGrid.GridSize, false);
            MyRenderProxy.DebugDrawSphere(pos, 0.5f, new Vector3(1.0f, 0.0f, 0.0f), 1.0f, false);*/
            float highlightThickness = m_tool.GetTargetGrid().GridSizeEnum == MyCubeSize.Large ? 0.06f : 0.03f;

            Vector3 centerOffset = new Vector3(0.5f, 0.5f, 0.5f);
            TimeSpan time = MySession.Static.ElapsedPlayTime;
            Vector3 inflate = new Vector3(0.05f);
            BoundingBoxD bb = new BoundingBoxD(-block.BlockDefinition.Center - centerOffset - inflate, block.BlockDefinition.Size - block.BlockDefinition.Center - centerOffset + inflate);
            Color color = m_tool.HighlightColor;
			var lineMaterial = m_tool.HighlightMaterial;
            MySimpleObjectDraw.DrawTransparentBox(ref blockWorldMatrix, ref bb, ref color, MySimpleObjectRasterizer.Wireframe, 1, highlightThickness, null, lineMaterial, false);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MyRenderComponentEngineerTool.cs

示例4: RemoveEncounter

        public static bool RemoveEncounter(BoundingBoxD boundingVolume, int seed)
        {
            bool wasFound = false;
            for (int i = 0; i < 2; ++i)
            {
                MyEncounterId encounter = new MyEncounterId(boundingVolume, seed,i);
                if (true == m_savedEncounters.Contains(encounter))
                {
                    wasFound = false;
                    continue;
                }

                List<IMyEntity> entitiesToRemove = new List<IMyEntity>();

                foreach (var entity in m_entityToEncounterConversion)
                {
                    if (entity.Value.BoundingBox == encounter.BoundingBox && entity.Value.Seed == encounter.Seed && entity.Value.EncounterId == encounter.EncounterId)
                    {
                        entity.Key.Close();
                        entitiesToRemove.Add(entity.Key);
                        wasFound = true;
                    }
                }

                foreach (var entity in entitiesToRemove)
                {
                    m_entityToEncounterConversion.Remove(entity);
                }
            }
            return wasFound;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:31,代码来源:MyEncounterGenerator.cs

示例5: Spawn

        public static MyEntity Spawn(this MyPhysicalInventoryItem thisItem, MyFixedPoint amount, BoundingBoxD box, MyEntity owner = null)
        {
            if(amount < 0)
            {
                return null;
            }

            MatrixD spawnMatrix = MatrixD.Identity;
            spawnMatrix.Translation = box.Center;
            var entity = Spawn(thisItem, amount, spawnMatrix, owner);
            if (entity == null)
                return null;
            var size = entity.PositionComp.LocalVolume.Radius;
            var halfSize = box.Size / 2 - new Vector3(size);
            halfSize = Vector3.Max(halfSize, Vector3.Zero);
            box = new BoundingBoxD(box.Center - halfSize, box.Center + halfSize);
            var pos = MyUtils.GetRandomPosition(ref box);

            Vector3 forward = MyUtils.GetRandomVector3Normalized();
            Vector3 up = MyUtils.GetRandomVector3Normalized();
            while (forward == up)
                up = MyUtils.GetRandomVector3Normalized();

            Vector3 right = Vector3.Cross(forward, up);
            up = Vector3.Cross(right, forward);
            entity.WorldMatrix = MatrixD.CreateWorld(pos, forward, up);
            return entity;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyPhysicalInventoryItemExtensions.cs

示例6: GetClosestContainingPlanet

        public MyPlanet GetClosestContainingPlanet(Vector3D point)
        {
            m_voxels.Clear();
            BoundingBoxD b = new BoundingBoxD(point, point);
            MyGamePruningStructure.GetAllVoxelMapsInBox(ref b, m_voxels);

            double dist = double.PositiveInfinity;

            MyPlanet p = null;

            foreach (var v in m_voxels)
            {
                if (v is MyPlanet)
                {
                    var d = Vector3.Distance(v.WorldMatrix.Translation, point);
                    if (d < dist)
                    {
                        dist = d;
                        p = (MyPlanet)v;
                    }
                }
            }

            return p;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:25,代码来源:MyPlanetsDebugInputComponent.cs

示例7: Area

 public Area()
 {
     ProxyId = -1;
     ForestBox = BoundingBoxD.CreateInvalid();
     ItemIds = new Dictionary<long, HashSet<int>>();
     IsFull = false;
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MyFloraAreas.cs

示例8: PrepareVoxelTriangleTests

        public void PrepareVoxelTriangleTests(BoundingBoxD cellBoundingBox, List<MyCubeGrid> gridsToTestOutput)
        {
            ProfilerShort.Begin("PrepareVoxelTriangleTests");

            m_tmpEntityList.Clear();

            // Each triangle will be tested with grids up to one largest cube further away from them, so we have to reflect this in the bounding box.
            float largeCubeSize = MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large);
            cellBoundingBox.Inflate(largeCubeSize);

            // Furthermore, a triangle cannot lie in a cube under existing block, so we have to extend the bbox even further
            if (MyPerGameSettings.NavmeshPresumesDownwardGravity)
            {
                var min = cellBoundingBox.Min;
                min.Y -= largeCubeSize;
                cellBoundingBox.Min = min;
            }

            MyGamePruningStructure.GetAllEntitiesInBox(ref cellBoundingBox, m_tmpEntityList);
            foreach (var entity in m_tmpEntityList)
            {
                var grid = entity as MyCubeGrid;
                if (grid == null) continue;

                if (!MyGridPathfinding.GridCanHaveNavmesh(grid)) continue;

                gridsToTestOutput.Add(grid);
            }

            m_tmpEntityList.Clear();

            ProfilerShort.End();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:33,代码来源:MyNavmeshCoordinator.cs

示例9: Init

 public void Init(ref Vector3I pos, MyPlanet planet)
 {
     m_pos = pos;
     m_cellHashCode = pos.GetHashCode() + planet.PositionLeftBottomCorner.GetHashCode();
     m_planet = planet;
     SectorBox = new BoundingBoxD(m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS, m_planet.PositionLeftBottomCorner + pos * SECTOR_SIZE_METERS + SECTOR_SIZE_METERS);
     m_sectorCenter = SectorBox.Center;
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyPlanetEnvironmentSector.cs

示例10: MyElement

 public MyElement(uint id)
 {
     m_id = id;
     
     Flags = MyElementFlag.EF_AABB_DIRTY;
     m_aabb = new BoundingBoxD();        
     m_proxyData = PROXY_UNASSIGNED;
     m_shadowProxyData = PROXY_UNASSIGNED;
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyElement.cs

示例11: InitVoxelMap

        private void InitVoxelMap(Vector3D position, Vector3I size, string materialName, bool defineMemory)
        {
            IsValid = true;
            Size = size;
            _sizeMinusOne = new Vector3I(Size.X - 1, Size.Y - 1, Size.Z - 1);
            VoxelMaterial = SpaceEngineersCore.Resources.GetMaterialIndex(materialName);
            _positionLeftBottomCorner = position;
            _boundingContent = new BoundingBoxD(new Vector3I(Size.X, Size.Y, Size.Z), new Vector3I(0, 0, 0));

            // this is too big for the current SEToolbox code to cope with, and is probably a planet.
            if (!defineMemory)
                return;

            // If you need larged voxel maps, enlarge this constant.
            Debug.Assert(Size.X <= MyVoxelConstants.MAX_VOXEL_MAP_SIZE_IN_VOXELS);
            Debug.Assert(Size.Y <= MyVoxelConstants.MAX_VOXEL_MAP_SIZE_IN_VOXELS);
            Debug.Assert(Size.Z <= MyVoxelConstants.MAX_VOXEL_MAP_SIZE_IN_VOXELS);

            // Voxel map size must be multiple of a voxel data cell size.
            Debug.Assert((Size.X & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            Debug.Assert((Size.Y & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            Debug.Assert((Size.Z & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            _dataCellsCount.X = Size.X >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;
            _dataCellsCount.Y = Size.Y >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;
            _dataCellsCount.Z = Size.Z >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS;

            // Voxel map size must be multiple of a voxel data cell size.
            Debug.Assert((Size.X % MyVoxelConstants.VOXEL_RENDER_CELL_SIZE_IN_VOXELS) == 0);
            Debug.Assert((Size.Y % MyVoxelConstants.VOXEL_RENDER_CELL_SIZE_IN_VOXELS) == 0);
            Debug.Assert((Size.Z % MyVoxelConstants.VOXEL_RENDER_CELL_SIZE_IN_VOXELS) == 0);

            // Array of voxel cells in this voxel map.
            _voxelContentCells = new MyVoxelContentCell[_dataCellsCount.X][][];
            for (var x = 0; x < _voxelContentCells.Length; x++)
            {
                _voxelContentCells[x] = new MyVoxelContentCell[_dataCellsCount.Y][];
                for (var y = 0; y < _voxelContentCells[x].Length; y++)
                {
                    _voxelContentCells[x][y] = new MyVoxelContentCell[_dataCellsCount.Z];
                }
            }

            //  Set base material.
            _voxelMaterialCells = new MyVoxelMaterialCell[_dataCellsCount.X][][];
            for (var x = 0; x < _dataCellsCount.X; x++)
            {
                _voxelMaterialCells[x] = new MyVoxelMaterialCell[_dataCellsCount.Y][];
                for (var y = 0; y < _dataCellsCount.Y; y++)
                {
                    _voxelMaterialCells[x][y] = new MyVoxelMaterialCell[_dataCellsCount.Z];
                    for (var z = 0; z < _dataCellsCount.Z; z++)
                    {
                        _voxelMaterialCells[x][y][z] = new MyVoxelMaterialCell(VoxelMaterial, 0xFF);
                    }
                }
            }
        }
开发者ID:Stevolk,项目名称:SEToolbox,代码行数:57,代码来源:MyVoxelMap.cs

示例12: AccumulateCorrection

        public override void AccumulateCorrection(ref VRageMath.Vector3 correction, ref float weight)
        {
            Vector3D position = Parent.PositionAndOrientation.Translation;

            BoundingBoxD box = new BoundingBoxD(position - Vector3D.One, position + Vector3D.One);

            Vector3D currentMovement = Parent.ForwardVector * Parent.Speed;
            if (Parent.Speed > 0.01f)
                currentMovement.Normalize();

            // Don't do any correction if we're not moving
            if (currentMovement.LengthSquared() < 0.01)
            {
                return;
            }

            var entities = MyEntities.GetEntitiesInAABB(ref box);
            foreach (var entity in entities)
            {
                var environmentItems = entity as MyEnvironmentItems;
                if (environmentItems == null) continue;

                environmentItems.GetItemsInRadius(ref position, 6.0f, m_trees);

                foreach (var item in m_trees)
                {
                    Vector3D dir = item - position;
                    var dist = dir.Normalize();
                    dir = Vector3D.Reject(currentMovement, dir);

                    dir.Y = 0.0f;
                    if (dir.Z * dir.Z + dir.X * dir.X < 0.1)
                    {
                        Vector3D dirLocal = Vector3D.TransformNormal(dir, Parent.PositionAndOrientationInverted);
                        dir = position - item;
                        dir = Vector3D.Cross(Vector3D.Up, dir);
                        if (dirLocal.X < 0)
                            dir = -dir;
                    }

                    dir.Normalize();

                    correction += (6f - dist) * Weight * dir;
                    if (!correction.IsValid())
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                }
                m_trees.Clear();
            }

            weight += Weight;

            entities.Clear();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:55,代码来源:MyTreeAvoidance.cs

示例13: AreaData

            public AreaData(int id, BoundingBoxD box, Dictionary<long, HashSet<int>> items)
            {
                Id = id;
                ForestBox = box;
                ItemIds = DictionaryReader<long, HashSetReader<int>>.Empty;

                var dictionary = new Dictionary<long, HashSetReader<int>>();
                foreach (var pair in items)
                    dictionary[pair.Key] = new HashSetReader<int>(pair.Value);
                ItemIds = new DictionaryReader<long, HashSetReader<int>>(dictionary);
            }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:11,代码来源:MyFloraAreas.cs

示例14: GetShapeCenter

		public static bool GetShapeCenter(HkShape shape, uint shapeKey, MyCubeGrid grid, ref Vector3D shapeCenter)
		{
			bool shapeSet = true;

			switch (shape.ShapeType)
			{
				case HkShapeType.List:
					var listShape = (HkListShape)shape;
					shape = listShape.GetChildByIndex((int)shapeKey);
					break;
				case HkShapeType.Mopp:
					var moppShape = (HkMoppBvTreeShape)shape;
					shape = moppShape.ShapeCollection.GetShape(shapeKey, null);
					break;
				case HkShapeType.Box:
					var boxShape = (HkBoxShape)shape;
					shape = boxShape;
					break;
				case HkShapeType.ConvexTranslate:
					var convexTranslateShape = (HkConvexShape)shape;
					shape = convexTranslateShape;
					break;
				case HkShapeType.ConvexTransform:
					var convexTransformShape = (HkConvexTransformShape)shape;
					shape = convexTransformShape;
					break;
			/*	case HkShapeType.BvTree:
					var bvTreeShape = (HkBvTreeShape)shape;
					var iterator = bvTreeShape.Base.GetContainer();
					while (iterator.CurrentValue.IsContainer() && iterator.CurrentValue.ShapeType != HkShapeType.ConvexTranslate && iterator.CurrentValue.ShapeType != HkShapeType.ConvexTransform)
						iterator.Next();
					if (iterator.IsValid)
						shape = iterator.CurrentValue;
					else
						shapeSet = false;
					break;*/

				default:
					shapeSet = false;
					break;
			}

			if (shapeSet)
			{
				Vector4 min4, max4;
				shape.GetLocalAABB(0.05f, out min4, out max4);
				Vector3 worldMin = Vector3.Transform(new Vector3(min4), grid.PositionComp.WorldMatrix);
				Vector3 worldMax = Vector3.Transform(new Vector3(max4), grid.PositionComp.WorldMatrix);
				var worldAABB = new BoundingBoxD(worldMin, worldMax);

				shapeCenter = worldAABB.Center;
			}
			return shapeSet;
		}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:54,代码来源:MyDrillSensorRaycast.cs

示例15: Init

        public void Init(IMy2DClipmapManager parent, int x, int y, int lod, ref BoundingBox2D bounds)
        {
            m_manager = (MyPlanetEnvironmentComponent)parent;

            var bounds3D = new BoundingBoxD(new Vector3D(bounds.Min, 0), new Vector3D(bounds.Max, 0));
            Lod = lod;

            Face = m_manager.ActiveFace;

            var matrix = m_manager.ActiveClipmap.WorldMatrix;

            bounds3D = bounds3D.Transform(matrix);

            Coords = new Vector2I(x, y);

            Id = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod);

            m_manager.RegisterProxy(this);

            MyEnvironmentSectorParameters sectorParams;

            matrix.Translation = Vector3D.Zero;

            sectorParams.SurfaceBasisX = Vector3.Transform(new Vector3(bounds.Width / 2, 0, 0), matrix);
            sectorParams.SurfaceBasisY = Vector3.Transform(new Vector3(0, bounds.Height / 2, 0), matrix);
            sectorParams.Center = bounds3D.Center;

            if (lod > m_manager.MaxLod) return;

            if (!m_manager.TryGetSector(Id, out EnvironmentSector))
            {
                sectorParams.SectorId = Id;
                sectorParams.EntityId = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod);

                sectorParams.Bounds = m_manager.GetBoundingShape(ref sectorParams.Center, ref sectorParams.SurfaceBasisX, ref sectorParams.SurfaceBasisY); ;

                sectorParams.Environment = m_manager.EnvironmentDefinition;

                sectorParams.DataRange = new BoundingBox2I(Coords << lod, ((Coords + 1) << lod) - 1);

                sectorParams.Provider = m_manager.Providers[m_manager.ActiveFace];

                EnvironmentSector = m_manager.EnvironmentDefinition.CreateSector();
                EnvironmentSector.Init(m_manager, ref sectorParams);

                m_manager.Planet.AddChildEntity((MyEntity)EnvironmentSector);
            }

            m_manager.EnqueueOperation(this, lod);
            LodSet = lod;

            EnvironmentSector.OnLodCommit += sector_OnMyLodCommit;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:53,代码来源:MyPlanetEnvironmentClipmapProxy.cs


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