Ejemplo n.º 1
0
    void Update()
    {
        if (selGridInt != -1)
        {
            switch (selGridInt)
            {
            case 0:
                Size = TerrainSize.Huge;
                break;

            case 1:
                Size = TerrainSize.Big;
                break;

            case 2:
                Size = TerrainSize.Medium;
                break;

            case 3:
                Size = TerrainSize.Small;
                break;
            }
            selGridInt = -1;
            ChangeTerrains();
            changeTerrain = false;
        }
    }
Ejemplo n.º 2
0
        //--------------------//

        #region Get input
        /// <summary>
        /// Get a new <see cref="TerrainSize"/>.
        /// </summary>
        /// <returns>The new <see cref="TerrainSize"/>.</returns>
        public static TerrainSize Create()
        {
            var size = new TerrainSize(126, 126, stretchH: 30);

            Edit(ref size);
            return(size);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Modify an existing <see cref="TerrainSize"/>.
        /// </summary>
        /// <param name="size">The <see cref="TerrainSize"/> to modify</param>
        /// <exception cref="OperationCanceledException">The user clicked the cancel button.</exception>
        public static void Edit(ref TerrainSize size)
        {
            var dialog = new TerrainSizeDialog
            {
                // Display existing data in dialog
                numericX        = { Value = size.X },
                numericY        = { Value = size.Y },
                numericStretchH = { Value = ((decimal)size.StretchH) },
                numericStretchV = { Value = ((decimal)size.StretchV) }
            };

            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                throw new OperationCanceledException();
            }

            // Get new data from dialog
            size.X        = (int)dialog.numericX.Value;
            size.Y        = (int)dialog.numericY.Value;
            size.StretchH = (float)dialog.numericStretchH.Value;
            size.StretchV = (float)dialog.numericStretchV.Value;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="core">Engine core.</param>
        /// <param name="size">Size of terrain.</param>
        public QuadTerrainComponent(DeepCore core, TerrainSize size)
            : base(core)
        {
            // Get dimensions
            this.mapDimension = (int)size;

            // Height maps must always subdivide into 128x128 or smaller leaf nodes.
            // This is to ensure each leaf tile fits within a single vertex buffer.
            leafDimension = mapDimension;
            int levelCount = 0;

            while (leafDimension > 128)
            {
                levelCount++;
                leafDimension /= 2;
            }

            // Store values
            this.levelCount       = levelCount;
            this.terrainBlendMap0 = new Texture2D(core.GraphicsDevice, mapDimension, mapDimension, false, SurfaceFormat.Color);
            this.terrainBlendMap1 = new Texture2D(core.GraphicsDevice, mapDimension, mapDimension, false, SurfaceFormat.Color);
            this.mapHeight        = mapDimension * heightMultiplier;

            // Clear blend maps
            ClearBlendMaps();

            // Create vertex texture
            terrainVertexMap = new Texture2D(
                core.GraphicsDevice,
                mapDimension,
                mapDimension,
                false,
                SurfaceFormat.Vector4);

            // Set default textures
            SetDaggerfallTexture(0, 302, 1);
            SetDaggerfallTexture(1, 102, 1);
            SetDaggerfallTexture(2, 302, 2);
            SetDaggerfallTexture(3, 302, 3);
            SetDaggerfallTexture(4, 303, 3);
            SetDaggerfallTexture(5, 003, 3);
            SetDaggerfallTexture(6, 003, 46);
            SetDaggerfallTexture(7, 302, 46);
            SetDaggerfallTexture(8, 404, 46);

            // Create arrays
            terrainData = new Vector4[mapDimension * mapDimension];

            // Create grid
            grid = new Grid(core.GraphicsDevice, leafDimension, 1.0f);

            // Initialise map data
            SetHeight(0);

            // Initialise quad tree
            BuildQuadTree();

            // Create intersections list
            pointerNodeIntersections = new List <Intersection.ObjectIntersection <QuadNode> >();

            // Load effects
            terrainEffect = core.ContentManager.Load <Effect>("Effects/RenderTerrain");

            // Get effect parameters
            terrainEffect_View          = terrainEffect.Parameters["View"];
            terrainEffect_Projection    = terrainEffect.Parameters["Projection"];
            terrainEffect_World         = terrainEffect.Parameters["World"];
            terrainEffect_VertexTexture = terrainEffect.Parameters["VertexTexture"];
            terrainEffect_BlendTexture0 = terrainEffect.Parameters["BlendTexture0"];
            terrainEffect_BlendTexture1 = terrainEffect.Parameters["BlendTexture1"];
            terrainEffect_Texture0      = terrainEffect.Parameters["Texture0"];
            terrainEffect_Texture1      = terrainEffect.Parameters["Texture1"];
            terrainEffect_Texture2      = terrainEffect.Parameters["Texture2"];
            terrainEffect_Texture3      = terrainEffect.Parameters["Texture3"];
            terrainEffect_Texture4      = terrainEffect.Parameters["Texture4"];
            terrainEffect_Texture5      = terrainEffect.Parameters["Texture5"];
            terrainEffect_Texture6      = terrainEffect.Parameters["Texture6"];
            terrainEffect_Texture7      = terrainEffect.Parameters["Texture7"];
            terrainEffect_Texture8      = terrainEffect.Parameters["Texture8"];
            terrainEffect_MaxHeight     = terrainEffect.Parameters["MaxHeight"];
            terrainEffect_SampleScale   = terrainEffect.Parameters["SampleScale"];
            terrainEffect_SampleOffset  = terrainEffect.Parameters["SampleOffset"];
            terrainEffect_TextureRepeat = terrainEffect.Parameters["TextureRepeat"];
        }