示例#1
0
        /// <summary>
        /// Forced updated of the boundingbox scanning all the
        /// vertices of the cell for their height position
        /// </summary>
        private void UpdateBoundingBox()
        {
            float minH   = float.MaxValue;
            float maxH   = float.MinValue;
            float height = 0f;

            for (int y = 0; y < divisions.Y; y++)
            {
                for (int x = 0; x < divisions.X; x++)
                {
                    height = vertices[x + y * divisions.X].Position.Y;

                    if (height < minH)
                    {
                        minH = height;
                    }
                    if (height > maxH)
                    {
                        maxH = height;
                    }
                }
            }

            Vector3 Min = new Vector3(position.X, minH, position.Z);
            Vector3 Max = new Vector3(position.X + divisions.X * cellsize.X - cellsize.X, maxH, position.Z + divisions.Y * cellsize.Y - cellsize.Y);

            center.Y = Min.Y + (Max.Y - Min.Y) / 2f;

            boundingBox     = new BoundingBox(Min, Max);
            boundingBoxWire = new DrawableBoundingBox(Vector3.Zero, Min, Max);

            minHeight = minH;
            maxHeight = maxH;
        }
示例#2
0
 private void InitBoundingBox()
 {
     if (model.Tag != null)
     {
         BoundingBox modelBounds = (BoundingBox)model.Tag;
         boundingBox = new DrawableBoundingBox(position, modelBounds.Min, modelBounds.Max);
     }
 }
示例#3
0
        private void SetupVertices()
        {
            vertexDeclaration = new VertexDeclaration(Editor.graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements);

            vertex    = new VertexPositionNormalTexture[4];
            vertex[0] = new VertexPositionNormalTexture(new Vector3(-10f, 15f, 0f), Vector3.Forward, new Vector2(0f, 0f));
            vertex[1] = new VertexPositionNormalTexture(new Vector3(10f, 15f, 0f), Vector3.Forward, new Vector2(1f, 0f));
            vertex[2] = new VertexPositionNormalTexture(new Vector3(-10f, -15f, 0f), Vector3.Forward, new Vector2(0f, 1f));
            vertex[3] = new VertexPositionNormalTexture(new Vector3(10f, -15f, 0f), Vector3.Forward, new Vector2(1f, 1f));

            vertexBuffer = new VertexBuffer(Editor.graphics.GraphicsDevice, typeof(VertexPositionNormalTexture), vertex.Length, BufferUsage.None);
            vertexBuffer.SetData <VertexPositionNormalTexture>(vertex);

            boundingBox = new DrawableBoundingBox(position, vertex[2].Position - new Vector3(2f, 2f, 2f), vertex[1].Position + new Vector3(2f, 2f, 2f));
        }
示例#4
0
        private void UpdateBoundingBox(float minHeight, float maxHeight)
        {
            if (minHeight < this.minHeight)
            {
                this.minHeight = minHeight;
            }
            if (maxHeight > this.maxHeight)
            {
                this.maxHeight = maxHeight;
            }

            Vector3 Min = new Vector3(position.X, this.minHeight, position.Z);
            Vector3 Max = new Vector3(position.X + divisions.X * cellsize.X - cellsize.X, this.maxHeight, position.Z + divisions.Y * cellsize.Y - cellsize.Y);

            center.Y = Min.Y + (Max.Y - Min.Y) / 2f;

            boundingBox     = new BoundingBox(Min, Max);
            boundingBoxWire = new DrawableBoundingBox(Vector3.Zero, Min, Max);
        }