/// <summary>
        /// Creates a new exterior location node.
        /// </summary>
        /// <param name="regionName">Region name.</param>
        /// <param name="locationName">Location name.</param>
        /// <returns>LocationNode.</returns>
        public LocationNode CreateExteriorLocationNode(string regionName, string locationName)
        {
            // Get location
            DFLocation location;

            if (!LoadDaggerfallLocation(
                    regionName,
                    locationName,
                    out location))
            {
                return(null);
            }

            // Reset ground plane texture cache
            textureManager.ClearGroundTextures();

            // Create location node
            LocationNode locationNode = new LocationNode(location);

            // Get dimensions of exterior location array
            int width  = location.Exterior.ExteriorData.Width;
            int height = location.Exterior.ExteriorData.Height;

            // Build exterior node from blocks
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    // Get final block name
                    string name = blocksFile.CheckName(
                        mapsFile.GetRmbBlockName(ref location, x, y));

                    // Create block position data
                    SceneNode blockNode = CreateBlockNode(name, location.Climate, false);
                    blockNode.Position = new Vector3(
                        x * rmbSide,
                        0f,
                        -(y * rmbSide));

                    // Add block to location node
                    locationNode.Add(blockNode);
                }
            }

            return(locationNode);
        }
Exemple #2
0
        private void CreateExteriorMap()
        {
            // Get dimensions of exterior location
            int width  = dfLocation.Exterior.ExteriorData.Width;
            int height = dfLocation.Exterior.ExteriorData.Height;

            // Get longest side
            int longestSide;

            if (width >= height)
            {
                longestSide = width;
            }
            else
            {
                longestSide = height;
            }

            // Calc block layout size based on longest side.
            // Note: If control dimensions are not square then blocks will look squashed.
            Size blockSize = new Size();

            if (longestSide <= 4)
            {
                blockSize.Width  = this.Width / 4;
                blockSize.Height = this.Height / 4;
            }
            else
            {
                blockSize.Width  = this.Width / 8;
                blockSize.Height = this.Height / 8;
            }

            // Create starting offsets.
            // Daggerfall's blocks are laid out bottom to top, then left to right.
            int xpos = 0;
            int ypos = (height * blockSize.Height) - blockSize.Height;

            // Create map layout
            exteriorLayout = new BlockLayout[width * height];
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int index = y * width + x;
                    exteriorLayout[index].x         = x;
                    exteriorLayout[index].y         = y;
                    exteriorLayout[index].rect      = new Rectangle(xpos, ypos, blockSize.Width, blockSize.Height);
                    exteriorLayout[index].name      = blocksFile.CheckName(mapsFile.GetRmbBlockName(ref dfLocation, x, y));
                    exteriorLayout[index].blocktype = DFBlock.BlockTypes.Rmb;
                    exteriorLayout[index].rdbType   = DFBlock.RdbTypes.Unknown;
                    xpos += blockSize.Width;
                }
                ypos -= blockSize.Height;
                xpos  = 0;
            }

            // Create layout image
            int layoutWidth  = width * blockSize.Width + 1;
            int layoutHeight = height * blockSize.Height + 1;

            exteriorLayoutBitmap = new Bitmap(layoutWidth, layoutHeight);
            Graphics gr = Graphics.FromImage(exteriorLayoutBitmap);

            // Render map layout
            DFManualImage dfManualImage = new DFManualImage();

            dfManualImage.Palette.MakeAutomap();
            foreach (var layout in exteriorLayout)
            {
                // Get block automap image
                dfManualImage.DFBitmap = blocksFile.GetBlockAutoMap(layout.name, true);
                Bitmap bm = dfManualImage.GetManagedBitmap(0, 0, false, true);

                // Render automap block
                gr.DrawImage(bm, layout.rect);

                // Render grid overlay
                gr.DrawRectangle(new Pen(gridColour), layout.rect);
            }
        }