示例#1
0
        private void Initialize(int xPos, int yPos, string entityName)
        {
            this.Title = "Entity Report - " + entityName;

            UInt32 windowWidth  = (UInt32)QSMath.Max((10 * this.Title.Length) + 20, 400);
            UInt32 windowHeight = 400;

            this.EnableDragging = true;
            this.MinimizeWidth  = windowWidth;
            this.MinimizeHeight = 25;

            this.label        = new ListControl();
            this.label.Bounds = new UniRectangle(4, 25, windowWidth - 10, windowHeight - 70);
            this.label.Slider.Bounds.Location.X.Offset -= 1.0f;
            this.label.Slider.Bounds.Location.Y.Offset += 1.0f;
            this.label.Slider.Bounds.Size.Y.Offset     -= 2.0f;
            this.label.SelectionMode = ListSelectionMode.Single;

            this.closeButton        = new ButtonControl();
            this.closeButton.Text   = "Close";
            this.closeButton.Bounds = new UniRectangle(new UniScalar(1.0f, -90.0f),
                                                       new UniScalar(1.0f, -40.0f),
                                                       80, 24);
            this.closeButton.Pressed += new EventHandler(closeButton_Pressed);

            this.Bounds = new UniRectangle(xPos, yPos, windowWidth, windowHeight);

            this.Children.Add(this.label);
            this.Children.Add(this.closeButton);
        }
示例#2
0
        /// <summary>
        /// Load the heightfield data from the heightmap image
        /// </summary>
        /// <param name="heightImagePath">Path of heightmap image to read from</param>
        private void LoadHeightData(string heightImagePath)
        {
            this.heightMap = this.parentEntity.Game.Content.Load <Texture2D>(heightImagePath);

            if ((QSMath.IsPowerOfTwo(this.heightMap.Width) && QSMath.IsPowerOfTwo(this.heightMap.Height) == false))
            {
                throw new Exception("Height maps must have a width and height that is a power of two.");
            }

            this.Size = this.heightMap.Width;             // Sets the map width to the same as the heightmap texture.

            // We setup the map for colors so we can use the color to determine elevations of the map
            Color[] heightMapColors = new Color[size * size];

            // XNA Built-in feature automatically copies pixel data into the heightmap.
            this.heightMap.GetData(heightMapColors);

            this.heightData = new float[size, size];  // Create an array to hold elevations from heightMap

            // Find minimum and maximum values for the heightmap file we read in
            for (int x = 0; x < size; ++x)
            {
                for (int z = 0; z < size; ++z)
                {
                    Color heightMapColorAtPoint = heightMapColors[x + z * size];
                    float heightAtXZ            = heightMapColorAtPoint.R + heightMapColorAtPoint.G + heightMapColorAtPoint.B;

                    if (heightAtXZ < this.MinimumHeight)
                    {
                        this.MinimumHeight = heightAtXZ;
                    }
                    else if (heightAtXZ > this.MaximumHeight)
                    {
                        this.MaximumHeight = heightAtXZ;
                    }
                }
            }


            // Set height by color, and then alter height by min and max amounts
            for (int x = 0; x < size; ++x)
            {
                for (int z = 0; z < size; ++z)
                {
                    Color heightMapColorAtPoint = heightMapColors[z + x * size];
                    float heightAtXZ            = heightMapColorAtPoint.R + heightMapColorAtPoint.G + heightMapColorAtPoint.B;
                    this.heightData[z, x] = (heightAtXZ - this.MinimumHeight) / (this.MaximumHeight - this.MinimumHeight) * this.elevationStrength * this.scaleFactor;
                }
            }
        }