Ejemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="name">
        /// </param>
        /// <param name="url">
        /// </param>
        /// <param name="width">
        /// </param>
        /// <param name="height">
        /// </param>
        /// <param name="subdivisions">
        /// </param>
        /// <param name="minHeight">
        /// </param>
        /// <param name="maxHeight">
        /// </param>
        /// <param name="scene">
        /// </param>
        /// <param name="updatable">
        /// </param>
        /// <returns>
        /// </returns>
        public static GroundMesh CreateGroundFromHeightMap(
            string name, string url, double width, double height, int subdivisions, double minHeight, double maxHeight, Scene scene, bool updatable = false)
        {
            var ground = new GroundMesh(name, scene);

            ground._subdivisions = subdivisions;
            ground._setReady(false);
            Action <Web.ImageData> onload = (img) =>
            {
                //var canvas = (HTMLCanvasElement)Engine.document.createElement("canvas");
                //var context = (CanvasRenderingContext2D)canvas.getContext("2d");
                var heightMapWidth  = img.width;
                var heightMapHeight = img.height;
                //canvas.width = heightMapWidth;
                //canvas.height = heightMapHeight;
                //context.drawImage(img, 0, 0);
                //var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
                var vertexData = VertexData.CreateGroundFromHeightMap(
                    width, height, subdivisions, minHeight, maxHeight, img.dataBytes, heightMapWidth, heightMapHeight);
                vertexData.applyToMesh(ground, updatable);
                ground._setReady(true);
            };

            Tools.LoadImage(scene.getEngine()._canvas, url, onload, (img, err) => { }, scene.database);
            return(ground);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="name">
        /// </param>
        /// <param name="width">
        /// </param>
        /// <param name="height">
        /// </param>
        /// <param name="subdivisions">
        /// </param>
        /// <param name="scene">
        /// </param>
        /// <param name="updatable">
        /// </param>
        /// <returns>
        /// </returns>
        public static Mesh CreateGround(string name, double width, double height, int subdivisions, Scene scene, bool updatable = false)
        {
            var ground = new GroundMesh(name, scene);

            ground._setReady(false);
            ground._subdivisions = subdivisions;
            var vertexData = VertexData.CreateGround(width, height, subdivisions);

            vertexData.applyToMesh(ground, updatable);
            ground._setReady(true);
            return(ground);
        }