• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BoundingBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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];
			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 = (CubeBlock as Interfaces.IMyInventoryOwner).GetInventory(0);

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


示例2: DynamicQuadTree

 public DynamicQuadTree(BoundingBox bounds)
 {
     _boundaries = bounds;
     _isLeaf = true;
     _bucket = new List<IWorldEntity>();
     _numEntities = 0;
 }
开发者ID:sacel,项目名称:Encore,代码行数:7,代码来源:DynamicQuadTree.cs


示例3: MyModelInstanceData

 public MyModelInstanceData(MyStringHash subtypeId, MyInstanceFlagsEnum flags, float maxViewDistance, BoundingBox modelBox)
 {
     SubtypeId = subtypeId;
     Flags = flags;
     MaxViewDistance = maxViewDistance;
     ModelBox = modelBox;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:7,代码来源:MyEnvironmentSector.cs


示例4: Viewport

 public Viewport()
 {
     _extent = new BoundingBox(0, 0, 0, 0);
     _windowExtent = new Quad();
     RenderResolutionMultiplier = 1;
     _center.PropertyChanged += (sender, args) => _modified = true; 
 }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:7,代码来源:Viewport.cs


示例5: OptimizeChilds

        //  This method will look if node has all its childs null, and if yes, destroy childs array (saving memory + making traversal faster, because we don't need to traverse whole array)
        public void OptimizeChilds()
        {
            // Current bounding box is real bounding box (calculated as bounding box of children and triangles)
            m_boundingBox = m_realBoundingBox;

            for (int i = 0; i < m_childs.Count; i++)
            {
                if (m_childs[i] != null)
                {
                    m_childs[i].OptimizeChilds();
                }
            }

            //  Remove all childs that are null, thus empty for us
            while (m_childs.Remove(null) == true)
            {
            }

            // When has only one child
            while (m_childs != null && m_childs.Count == 1)
            {
                // Add child triangles to self
                foreach (var t in m_childs[0].m_triangleIndices)
                {
                    m_triangleIndices.Add(t);
                }

                // Replace current child with children of current child
                m_childs = m_childs[0].m_childs;
            }

            //  If all childs are empty, we set this list to null so we save few value
            if (m_childs != null && m_childs.Count == 0) m_childs = null;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:35,代码来源:MyModelOctreeNode.cs


示例6: Prepare

        public override bool Prepare( Vector3I[] marks ) {
            if( !base.Prepare( marks ) ) return false;

            // center of the torus
            center = marks[0];

            Vector3I radiusVector = (marks[1] - center).Abs();

            // tube radius is figured out from Z component of the mark vector
            tubeR = radiusVector.Z;

            // torus radius is figured out from length of vector's X-Y components
            bigR = Math.Sqrt( radiusVector.X * radiusVector.X +
                              radiusVector.Y * radiusVector.Y + .5 );

            // tube + torus radius, rounded up. This will be the maximum extend of the torus.
            int combinedRadius = (int)Math.Ceiling( bigR + tubeR );

            // vector from center of torus to the furthest-away point of the bounding box
            Vector3I combinedRadiusVector = new Vector3I( combinedRadius, combinedRadius, tubeR + 1 );

            // adjusted bounding box
            Bounds = new BoundingBox( center - combinedRadiusVector, center + combinedRadiusVector );

            BlocksTotalEstimate = (int)(2 * Math.PI * Math.PI * bigR * (tubeR * tubeR + Bias));

            coordEnumerator = BlockEnumerator().GetEnumerator();
            return true;
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:29,代码来源:TorusDrawOperation.cs


示例7: TestVarious

 public void TestVarious()
 {
     BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
     Assert.AreEqual(20, b1.Left);
     Assert.AreEqual(20, b1.Min.X);
     Assert.AreEqual(40, b1.Right);
     Assert.AreEqual(40, b1.Max.X);
     Assert.AreEqual(30, b1.Bottom);
     Assert.AreEqual(30, b1.Min.Y);
     Assert.AreEqual(55, b1.Top);
     Assert.AreEqual(55, b1.Max.Y);
     Assert.AreEqual(20, b1.Width);
     Assert.AreEqual(25, b1.Height);
     Assert.AreNotSame(b1, b1.Clone());
     Assert.IsTrue(b1.Contains(new Point(30, 40)));
     Assert.IsTrue(b1.Contains(new Point(20, 40)));
     Assert.IsFalse(b1.Contains(new Point(10, 10)));
     Assert.IsFalse(b1.Contains(new Point(50, 60)));
     Assert.IsFalse(b1.Contains(new Point(30, 60)));
     Assert.IsFalse(b1.Contains(new Point(50, 40)));
     Assert.IsFalse(b1.Contains(new Point(30, 15)));
     Assert.IsTrue(b1.Equals(new BoundingBox(20, 30, 40, 55)));
     Assert.AreEqual(new Point(30, 42.5), b1.GetCentroid());
     Assert.AreEqual(1, b1.LongestAxis);
     Assert.AreEqual(new BoundingBox(19, 29, 41, 56), b1.Grow(1));
     Assert.IsFalse(b1.Equals(null));
     Assert.IsFalse(b1.Equals(new Polygon()));
     Assert.AreEqual("20,30 40,55", b1.ToString());
     Assert.AreEqual(b1, new BoundingBox(40, 55, 20, 30));
     Assert.AreEqual(Math.Sqrt(200), b1.Distance(new BoundingBox(50, 65, 60, 75)));
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:31,代码来源:BoundingBoxTests.cs


示例8: BuildVolumeHeuristic

        public unsafe void BuildVolumeHeuristic(int[] leafIds, BoundingBox[] leafBounds, int start = 0, int length = -1)
        {
            if (leafIds.Length != leafBounds.Length)
                throw new ArgumentException("leafIds and leafBounds lengths must be equal.");
            if (start + length > leafIds.Length)
                throw new ArgumentException("Start + length must be smaller than the leaves array length.");
            if (start < 0)
                throw new ArgumentException("Start must be nonnegative.");
            if (length == 0)
                throw new ArgumentException("Length must be positive.");
            if (length < 0)
                length = leafIds.Length;
            if (nodes[0].ChildCount != 0)
                throw new InvalidOperationException("Cannot build a tree that already contains nodes.");
            //The tree is built with an empty node at the root to make insertion work more easily.
            //As long as that is the case (and as long as this is not a constructor),
            //we must clear it out.
            nodeCount = 0;

            //Guarantee that no resizes will occur during the build.
            if (LeafCapacity < leafBounds.Length)
            {
                LeafCapacity = leafBounds.Length;
            }
            var preallocatedNodeCount = leafBounds.Length * 2 - 1;
            if (NodeCapacity < preallocatedNodeCount)
            {
                NodeCapacity = preallocatedNodeCount;
            }

            int nodeIndex;
            BoundingBox boundingBox;
            VolumeHeuristicAddNode(-1, -1, leafIds, leafBounds, start, length, out boundingBox, out nodeIndex);
        }
开发者ID:RossNordby,项目名称:scratchpad,代码行数:34,代码来源:Tree_VHBuilder.cs


示例9: Prepare

        public override bool Prepare(Vector3I[] marks) {
            a = marks[0];
            b = marks[1];
            c = marks[2];

            if (a == b || b == c || c == a) {
                if (a != c) b = c;
                isLine = true;
            }

            Bounds = new BoundingBox(
                Math.Min(Math.Min(a.X, b.X), c.X),
                Math.Min(Math.Min(a.Y, b.Y), c.Y),
                Math.Min(Math.Min(a.Z, b.Z), c.Z),
                Math.Max(Math.Max(a.X, b.X), c.X),
                Math.Max(Math.Max(a.Y, b.Y), c.Y),
                Math.Max(Math.Max(a.Z, b.Z), c.Z)
                );

            Coords = Bounds.MinVertex;

            if (!base.Prepare(marks)) return false;

            normal = (b - a).Cross(c - a);
            normalF = normal.Normalize();
            BlocksTotalEstimate = GetBlockTotalEstimate();

            s1 = normal.Cross(a - b).Normalize();
            s2 = normal.Cross(b - c).Normalize();
            s3 = normal.Cross(c - a).Normalize();

            return true;
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:33,代码来源:TriangleDrawOperation.cs


示例10: QuadTree

        public QuadTree(BoundingBox bounds, int depthThreshold = DefaultDepthThreshold)
            : base(bounds)
        {
            Contract.Requires(depthThreshold > 0);

            Partition(depthThreshold, 0);
        }
开发者ID:chosenmangos,项目名称:Encore,代码行数:7,代码来源:QuadTree.cs


示例11: Draw

		public static void Draw(CALayer target, IViewport viewport, IStyle style, IFeature feature)
		{
			const string styleKey = "laag";

			if(feature[styleKey] == null) feature[styleKey] = ToiOSBitmap(feature.Geometry);

			var bitmap = (UIImage)feature [styleKey];

			var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
			dest = new BoundingBox(
				dest.MinX,
				dest.MinY,
				dest.MaxX,
				dest.MaxY);

			var destination = RoundToPixel(dest);

			var tile = new CALayer
			{
				Frame = destination,
				Contents = bitmap.CGImage,
			};
			
			target.AddSublayer(tile);
		}
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:25,代码来源:RasterRenderer.cs


示例12: QueryData

        private static IEnumerable<GeoJSON> QueryData(BoundingBox bbox, ICanQueryLayer layer)
        {
            if (layer == null)
                throw new ArgumentNullException("layer");

            // Query for data
            FeatureDataSet ds = new FeatureDataSet();
            layer.ExecuteIntersectionQuery(bbox, ds);
            IEnumerable<GeoJSON> data = GeoJSONHelper.GetData(ds);

            // Reproject geometries if needed
            IMathTransform transform = null;
            if (layer is VectorLayer)
            {
                ICoordinateTransformation transformation = (layer as VectorLayer).CoordinateTransformation;
                transform = transformation == null ? null : transformation.MathTransform;
            }
            if (transform != null)
            {
                GeometryFactory gf = new GeometryFactory();
                data = data.Select(d =>
                    {
                        Geometry converted = GeometryTransform.TransformGeometry(d.Geometry, transform, gf);
                        d.SetGeometry(converted);
                        return d;
                    });
            }
            return data;
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:29,代码来源:StdJsonMapHandler.cs


示例13: RenderObjectUnity

        public RenderObjectUnity(AnimatorEditor editor, HashSet<string> meshNames)
        {
            HighlightSubmesh = new HashSet<int>();
            highlightMaterial = new SlimDX.Direct3D9.Material();
            highlightMaterial.Ambient = new Color4(1, 1, 1, 1);
            highlightMaterial.Diffuse = new Color4(1, 0, 1, 0);

            this.device = Gui.Renderer.Device;
            this.tweeningVertDec = new VertexDeclaration(this.device, TweeningWithoutNormalsVertexBufferFormat.ThreeStreams);

            Textures = new Texture[editor.Textures.Count];
            Materials = new SlimDX.Direct3D9.Material[editor.Materials.Count];

            rootFrame = CreateHierarchy(editor, meshNames, device, out meshFrames);

            AnimationController = new AnimationController(numFrames, 30, 30, 1);
            Frame.RegisterNamedMatrices(rootFrame, AnimationController);

            if (meshFrames.Count > 0)
            {
                Bounds = meshFrames[0].Bounds;
                for (int i = 1; i < meshFrames.Count; i++)
                {
                    Bounds = BoundingBox.Merge(Bounds, meshFrames[i].Bounds);
                }
            }
            else
            {
                Bounds = new BoundingBox();
            }
        }
开发者ID:hejob,项目名称:SB3Utility,代码行数:31,代码来源:RenderObjectUnity.cs


示例14: FindContent

		public void FindContent(Bitmap image, Bitmap foregroundImage, Tree currentNode, List<Tree> foundContent)
		{
			Utils.RectData[] found = ConnectedComponents.TwoPass(ccLabelingBitmap, foregroundImage, currentNode, Utils.BACKGROUND);

			foreach (Utils.RectData rect in found)
			{
				if(rect != null){
					int hash = 17;
					for (int row = rect.Top; row <= rect.Bottom; row++)
					{
						for (int col = rect.Left; col <= rect.Right; col++)
						{
							hash = 31 * hash + image[row, col];
						}
					}

					BoundingBox bb = new BoundingBox(rect.Left, rect.Top, (rect.Right - rect.Left) + 1, (rect.Bottom - rect.Top) + 1);

					Dictionary<string,object> tags = new Dictionary<string, object>();
					tags.Add("type", "content");
					tags.Add("pixel_hash", hash);

					Tree node = Tree.FromBoundingBox(bb, tags);

					foundContent.Add(node);
				}
			}
		}
开发者ID:nunb,项目名称:interpretation,代码行数:28,代码来源:ContentFinder.cs


示例15: Intersect

        internal void Intersect(ref BoundingBox box, List<Actor> result)
        {
            if (Box.Intersects(ref box))
            {
                if (Children != null)
                {
                    Children[LEFT_TOP_FRONT].Intersect(ref box, result);
                    Children[RIGHT_TOP_FRONT].Intersect(ref box, result);
                    Children[LEFT_TOP_BACK].Intersect(ref box, result);
                    Children[RIGHT_TOP_BACK].Intersect(ref box, result);
                    Children[LEFT_BOTTOM_FRONT].Intersect(ref box, result);
                    Children[RIGHT_BOTTOM_FRONT].Intersect(ref box, result);
                    Children[LEFT_BOTTOM_BACK].Intersect(ref box, result);
                    Children[RIGHT_BOTTOM_BACK].Intersect(ref box, result);
                }

                if (Objects.Count > 0)
                {
                    for (var i = 0; i < Objects.Count; ++i)
                    {
                        if (Objects[i].Box.Intersects(ref box))
                        {
                            ActorPool.Verify(Objects[i].Actor);
                            result.Add(Objects[i].Actor);
                        }
                    }
                }
            }
        }
开发者ID:Ramzawulf,项目名称:unityassets,代码行数:29,代码来源:Node.cs


示例16: UpdateLocalVolume

        private void UpdateLocalVolume()
        {
            float maxRadius = Math.Max(Radius1, Radius2);
            this.LocalVolume = new BoundingSphere(Vector3.Zero, Math.Max(maxRadius, Length / 2));

            this.m_localBoundingBox = new BoundingBox(new Vector3(-maxRadius, -Length / 2, -maxRadius), new Vector3(maxRadius, Length / 2, maxRadius));
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:MyVoxelHandCylinder.cs


示例17: AdjustVertices

        public void AdjustVertices()
        {
            Matrix camWorld = Matrix.Invert(GraphicOptions.CurrentCamera.View);
            Vector3 right = camWorld.Right;
            Vector3 down = camWorld.Down;
            right.Normalize(); down.Normalize();
            right = right * width;
            down = down * height;
            Vector3 tl = position - right / 2;
            Vector3 tr = position + right / 2;
            Vector3 bl = tl + down;
            Vector3 br = tr + down;

            vertices.Clear();
            Vector3 normal = Vector3.Cross(down, right);
            vertices.Add(new VertexPositionNormalTexture(bl, normal, Vector2.UnitY));
            vertices.Add(new VertexPositionNormalTexture(tl, normal, Vector2.Zero));
            vertices.Add(new VertexPositionNormalTexture(tr, normal, Vector2.UnitX));
            vertices.Add(new VertexPositionNormalTexture(br, normal, Vector2.One));
            vertices.Add(new VertexPositionNormalTexture(bl, normal, Vector2.UnitY));
            vertices.Add(new VertexPositionNormalTexture(tr, normal, Vector2.UnitX));

            boundingBox = new BoundingBox(tl, br);
            Ready();
        }
开发者ID:summer-of-software,项目名称:vtank,代码行数:25,代码来源:TextObject.cs


示例18: Intersect

 public List<Actor> Intersect(BoundingBox box)
 {
     UpdateDirty();
     var result = new List<Actor>();
     Root.Intersect(ref box, result);
     return result;
 }
开发者ID:Ramzawulf,项目名称:unityassets,代码行数:7,代码来源:OCTree.cs


示例19: generateSplitBox

        protected override void generateSplitBox()
        {
            if (splitDepth == 0)
            {
                // special case for splitdepth 0

                Vector3 boxCenter = aabb.Minimum + aabb.Maximum;
                boxCenter *= 0.5f;

                float halfx = boxCenter.X - aabb.Minimum.X;
                float halfy = boxCenter.Y - aabb.Minimum.Y;
                float halfz = boxCenter.Z - aabb.Minimum.Z;

                float maxHalf = Math.Max(halfx, Math.Max(halfy, halfz));

                // adjust bounding box to not be flat
                aabb = new BoundingBox(boxCenter - new Vector3(maxHalf * 2f), boxCenter + new Vector3(maxHalf * 2f));

                Vector3 newMin = boxCenter - new Vector3(maxHalf * 2f * (float)splitFactor);
                Vector3 newMax = boxCenter + new Vector3(maxHalf * 2f * (float)splitFactor);

                splitBox = new BoundingBox(newMin, newMax);
            }
            else
            {
                base.generateSplitBox();
            }
        }
开发者ID:ukitake,项目名称:Stratum,代码行数:28,代码来源:HemisphereTerrainNode.cs


示例20: FetchTiles

        public IEnumerable<IFeature> FetchTiles(BoundingBox boundingBox, double resolution)
        {
            var extent = new Extent(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Max.X, boundingBox.Max.Y);
            var levelId = BruTile.Utilities.GetNearestLevel(_source.Schema.Resolutions, resolution);
            var infos = _source.Schema.GetTileInfos(extent, levelId).ToList();

            ICollection<WaitHandle> waitHandles = new List<WaitHandle>();
                        
            foreach (TileInfo info in infos)    
            {
                if (_bitmaps.Find(info.Index) != null) continue;
                if (_queue.Contains(info.Index)) continue;
                var waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                _queue.Add(info.Index);
                ThreadPool.QueueUserWorkItem(GetTileOnThread, new object[] { _source, info, _bitmaps, waitHandle });
            }

            WaitHandle.WaitAll(waitHandles.ToArray());
            
            IFeatures features = new Features();
            foreach (TileInfo info in infos)
            {
                byte[] bitmap = _bitmaps.Find(info.Index);
                if (bitmap == null) continue;
                IRaster raster = new Raster(new MemoryStream(bitmap), new BoundingBox(info.Extent.MinX, info.Extent.MinY, info.Extent.MaxX, info.Extent.MaxY));
                IFeature feature = features.New();
                feature.Geometry = raster;
                features.Add(feature);
            }
            return features;
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:32,代码来源:TileProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BoundingBoxD类代码示例发布时间:2022-05-24
下一篇:
C# BoundStatement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap