當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。