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


C# BoundingBox.GetCorners方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.BoundingBox.GetCorners方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox.GetCorners方法的具體用法?C# BoundingBox.GetCorners怎麽用?C# BoundingBox.GetCorners使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.BoundingBox的用法示例。


在下文中一共展示了BoundingBox.GetCorners方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DrawBBox

        public static void DrawBBox(BoundingBox box, Matrix Projection, Matrix View, Matrix localWorld,Color color)
        {
            // Use inside a drawing loop

                Vector3[] corners = box.GetCorners();
                VertexPositionColor[] primitiveList = new VertexPositionColor[corners.Length];

                // Assign the 8 box vertices
                for (int i = 0; i < corners.Length; i++)
                {
                    primitiveList[i] = new VertexPositionColor(corners[i], color);
                }

                /* Set your own effect parameters here */

                boxEffect.World = localWorld;
                boxEffect.View = View;
                boxEffect.Projection = Projection;
                boxEffect.TextureEnabled = false;

                // Draw the box with a LineList
                foreach (EffectPass pass in boxEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    device.DrawUserIndexedPrimitives(
                        PrimitiveType.LineList, primitiveList, 0, 8,
                        bBoxIndices, 0, 12);
                }
        }
開發者ID:MenosGrandes,項目名稱:mrowisko-pbl,代碼行數:29,代碼來源:BBoxRender.cs

示例2: Render

        /// <summary>
        /// Renders the bounding box for debugging purposes.
        /// </summary>
        /// <param name="box">The box to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="color">The color to use drawing the lines of the box.</param>
        public static void Render(
            BoundingBox box,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (box.Min == box.Max)
            {
                return;
            }

            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice)
                             {TextureEnabled = false, VertexColorEnabled = true, LightingEnabled = false};
            }

            Vector3[] corners = box.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0,
                                                         indices.Length/2);
            }
        }
開發者ID:HaKDMoDz,項目名稱:4DBlockEngine,代碼行數:43,代碼來源:BoundingBoxRenderer.cs

示例3: Draw

        public static void Draw(BoundingBox box, BaseCamera camera, Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(YnG.GraphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3 [] corners = box.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts [i].Position = corners [i];
                verts [i].Color = color;
            }

            effect.View = camera.View;
            effect.Projection = camera.Projection;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                YnG.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0, indices.Length / 2);
            }
        }
開發者ID:shaoleibo,項目名稱:YnaEngine,代碼行數:25,代碼來源:BoundingBoxRenderer.cs

示例4: Render

        public static void Render(BoundingBox box,
                                  GraphicsDevice graphicsDevice,
                                  Matrix view,
                                  Matrix projection,
                                  Color color)
        {
            if (_effect.IsNull())
                _effect = new BasicEffect(graphicsDevice) { VertexColorEnabled = true, LightingEnabled = false };

            var corners = box.GetCorners();

            for (var i = 0; i < 8; i++)
            {
                Vertices[i].Position = corners[i];
                Vertices[i].Color = color;
            }

            _effect.View = view;
            _effect.Projection = projection;

            foreach (var pass in _effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList,
                                                         Vertices,
                                                         0,
                                                         8,
                                                         Indices,
                                                         0,
                                                         Indices.Length / 2);
            }
        }
開發者ID:naighes,項目名稱:AsteroidChallenge,代碼行數:32,代碼來源:BoundingBoxRenderer.cs

示例5: AddBoundingBox

        public static void AddBoundingBox(BoundingBox box, Color color, float life)
        {
            DebugShape shape = GetShapeForLines(12, life);

            box.GetCorners(Corners);

            shape.Vertices[0] = new VertexPositionColor(Corners[0], color);
            shape.Vertices[1] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[2] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[3] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[4] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[5] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[6] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[7] = new VertexPositionColor(Corners[0], color);

            shape.Vertices[8] = new VertexPositionColor(Corners[4], color);
            shape.Vertices[9] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[10] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[11] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[12] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[13] = new VertexPositionColor(Corners[7], color);
            shape.Vertices[14] = new VertexPositionColor(Corners[7], color);
            shape.Vertices[15] = new VertexPositionColor(Corners[4], color);

            shape.Vertices[16] = new VertexPositionColor(Corners[0], color);
            shape.Vertices[17] = new VertexPositionColor(Corners[4], color);
            shape.Vertices[18] = new VertexPositionColor(Corners[1], color);
            shape.Vertices[19] = new VertexPositionColor(Corners[5], color);
            shape.Vertices[20] = new VertexPositionColor(Corners[2], color);
            shape.Vertices[21] = new VertexPositionColor(Corners[6], color);
            shape.Vertices[22] = new VertexPositionColor(Corners[3], color);
            shape.Vertices[23] = new VertexPositionColor(Corners[7], color);
        }
開發者ID:TalonTwist,項目名稱:3DBraveChess,代碼行數:33,代碼來源:DebugEngine.cs

示例6: Draw

        public static void Draw(BoundingBox box)
        {
            Vector3[] corners = box.GetCorners();
            VertexPositionColor[] primitiveList = new VertexPositionColor[corners.Length];

            // Assign the 8 box vertices
            for (int i = 0; i < corners.Length; i++)
            {
                primitiveList[i] = new VertexPositionColor(corners[i], Color.White);
            }

            /* Set your own effect parameters here */

            boxEffect.World = Matrix.Identity;
            boxEffect.View = Camera.View;
            boxEffect.Projection = Camera.Projection;
            boxEffect.TextureEnabled = false;

            // Draw the box with a LineList
            foreach (EffectPass pass in boxEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                AssetManager.Singleton.m_GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.LineList, primitiveList, 0, 8,
                    bBoxIndices, 0, 12);
            }
        }
開發者ID:EricPolman,項目名稱:clockwork-age,代碼行數:27,代碼來源:BoundingBoxRenderer.cs

示例7: GetVerticesFromBounds

        public static VertexPositionColor[] GetVerticesFromBounds(BoundingBox bounds, Color hitboxColor)
        {
            Vector3[] corners = bounds.GetCorners();
            VertexPositionColor[] debugVerts = new VertexPositionColor[24];
            debugVerts[0] = new VertexPositionColor(corners[0], hitboxColor);
            debugVerts[1] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[2] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[3] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[4] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[5] = new VertexPositionColor(corners[4], hitboxColor);
            debugVerts[6] = new VertexPositionColor(corners[4], hitboxColor);
            debugVerts[7] = new VertexPositionColor(corners[0], hitboxColor);

            debugVerts[8] = new VertexPositionColor(corners[3], hitboxColor);
            debugVerts[9] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[10] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[11] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[12] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[13] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[14] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[15] = new VertexPositionColor(corners[3], hitboxColor);

            debugVerts[16] = new VertexPositionColor(corners[3], hitboxColor);
            debugVerts[17] = new VertexPositionColor(corners[0], hitboxColor);
            debugVerts[18] = new VertexPositionColor(corners[2], hitboxColor);
            debugVerts[19] = new VertexPositionColor(corners[1], hitboxColor);
            debugVerts[20] = new VertexPositionColor(corners[6], hitboxColor);
            debugVerts[21] = new VertexPositionColor(corners[5], hitboxColor);
            debugVerts[22] = new VertexPositionColor(corners[7], hitboxColor);
            debugVerts[23] = new VertexPositionColor(corners[4], hitboxColor);

            return debugVerts;
        }
開發者ID:MattVitelli,項目名稱:Nosferatu,代碼行數:33,代碼來源:DebugHelper.cs

示例8: AddLightVolume

 public void AddLightVolume(ref BoundingBox boundingBox)
 {
     boundingBox.GetCorners(boundingBoxCorners);
     for (int i = 0; i < boundingBoxCorners.Length; i++)
     {
         additionalLightVolumePoints.Add(boundingBoxCorners[i]);
     }
 }
開發者ID:willcraftia,項目名稱:WindowsGame,代碼行數:8,代碼來源:LightCamera.cs

示例9: IsNaN

 public static bool IsNaN(BoundingBox b)
 {
     Vector3[] corners = new Vector3[8];
       b.GetCorners(corners);
       bool nan = false;
       for (int i = 0; i < CornersInBB && !nan; i++)
       {
     Vector3 v = corners[i];
     nan = nan || float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z);
       }
       return nan;
 }
開發者ID:DigitalLibrarian,項目名稱:xna-forever,代碼行數:12,代碼來源:NaNny.cs

示例10: CreateVertices

        VertexPositionColor[] CreateVertices(BoundingBox boundingBox)
        {
            var vertices = new VertexPositionColor[8];

            Vector3[] corners = boundingBox.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                vertices[i].Position = corners[i];
                vertices[i].Color = Color.Red;
            }

            return vertices;
        }
開發者ID:SaintGimp,項目名稱:GimpBlocks,代碼行數:13,代碼來源:BoundingBoxRenderer.cs

示例11: Transform

        public static BoundingBox Transform(BoundingBox box, Matrix world)
        {
            var vertices = box.GetCorners();
            var minVertex = new Vector3(float.MaxValue);
            var maxVertex = new Vector3(float.MinValue);

            foreach (Vector3 vertex in vertices)
            {
                var transformedVertex = Vector3.Transform(vertex, world);
                minVertex = Vector3.Min(minVertex, transformedVertex);
                maxVertex = Vector3.Max(maxVertex, transformedVertex);
            }

            return new BoundingBox(minVertex, maxVertex);
        }
開發者ID:Brandon-T,項目名稱:XNA-FPS,代碼行數:15,代碼來源:Collider.cs

示例12: GetWorldSpaceFrustumCorners

		public static IEnumerable<Vector3> GetWorldSpaceFrustumCorners(
			float clipSpaceNear, float clipSpaceFar,
			Matrix viewProjectionInverse)
		{
			var clipSpaceBoundingBox = new BoundingBox(
				new Vector3(-1, -1, clipSpaceNear), 
				new Vector3(1, 1, clipSpaceFar));
			return clipSpaceBoundingBox.GetCorners().Select(v =>
			{
				var vt = Vector4.Transform(v, viewProjectionInverse);
				vt /= vt.W;

				return new Vector3(vt.X, vt.Y, vt.Z);
			});
		}
開發者ID:modulexcite,項目名稱:xna-tutorials,代碼行數:15,代碼來源:FrustumUtility.cs

示例13: Render

        /// <summary>
        /// Renders the bounding box for debugging purposes.
        /// </summary>
        /// <param name="box">The box to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="color">The color to use drawing the lines of the box.</param>
        public static void Render(
            BoundingBox box,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice, null);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
                vertDecl = new VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements);
            }

            Vector3[] corners = box.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            graphicsDevice.VertexDeclaration = vertDecl;

            effect.View = view;
            effect.Projection = projection;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                graphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.LineList,
                    verts,
                    0,
                    8,
                    indices,
                    0,
                    indices.Length / 2);

                pass.End();
            }
            effect.End();
        }
開發者ID:AgusRumayor,項目名稱:C-,代碼行數:53,代碼來源:BoundingBoxRenderer.cs

示例14: Render

        /// <summary>
        /// Renders the bounding box for debugging purposes.
        /// </summary>
        /// <param name="box">The box to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="color">The color to use for drawing the lines of the box.</param>
        public static void Render(
            BoundingBox box,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3[] corners = box.GetCorners();

            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            vertex_Buffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), verts.Length, BufferUsage.WriteOnly);
            vertex_Buffer.SetData<VertexPositionColor>(verts);
            graphicsDevice.SetVertexBuffer(vertex_Buffer);

            effect.View = view;
            effect.Projection = projection;

            effect.CurrentTechnique.Passes[0].Apply();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                graphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.LineList,
                    verts,
                    0,
                    8,
                    indices,
                    0,
                    indices.Length / 2);
            }
        }
開發者ID:Brandon-T,項目名稱:XNA-FPS,代碼行數:51,代碼來源:TestRender.cs

示例15: LoadContent

        protected override void LoadContent()
        {
            base.LoadContent();
            BoundingBox box = new BoundingBox(new Vector3(-1,-1,-1),new Vector3(1,1,1) );
            Vector3[] boxCornersVertices = box.GetCorners();

            _boxCorners = new VertexPositionColor[boxCornersVertices.Length];
            for (int i = 0; i < 8; i++)
                _boxCorners[i] = new VertexPositionColor(boxCornersVertices[i], Color.White);

            _boxIndices = new int[24];
            _boxIndices[0] = 0;
            _boxIndices[1] = 1;
            _boxIndices[2] = 1;
            _boxIndices[3] = 2;
            _boxIndices[4] = 2;
            _boxIndices[5] = 3;
            _boxIndices[6] = 3;
            _boxIndices[7] = 0;
            _boxIndices[8] = 0;
            _boxIndices[9] = 4;
            _boxIndices[10] = 3;
            _boxIndices[11] = 7;
            _boxIndices[12] = 2;
            _boxIndices[13] = 6;
            _boxIndices[14] = 1;
            _boxIndices[15] = 5;
            _boxIndices[16] = 4;
            _boxIndices[17] = 5;
            _boxIndices[18] = 5;
            _boxIndices[19] = 6;
            _boxIndices[20] = 6;
            _boxIndices[21] = 7;
            _boxIndices[22] = 7;
            _boxIndices[23] = 4;

            effect = new BasicEffect(GraphicsDevice);
            effect.EnableDefaultLighting();
            effect.AmbientLightColor = new Vector3(150, 0, 0);
            effect.PreferPerPixelLighting = true;
            effect.LightingEnabled = true;
            effect.TextureEnabled = false;
        }
開發者ID:andrewmyhre,項目名稱:Tad.Xna.Common,代碼行數:43,代碼來源:TestAvatar.cs


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