當前位置: 首頁>>代碼示例>>C#>>正文


C# BoundingBox類代碼示例

本文整理匯總了C#中BoundingBox的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox類的具體用法?C# BoundingBox怎麽用?C# BoundingBox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BoundingBox類屬於命名空間,在下文中一共展示了BoundingBox類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的BoundingBox類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。