当前位置: 首页>>代码示例>>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;未经允许,请勿转载。