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


C# BoundingBox.GetIntersection方法代码示例

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


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

示例1: Prepare

        public override bool Prepare(Vector3I[] marks) {
            if (marks == null)
                throw new ArgumentNullException("marks");
            if (marks.Length < 2)
                throw new ArgumentException("At least two marks needed.", "marks");

            // Make sure that we have something to paste
            CopyInfo = Player.GetCopyState();
            if (CopyInfo == null) {
                Player.Message("Nothing to paste! Copy something first.");
                return false;
            }

            // Calculate the buffer orientation
            Vector3I delta = marks[1] - marks[0];
            Vector3I orientation = new Vector3I {
                X = (delta.X == 0 ? CopyInfo.Orientation.X : Math.Sign(delta.X)),
                Y = (delta.Y == 0 ? CopyInfo.Orientation.Y : Math.Sign(delta.Y)),
                Z = (delta.Z == 0 ? CopyInfo.Orientation.Z : Math.Sign(delta.Z))
            };

            // Calculate the start/end coordinates for pasting
            marks[1] = marks[0] + new Vector3I(orientation.X * (CopyInfo.Bounds.Width - 1),
                                               orientation.Y * (CopyInfo.Bounds.Length - 1),
                                               orientation.Z * (CopyInfo.Bounds.Height - 1));
            Bounds = new BoundingBox(marks[0], marks[1]);
            Marks = marks;

            // Warn if paste will be cut off
            if (Bounds.XMin < 0 || Bounds.XMax > Map.Width - 1) {
                Player.Message("Warning: Not enough room horizontally (X), paste cut off.");
            }
            if (Bounds.YMin < 0 || Bounds.YMax > Map.Length - 1) {
                Player.Message("Warning: Not enough room horizontally (Y), paste cut off.");
            }
            if (Bounds.ZMin < 0 || Bounds.ZMax > Map.Height - 1) {
                Player.Message("Warning: Not enough room vertically, paste cut off.");
            }

            // Clip bounds to the map, to avoid unnecessary iteration beyond the map boundaries
            Start = Bounds.MinVertex;
            Bounds = Bounds.GetIntersection(Map.Bounds);

            // Set everything up for pasting
            Brush = this;
            Coords = Bounds.MinVertex;

            StartTime = DateTime.UtcNow;
            Context = BlockChangeContext.Drawn | BlockChangeContext.Pasted;
            BlocksTotalEstimate = Bounds.Volume;
            return true;
        }
开发者ID:Magi1053,项目名称:ProCraft,代码行数:52,代码来源:PasteDrawOperation.cs

示例2: Prepare

        public override bool Prepare( Vector3I[] marks ) {
            if( marks == null ) throw new ArgumentNullException( "marks" );
            if( marks.Length < 1 ) throw new ArgumentException( "At least one mark needed.", "marks" );

            Marks = marks;
            Origin = marks[0];
            SourceBlock = Map.GetBlock( Origin );

            Vector3I playerCoords = Player.Position.ToBlockCoords();
            Vector3I lookVector = (Origin - playerCoords);
            Axis = lookVector.LongestAxis;

            Vector3I maxDelta;

            maxFillExtent = Player.Info.Rank.FillLimit;
            if( maxFillExtent < 1 || maxFillExtent > 2048 ) maxFillExtent = 2048;

            switch( Axis ) {
                case Axis.X:
                    maxDelta = new Vector3I( 0, maxFillExtent, maxFillExtent );
                    coordEnumerator = BlockEnumeratorX().GetEnumerator();
                    break;
                case Axis.Y:
                    maxDelta = new Vector3I( maxFillExtent, 0, maxFillExtent );
                    coordEnumerator = BlockEnumeratorY().GetEnumerator();
                    break;
                default: // Z
                    maxDelta = new Vector3I( maxFillExtent, maxFillExtent, 0 );
                    coordEnumerator = BlockEnumeratorZ().GetEnumerator();
                    break;
            }

            Bounds = new BoundingBox( Origin - maxDelta, Origin + maxDelta );

            // Clip bounds to the map, used to limit fill extent
            Bounds = Bounds.GetIntersection( Map.Bounds );

            // Set everything up for filling
            Coords = Origin;

            StartTime = DateTime.UtcNow;
            Context = BlockChangeContext.Drawn | BlockChangeContext.Filled;
            BlocksTotalEstimate = Bounds.Volume;

            if( Brush == null ) throw new NullReferenceException( Name + ": Brush not set" );
            return Brush.Begin( Player, this );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:47,代码来源:Fill2DDrawOperation.cs

示例3: Prepare

        public override bool Prepare( Vector3I[] marks ) {
            if( marks == null ) throw new ArgumentNullException( "marks" );
            if( marks.Length < 1 ) throw new ArgumentException( "At least one mark needed.", "marks" );

            Marks = marks;
            Origin = marks[0];
            SourceBlock = Map.GetBlock( Origin );

            if( Player.Info.Rank.DrawLimit == 0 ) {
                // Unlimited!
                Bounds = Map.Bounds;

            } else {
                // Our fill limit is cube root of DrawLimit
                double pow = Math.Pow( Player.Info.Rank.DrawLimit, 1/3d );
                int maxLimit = (int)Math.Ceiling( pow / 2 );

                // Compute the largest possible extent
                if( maxLimit < 1 || maxLimit > 2048 ) maxLimit = 2048;
                Vector3I maxDelta = new Vector3I( maxLimit, maxLimit, maxLimit );
                Bounds = new BoundingBox( Origin - maxDelta, Origin + maxDelta );
                // Clip bounds to the map, used to limit fill extent
                Bounds = Bounds.GetIntersection( Map.Bounds );
            }

            // Set everything up for filling
            Coords = Origin;

            StartTime = DateTime.UtcNow;
            Context = BlockChangeContext.Drawn | BlockChangeContext.Filled;
            BlocksTotalEstimate = Bounds.Volume;

            coordEnumerator = BlockEnumerator().GetEnumerator();

            if( Brush == null ) throw new NullReferenceException( Name + ": Brush not set" );
            return Brush.Begin( Player, this );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:37,代码来源:Fill3DDrawOperation.cs


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