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

C# BEPUutilities.BoundingBox类代码示例

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

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



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

示例1: GetOverlaps

		public void GetOverlaps( Vector3 gridPosition, BoundingBox boundingBox, ref QuickList<Int3> overlaps )
		{
			Vector3.Subtract( ref boundingBox.Min, ref gridPosition, out boundingBox.Min );
			Vector3.Subtract( ref boundingBox.Max, ref gridPosition, out boundingBox.Max );
			var inverseWidth = 1f / CellWidth;
			var min = new Int3
			{
				X = Math.Max( 0, (uint)( boundingBox.Min.X * inverseWidth ) ),
				Y = Math.Max( 0, (uint)( boundingBox.Min.Y * inverseWidth ) ),
				Z = Math.Max( 0, (uint)( boundingBox.Min.Z * inverseWidth ) )
			};
			var max = new Int3
			{
				X = Math.Min( VoxelSector.ZVOXELBLOCSIZE_X - 1, (uint)( boundingBox.Max.X * inverseWidth ) ),
				Y = Math.Min( VoxelSector.ZVOXELBLOCSIZE_Y - 1, (uint)( boundingBox.Max.Y * inverseWidth ) ),
				Z = Math.Min( VoxelSector.ZVOXELBLOCSIZE_Z - 1, (uint)( boundingBox.Max.Z * inverseWidth ) )
			};

			for( uint i = min.X; i <= max.X; ++i )
			{
				for( uint j = min.Y; j <= max.Y; ++j )
				{
					for( uint k = min.Z; k <= max.Z; ++k )
					{
						uint offset = i * VoxelSector.ZVOXELBLOCSIZE_Y + j + k * VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y;
						if( Cells[offset] != VoxelShape.Empty )
						{
							overlaps.Add( new Int3 { X = i, Y = j, Z = k } );
						}
					}
				}
			}
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:33,代码来源:BEPU.VoxelBlob.cs


示例2: HassSolidEntity

 public bool HassSolidEntity(Location min, Location max)
 {
     // TODO: Better alg!
     BoundingBox bb = new BoundingBox(min.ToBVector(), max.ToBVector());
     List<BroadPhaseEntry> entries = new List<BroadPhaseEntry>();
     PhysicsWorld.BroadPhase.QueryAccelerator.GetEntries(bb, entries);
     if (entries.Count == 0)
     {
         return false;
     }
     Location center = (max + min) * 0.5;
     Location rel = max - min;
     BoxShape box = new BoxShape((double)rel.X, (double)rel.Y, (double)rel.Z);
     RigidTransform start = new RigidTransform(center.ToBVector(), Quaternion.Identity);
     Vector3 sweep = new Vector3(0, 0, 0.01f);
     RayHit rh;
     foreach (BroadPhaseEntry entry in entries)
     {
         if (entry is EntityCollidable && Collision.ShouldCollide(entry) &&
             entry.CollisionRules.Group != CollisionUtil.Player &&
             entry.ConvexCast(box, ref start, ref sweep, out rh))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:27,代码来源:RegionPhysics.cs


示例3: GetBoundingBox

		public void GetBoundingBox( ref Vector3 position, out BoundingBox boundingBox )
		{
			var size = new Vector3( CellWidth * VoxelSector.ZVOXELBLOCSIZE_X
								, CellWidth * VoxelSector.ZVOXELBLOCSIZE_Y
								, CellWidth * VoxelSector.ZVOXELBLOCSIZE_Z );
			boundingBox.Min = position;
			Vector3.Add( ref size, ref position, out boundingBox.Max );
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:8,代码来源:BEPU.VoxelBlob.cs


示例4: GetBoundingBox

 /// <summary>
 /// Gets the bounding box of an element in the data.
 /// </summary>
 /// <param name="triangleIndex">Index of the triangle in the data.</param>
 /// <param name="boundingBox">Bounding box of the triangle.</param>
 public void GetBoundingBox(int triangleIndex, out BoundingBox boundingBox)
 {
     Vector3 v1, v2, v3;
     GetTriangle(triangleIndex, out v1, out v2, out v3);
     Vector3.Min(ref v1, ref v2, out boundingBox.Min);
     Vector3.Min(ref boundingBox.Min, ref v3, out boundingBox.Min);
     Vector3.Max(ref v1, ref v2, out boundingBox.Max);
     Vector3.Max(ref boundingBox.Max, ref v3, out boundingBox.Max);
 }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:14,代码来源:MeshBoundingBoxTreeData.cs


示例5: Intersects

        /// <summary>
        /// Determines if a bounding box intersects another bounding box.
        /// </summary>
        /// <param name="boundingBox">Bounding box to test against.</param>
        /// <returns>Whether the bounding boxes intersected.</returns>
        public bool Intersects(BoundingBox boundingBox)
        {
            if (boundingBox.Min.X > Max.X || boundingBox.Min.Y > Max.Y || boundingBox.Min.Z > Max.Z)
                return false;
            if (Min.X > boundingBox.Max.X || Min.Y > boundingBox.Max.Y || Min.Z > boundingBox.Max.Z)
                return false;
            return true;

        }
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:14,代码来源:BoundingBox.cs


示例6: MobileChunkCollidable

 public MobileChunkCollidable(MobileChunkShape shape)
 {
     ChunkShape = shape;
     base.Shape = ChunkShape;
     Vector3 max = new Vector3(shape.ChunkSize.X, shape.ChunkSize.Y, shape.ChunkSize.Z);
     boundingBox = new BoundingBox(-max, max);
     Events = new ContactEventManager<EntityCollidable>();
     LocalPosition = -shape.Center;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:9,代码来源:MobileChunkCollidable.cs


示例7: FullChunkObject

 public FullChunkObject(Vector3 pos, BlockInternal[] blocks)
 {
     ChunkShape = new FullChunkShape(blocks);
     base.Shape = ChunkShape;
     Position = pos;
     boundingBox = new BoundingBox(Position, Position + new Vector3(30, 30, 30));
     Events = new ContactEventManager<FullChunkObject>(this);
     Material.Bounciness = 0.75f;
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:9,代码来源:FullChunkObject.cs


示例8: GetOverlaps

 /// <summary>
 /// Gets the triangles whose bounding boxes are overlapped by the query.
 /// </summary>
 /// <param name="boundingBox">Shape to query against the tree.</param>
 /// <param name="outputOverlappedElements">Indices of triangles in the index buffer with bounding boxes which are overlapped by the query.</param>
 /// <returns>Whether or not any elements were overlapped.</returns>
 public bool GetOverlaps(BoundingBox boundingBox, IList<int> outputOverlappedElements)
 {
     if (root != null)
     {
         bool intersects;
         root.BoundingBox.Intersects(ref boundingBox, out intersects);
         if (intersects)
             root.GetOverlaps(ref boundingBox, outputOverlappedElements);
     }
     return outputOverlappedElements.Count > 0;
 }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:17,代码来源:MeshBoundingBoxTree.cs


示例9: GetBoundingBox

 /// <summary>
 /// Gets the bounding box of the shape given a transform.
 /// </summary>
 /// <param name="shapeTransform">Transform to use.</param>
 /// <param name="boundingBox">Bounding box of the transformed shape.</param>
 public override void GetBoundingBox(ref RigidTransform shapeTransform, out BoundingBox boundingBox)
 {
     #if !WINDOWS
     boundingBox = new BoundingBox();
     #endif
     boundingBox.Min.X = shapeTransform.Position.X - collisionMargin;
     boundingBox.Min.Y = shapeTransform.Position.Y - collisionMargin;
     boundingBox.Min.Z = shapeTransform.Position.Z - collisionMargin;
     boundingBox.Max.X = shapeTransform.Position.X + collisionMargin;
     boundingBox.Max.Y = shapeTransform.Position.Y + collisionMargin;
     boundingBox.Max.Z = shapeTransform.Position.Z + collisionMargin;
 }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:17,代码来源:SphereShape.cs


示例10: LotsOfBoxesTestDemo

        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public LotsOfBoxesTestDemo(DemosGame game)
            : base(game)
        {
            var ground = new Box(new Vector3(0, -.5f, 0), 200, 1, 200);
            Space.Add(ground);



            var spawnVolume = new BoundingBox
                {
                    Min = new Vector3(-25, 2, -25),
                    Max = new Vector3(25, 102, 25)
                };

            var span = spawnVolume.Max - spawnVolume.Min;

            NarrowPhaseHelper.Factories.BoxBox.EnsureCount(30000);

            var random = new Random(5);
            for (int i = 0; i < 5000; ++i)
            {
                Vector3 position;
                position.X = spawnVolume.Min.X + (float)random.NextDouble() * span.X;
                position.Y = spawnVolume.Min.Y + (float)random.NextDouble() * span.Y;
                position.Z = spawnVolume.Min.Z + (float)random.NextDouble() * span.Z;

                var entity = new Box(position, 2, 2, 2, 10);
                Space.Add(entity);
            }

            for (int i = 0; i < 100; ++i)
            {
                Space.Update();
            }

            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
            
            var start = Stopwatch.GetTimestamp();
            for (int i = 0; i < 200; ++i)
            {
                Space.Update();
            }
            var end = Stopwatch.GetTimestamp();
            var time = (end - start) / (double)Stopwatch.Frequency;

            Console.WriteLine("Time: {0}", time);
 
            game.Camera.Position = new Vector3(-10, 10, 10);
            game.Camera.Yaw((float)Math.PI / -4f);
            game.Camera.Pitch((float)Math.PI / 9f);
        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:55,代码来源:LotsOfBoxesTestDemo.cs


示例11: GetBoundingBox

        /// <summary>
        /// Gets the bounding box of the shape given a transform.
        /// </summary>
        /// <param name="shapeTransform">Transform to use.</param>
        /// <param name="boundingBox">Bounding box of the transformed shape.</param>
        public override void GetBoundingBox(ref RigidTransform shapeTransform, out BoundingBox boundingBox)
        {
            #if !WINDOWS
            boundingBox = new BoundingBox();
            #endif
            Matrix3x3 o;
            Matrix3x3.CreateFromQuaternion(ref shapeTransform.Orientation, out o);
            //Sample the local directions from the orientation matrix, implicitly transposed.

            Vector3 right;
            var direction = new Vector3(o.M11, o.M21, o.M31);
            GetLocalExtremePointWithoutMargin(ref direction, out right);

            Vector3 left;
            direction = new Vector3(-o.M11, -o.M21, -o.M31);
            GetLocalExtremePointWithoutMargin(ref direction, out left);

            Vector3 up;
            direction = new Vector3(o.M12, o.M22, o.M32);
            GetLocalExtremePointWithoutMargin(ref direction, out up);

            Vector3 down;
            direction = new Vector3(-o.M12, -o.M22, -o.M32);
            GetLocalExtremePointWithoutMargin(ref direction, out down);

            Vector3 backward;
            direction = new Vector3(o.M13, o.M23, o.M33);
            GetLocalExtremePointWithoutMargin(ref direction, out backward);

            Vector3 forward;
            direction = new Vector3(-o.M13, -o.M23, -o.M33);
            GetLocalExtremePointWithoutMargin(ref direction, out forward);

            //Rather than transforming each axis independently (and doing three times as many operations as required), just get the 6 required values directly.
            Vector3 positive, negative;
            TransformLocalExtremePoints(ref right, ref up, ref backward, ref o, out positive);
            TransformLocalExtremePoints(ref left, ref down, ref forward, ref o, out negative);

            //The positive and negative vectors represent the X, Y and Z coordinates of the extreme points in world space along the world space axes.
            boundingBox.Max.X = shapeTransform.Position.X + positive.X + collisionMargin;
            boundingBox.Max.Y = shapeTransform.Position.Y + positive.Y + collisionMargin;
            boundingBox.Max.Z = shapeTransform.Position.Z + positive.Z + collisionMargin;

            boundingBox.Min.X = shapeTransform.Position.X + negative.X - collisionMargin;
            boundingBox.Min.Y = shapeTransform.Position.Y + negative.Y - collisionMargin;
            boundingBox.Min.Z = shapeTransform.Position.Z + negative.Z - collisionMargin;
        }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:52,代码来源:ConvexShape.cs


示例12: DrawBoundingBox

		static void DrawBoundingBox( Display render, BoundingBox bb )
		{
			///Box box = e as Box;
			// = e.CollisionInformation.BoundingBox;
			//Vector3 corner = Matrix.TransformNormal( Vector3.One, e.WorldTransform );
			Vector3[] corners = new Vector3[8];
			//Vector3 half_size = new Vector3( box.HalfWidth, box.HalfHeight, box.HalfLength );
			corners[0] = bb.Min;
			corners[6] = bb.Max;
			corners[1] = corners[0];
			corners[1].X = corners[6].X;
			corners[2] = corners[0];
			corners[2].X = corners[6].X;
			corners[2].Y = corners[6].Y;
			corners[3] = corners[0];
			corners[3].Y = corners[6].Y;

			corners[4] = corners[0];
			corners[4].Z = corners[6].Z;

			corners[5] = corners[0];
			corners[5].X = corners[6].X;
			corners[5].Z = corners[6].Z;
			corners[7] = corners[0];
			corners[7].Y = corners[6].Y;
			corners[7].Z = corners[6].Z;
			Vector3 white = Vector3.One;
			white.Y = 0;
			white.Z = 0;
			drawLine( render, ref corners[0], ref corners[1], ref white, ref white );
			drawLine( render, ref corners[1], ref corners[2], ref white, ref white );
			drawLine( render, ref corners[2], ref corners[3], ref white, ref white );
			drawLine( render, ref corners[3], ref corners[0], ref white, ref white );
			drawLine( render, ref corners[0], ref corners[4], ref white, ref white );
			drawLine( render, ref corners[1], ref corners[5], ref white, ref white );
			drawLine( render, ref corners[2], ref corners[6], ref white, ref white );
			drawLine( render, ref corners[3], ref corners[7], ref white, ref white );
			drawLine( render, ref corners[4], ref corners[5], ref white, ref white );
			drawLine( render, ref corners[5], ref corners[6], ref white, ref white );
			drawLine( render, ref corners[6], ref corners[7], ref white, ref white );
			drawLine( render, ref corners[7], ref corners[4], ref white, ref white );
		}
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:42,代码来源:BEPUDebugDrawer.cs


示例13: ComputeBoundingBox

        ///<summary>
        /// Computes the bounding box of the transformed mesh shape.
        ///</summary>
        ///<param name="transform">Transform to apply to the shape during the bounding box calculation.</param>
        ///<param name="boundingBox">Bounding box containing the transformed mesh shape.</param>
        public void ComputeBoundingBox(ref AffineTransform transform, out BoundingBox boundingBox)
        {
            #if !WINDOWS
            boundingBox = new BoundingBox();
            #endif
            float minX = float.MaxValue;
            float minY = float.MaxValue;
            float minZ = float.MaxValue;

            float maxX = -float.MaxValue;
            float maxY = -float.MaxValue;
            float maxZ = -float.MaxValue;
            for (int i = 0; i < triangleMesh.Data.vertices.Length; i++)
            {
                System.Numerics.Vector3 vertex;
                triangleMesh.Data.GetVertexPosition(i, out vertex);
                Matrix3x3.Transform(ref vertex, ref transform.LinearTransform, out vertex);
                if (vertex.X < minX)
                    minX = vertex.X;
                if (vertex.X > maxX)
                    maxX = vertex.X;

                if (vertex.Y < minY)
                    minY = vertex.Y;
                if (vertex.Y > maxY)
                    maxY = vertex.Y;

                if (vertex.Z < minZ)
                    minZ = vertex.Z;
                if (vertex.Z > maxZ)
                    maxZ = vertex.Z;
            }
            boundingBox.Min.X = transform.Translation.X + minX;
            boundingBox.Min.Y = transform.Translation.Y + minY;
            boundingBox.Min.Z = transform.Translation.Z + minZ;

            boundingBox.Max.X = transform.Translation.X + maxX;
            boundingBox.Max.Y = transform.Translation.Y + maxY;
            boundingBox.Max.Z = transform.Translation.Z + maxZ;
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:45,代码来源:InstancedMeshShape.cs


示例14: GetEntries

        public void GetEntries(BoundingBox boundingShape, IList<BroadPhaseEntry> overlaps)
        {
            //Compute the min and max of the bounding box.
            //Loop through the cells and select bounding boxes which overlap the x axis.

            Int2 min, max;
            Grid2DSortAndSweep.ComputeCell(ref boundingShape.Min, out min);
            Grid2DSortAndSweep.ComputeCell(ref boundingShape.Max, out max);
            for (int i = min.Y; i <= max.Y; i++)
            {
                for (int j = min.Z; j <= max.Z; j++)
                {
                    //Grab the cell that we are currently in.
                    Int2 cellIndex;
                    cellIndex.Y = i;
                    cellIndex.Z = j;
                    GridCell2D cell;
                    if (owner.cellSet.TryGetCell(ref cellIndex, out cell))
                    {

                        //To fully accelerate this, the entries list would need to contain both min and max interval markers.
                        //Since it only contains the sorted min intervals, we can't just start at a point in the middle of the list.
                        //Consider some giant bounding box that spans the entire list.
                        for (int k = 0; k < cell.entries.Count
                            && cell.entries.Elements[k].item.boundingBox.Min.X <= boundingShape.Max.X; k++) //TODO: Try additional x axis pruning? A bit of optimization potential due to overlap with AABB test.
                        {
                            bool intersects;
                            var item = cell.entries.Elements[k].item;
                            boundingShape.Intersects(ref item.boundingBox, out intersects);
                            if (intersects && !overlaps.Contains(item))
                            {
                                overlaps.Add(item);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:38,代码来源:Grid2DSortAndSweepQueryAccelerator.cs


示例15: GetBoundingBox

        /// <summary>
        /// Computes a bounding box for the shape given the specified transform.
        /// </summary>
        /// <param name="transform">Transform to apply to the shape to compute the bounding box.</param>
        /// <param name="boundingBox">Bounding box for the shape given the transform.</param>
        public override void GetBoundingBox(ref RigidTransform transform, out BoundingBox boundingBox)
        {
            RigidTransform combinedTransform;
            RigidTransform.Transform(ref shapes.Elements[0].LocalTransform, ref transform, out combinedTransform);
            shapes.Elements[0].Shape.GetBoundingBox(ref combinedTransform, out boundingBox);

            for (int i = 0; i < shapes.Count; i++)
            {
                RigidTransform.Transform(ref shapes.Elements[i].LocalTransform, ref transform, out combinedTransform);
                BoundingBox childBoundingBox;
                shapes.Elements[i].Shape.GetBoundingBox(ref combinedTransform, out childBoundingBox);
                BoundingBox.CreateMerged(ref boundingBox, ref childBoundingBox, out boundingBox);
            }
        }
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:19,代码来源:CompoundShape.cs


示例16: SpawnBody

 /// <summary>
 /// Builds and spawns the body into the world.
 /// </summary>
 public virtual void SpawnBody()
 {
     if (Body != null)
     {
         DestroyBody();
     }
     Body = new BEPUphysics.Entities.Entity(Shape, Mass);
     Body.CollisionInformation.CollisionRules.Group = CGroup;
     InternalOffset = new Location(Body.Position);
     Body.AngularVelocity = new Vector3((float)AVel.X, (float)AVel.Y, (float)AVel.Z);
     Body.LinearVelocity = new Vector3((float)LVel.X, (float)LVel.Y, (float)LVel.Z);
     Body.WorldTransform = WorldTransform; // TODO: Position + Quaternion
     Body.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Passive;
     if (!CanRotate)
     {
         Body.AngularDamping = 1;
     }
     // TODO: Other settings
     // TODO: Gravity
     Body.Tag = this;
     SetFriction(Friction);
     SetBounciness(Bounciness);
     TheRegion.PhysicsWorld.Add(Body);
     for (int i = 0; i < Joints.Count; i++)
     {
         if (Joints[i] is BaseJoint)
         {
             BaseJoint joint = (BaseJoint)Joints[i];
             joint.CurrentJoint = joint.GetBaseJoint();
             TheRegion.PhysicsWorld.Add(joint.CurrentJoint);
         }
     }
     ShadowCastShape = Shape.GetCollidableInstance().BoundingBox;
     ShadowMainDupe = Shape.GetCollidableInstance().BoundingBox;
     ShadowCenter = GetPosition();
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:39,代码来源:PhysicsEntity.cs


示例17: GetBoundingBox

        /// <summary>
        /// Gets the bounding box of the shape given a transform.
        /// </summary>
        /// <param name="shapeTransform">Transform to use.</param>
        /// <param name="boundingBox">Bounding box of the transformed shape.</param>
        public override void GetBoundingBox(ref RigidTransform shapeTransform, out BoundingBox boundingBox)
        {
            #if !WINDOWS
            boundingBox = new BoundingBox();
            #endif

            Matrix3x3 o;
            Matrix3x3.CreateFromQuaternion(ref shapeTransform.Orientation, out o);
            //Sample the local directions from the orientation matrix, implicitly transposed.
            //Notice only three directions are used.  Due to box symmetry, 'left' is just -right.
            var right = new System.Numerics.Vector3(Math.Sign(o.M11) * halfWidth, Math.Sign(o.M21) * halfHeight, Math.Sign(o.M31) * halfLength);

            var up = new System.Numerics.Vector3(Math.Sign(o.M12) * halfWidth, Math.Sign(o.M22) * halfHeight, Math.Sign(o.M32) * halfLength);

            var backward = new System.Numerics.Vector3(Math.Sign(o.M13) * halfWidth, Math.Sign(o.M23) * halfHeight, Math.Sign(o.M33) * halfLength);

            //Rather than transforming each axis independently (and doing three times as many operations as required), just get the 3 required values directly.
            System.Numerics.Vector3 offset;
            TransformLocalExtremePoints(ref right, ref up, ref backward, ref o, out offset);

            //The positive and negative vectors represent the X, Y and Z coordinates of the extreme points in world space along the world space axes.
            Vector3Ex.Add(ref shapeTransform.Position, ref offset, out boundingBox.Max);
            Vector3Ex.Subtract(ref shapeTransform.Position, ref offset, out boundingBox.Min);
        }
开发者ID:Raverenx,项目名称:GameEngine,代码行数:29,代码来源:BoxShape.cs


示例18: GetTriangleBoundingBox

        /// <summary>
        /// Computes the bounding box of three points.
        /// </summary>
        /// <param name="a">First vertex of the triangle.</param>
        /// <param name="b">Second vertex of the triangle.</param>
        /// <param name="c">Third vertex of the triangle.</param>
        /// <param name="aabb">Bounding box of the triangle.</param>
        public static void GetTriangleBoundingBox(ref Vector3 a, ref Vector3 b, ref Vector3 c, out BoundingBox aabb)
        {
#if !WINDOWS
            aabb = new BoundingBox();
#endif
            //X axis
            if (a.X > b.X && a.X > c.X)
            {
                //A is max
                aabb.Max.X = a.X;
                aabb.Min.X = b.X > c.X ? c.X : b.X;
            }
            else if (b.X > c.X)
            {
                //B is max
                aabb.Max.X = b.X;
                aabb.Min.X = a.X > c.X ? c.X : a.X;
            }
            else
            {
                //C is max
                aabb.Max.X = c.X;
                aabb.Min.X = a.X > b.X ? b.X : a.X;
            }
            //Y axis
            if (a.Y > b.Y && a.Y > c.Y)
            {
                //A is max
                aabb.Max.Y = a.Y;
                aabb.Min.Y = b.Y > c.Y ? c.Y : b.Y;
            }
            else if (b.Y > c.Y)
            {
                //B is max
                aabb.Max.Y = b.Y;
                aabb.Min.Y = a.Y > c.Y ? c.Y : a.Y;
            }
            else
            {
                //C is max
                aabb.Max.Y = c.Y;
                aabb.Min.Y = a.Y > b.Y ? b.Y : a.Y;
            }
            //Z axis
            if (a.Z > b.Z && a.Z > c.Z)
            {
                //A is max
                aabb.Max.Z = a.Z;
                aabb.Min.Z = b.Z > c.Z ? c.Z : b.Z;
            }
            else if (b.Z > c.Z)
            {
                //B is max
                aabb.Max.Z = b.Z;
                aabb.Min.Z = a.Z > c.Z ? c.Z : a.Z;
            }
            else
            {
                //C is max
                aabb.Max.Z = c.Z;
                aabb.Min.Z = a.Z > b.Z ? b.Z : a.Z;
            }
        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:70,代码来源:Toolbox.cs


示例19: ExpandBoundingBox

        /// <summary>
        /// Expands a bounding box by the given sweep.
        /// </summary>
        /// <param name="boundingBox">Bounding box to expand.</param>
        /// <param name="sweep">Sweep to expand the bounding box with.</param>
        public static void ExpandBoundingBox(ref BoundingBox boundingBox, ref Vector3 sweep)
        {
            if (sweep.X > 0)
                boundingBox.Max.X += sweep.X;
            else
                boundingBox.Min.X += sweep.X;

            if (sweep.Y > 0)
                boundingBox.Max.Y += sweep.Y;
            else
                boundingBox.Min.Y += sweep.Y;

            if (sweep.Z > 0)
                boundingBox.Max.Z += sweep.Z;
            else
                boundingBox.Min.Z += sweep.Z;
        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:22,代码来源:Toolbox.cs


示例20: BuildPileSimulation

        int BuildPileSimulation(Space space)
        {
            Random rand = new Random(0);

#if WINDOWS
            NarrowPhaseHelper.Factories.BoxBox.EnsureCount(30000);
            BoundingBox box = new BoundingBox(new Vector3(-5, 10, -5), new Vector3(5, 300, 5));
            for (int k = 0; k < 5000; k++)
#else        
            NarrowPhaseHelper.Factories.BoxBox.EnsureCount(1500);
            BoundingBox box = new BoundingBox(new Vector3(-5, 10, -5), new Vector3(5, 20, 5));
            for (int k = 0; k < 250; k++)
#endif
            {
                Vector3 position = new Vector3((float)(rand.NextDouble() * (box.Max.X - box.Min.X) + box.Min.X),
                                               (float)(rand.NextDouble() * (box.Max.Y - box.Min.Y) + box.Min.Y),
                                               (float)(rand.NextDouble() * (box.Max.Z - box.Min.Z) + box.Min.Z));
                var toAdd = new Box(position, 1, 1, 1, 1);
                toAdd.ActivityInformation.IsAlwaysActive = true;

                space.Add(toAdd);


            }

            Box ground = new Box(new Vector3(0, 0, 0), 300, 10, 300);
            space.Add(ground);

#if WINDOWS
            return 700;
#else
            return 350;
#endif
        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:34,代码来源:MultithreadedScalingTestDemo.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BEPUutilities.Matrix3x3类代码示例发布时间:2022-05-24
下一篇:
C# BEPUutilities.AffineTransform类代码示例发布时间: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