Пример #1
0
        /// <summary>
        /// Runs through all levels and creates the parameters that are required to
        /// produce all images for each level, and starts the conversion
        /// </summary>
        private void CreatePyramid()
        {
            // The resolution of the image has to be n*2+1 to grid size in x3dom
            int    meshDim = Convert.ToInt32(meshDimension.Text) * 2 + 1;
            double factor  = 1.0;
            // List of nodes that is only required for tree extraction
            ArrayList nodes = new ArrayList();

            // Creates the coordinates on the image of the output size of all nodes
            UV[,] VertexData = createVertexData(meshDim);
            int          entireTiles      = 0;
            int          currentTiles     = 0;
            TreeTileData rootTreeTileData = null;

            // Calculation of the count of all tiles that should be produced in all levels
            for (int count = 0; count <= Convert.ToDouble(qtDepth.Text); count++)
            {
                entireTiles += (int)Math.Pow(4, count);
            }
            TreeTileData[] treeTileData = null;

            // Only required for tree output
            if (datasetFormat.Text == "tree")
            {
                treeTileData     = new TreeTileData[entireTiles];
                rootTreeTileData = new TreeTileData(Convert.ToInt32(qtDepth.Text), storingPath.Text, 0, 0, 0, 1, treeTileData);
            }

            // Convertion of all nodes of all levels
            for (double level = 0.0; level <= Convert.ToDouble(qtDepth.Text); level++)
            {
                int    quadNumber = 0;
                int    rowCount = (int)Math.Sqrt(Math.Pow(4.0, level));
                double step = 1.0 / (double)((double)rowCount);
                double xStep = 0.0, yStep = 0.0;

                // Convertion of all nodes of the current level
                for (int y = 0; y < rowCount; y++)
                {
                    for (int x = 0; x < rowCount; x++)
                    {
                        OutputNode node = new OutputNode(xStep, yStep, factor, (int)level, quadNumber,
                                                         VertexData, image, new Bitmap(meshDim, meshDim,
                                                                                       System.Drawing.Imaging.PixelFormat.Format32bppArgb),
                                                         storingPath.Text, convertingType.Text,
                                                         x, y, treeTileData);
                        node.CreateImage();
                        // Refresh the progress
                        currentTiles++;
                        convertState.Value = (int)Math.Floor((double)currentTiles /
                                                             ((double)entireTiles /
                                                              100.0));
                        quadNumber++;
                        xStep += step;

                        // Refresh the form
                        convertState.Refresh();
                        this.Refresh();
                        Application.DoEvents();
                    }
                    xStep  = 0.0;
                    yStep += step;
                }
                yStep   = 0.0;
                factor /= 2;
            }

            // final message
            MessageBox.Show("The convertion has been finished successfully! \n " +
                            "Please use the following configuration and replace all [] " +
                            "through right pathes etc. (all settings with '*' are only " +
                            "required if mode=3D): \n------------------------------------" +
                            "---------------------------------------\n\n" +
                            "<BVHRefiner maxDepth='" + qtDepth.Text + "'" +
                            "\n\t     minDepth='[0.." + qtDepth.Text + "]'" +
                            "\n\t     interactionDepth='[0.." + qtDepth.Text + "]'" +
                            "\n\t     smoothLoading='5'" +
                            "\n\t     subdivision='" + meshDimension.Text + " " + meshDimension.Text + "'" +
                            "\n\t     size='" + image.Width + " " + image.Width + "'" +
                            "\n\t     factor='10'" +
                            "\n\t     maxElevation='[0..n]'" +
                            "\n\t     elevationUrl='[path to elevation data]*'" +
                            "\n\t     textureUrl='[path to texture data]'" +
                            "\n\t     normalUrl='[path to normal data]*'" +
                            "\n\t     elevationFormat='[png]*'" +
                            "\n\t     textureFormat='[jpg, png, gif]'" +
                            "\n\t     normalFormat='[jpg, png, gif]*'" +
                            "\n\t     mode='[2D, 3D, bin, bvh]'>" +
                            "\n</BVHRefiner>\n\n" +
                            "The node is copied to clipboard automatically. Please insert in HTML with " +
                            "'Ctrl + V'.",
                            "Result message",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
            convertState.Value = 0;

            // copy the node definition to clipboard
            String clipboardMessage = "<BVHRefiner maxDepth='" + qtDepth.Text + "'" +
                                      "\n\t     minDepth='[0.." + qtDepth.Text + "]'" +
                                      "\n\t     interactionDepth='[0.." + qtDepth.Text + "]'" +
                                      "\n\t     smoothLoading='5'" +
                                      "\n\t     subdivision='" + meshDimension.Text + " " + meshDimension.Text + "'" +
                                      "\n\t     size='" + image.Width + " " + image.Width + "'" +
                                      "\n\t     factor='10'" +
                                      "\n\t     maxElevation='[0..n]'" +
                                      "\n\t     elevationUrl='[path to elevation data]*'" +
                                      "\n\t     textureUrl='[path to texture data]'" +
                                      "\n\t     normalUrl='[path to normal data]*'" +
                                      "\n\t     elevationFormat='[png]*'" +
                                      "\n\t     textureFormat='[jpg, png, gif]'" +
                                      "\n\t     normalFormat='[jpg, png, gif]*'" +
                                      "\n\t     mode='[2D, 3D, bin, bvh]'>" +
                                      "\n</BVHRefiner>";

            Clipboard.SetText(clipboardMessage);
        }
Пример #2
0
 public TreeTileData(int maxDepth, String path, int level, int column, int row, int number, TreeTileData [] treeTileData)
 {
     int levelStartID = 0;
     int tileCount = (int)Math.Sqrt(Math.Pow(4.0, level));
     this.StroingDirectory = path + "/" + number;
     
     for (int i = 0; i < level; i++)
     {
         levelStartID += (int)Math.Pow(4, i);
     }
     int sid = levelStartID + (row * tileCount + column);
     treeTileData[sid] = this;
     if (level < maxDepth)
     {
         children.Add(new TreeTileData(maxDepth, this.StroingDirectory,
                                      (level + 1), (column * 2), (row * 2), 1, treeTileData));
         children.Add(new TreeTileData(maxDepth, this.StroingDirectory,
                                      (level + 1), (column * 2), (row * 2 + 1), 2, treeTileData));
         children.Add(new TreeTileData(maxDepth, this.StroingDirectory,
                                      (level + 1), (column * 2 + 1), (row * 2), 3, treeTileData));
         children.Add(new TreeTileData(maxDepth, this.StroingDirectory,
                                      (level + 1), (column * 2 + 1), (row * 2 + 1), 4, treeTileData));
     }
 }
Пример #3
0
 public OutputNode(double xOffset, double yOffset, double factor, 
                 int level, int quadNumber, UV[,] UVCoords, Bitmap bmp, 
                 Bitmap resultBmp, String storingPath, String type,
                 int column, int row, TreeTileData [] treeTileData)
 {
     Column = column;
     Row = row;
     XOffset = xOffset;
     YOffset = yOffset;
     Factor = factor;
     Level = level;
     QuadNumber = quadNumber;
     BMP = bmp;
     ResultBMP = resultBmp;
     TransformedUVCoords = new UV[UVCoords.GetLength(0), UVCoords.GetLength(1)];
     StoringPath = storingPath;
     TreePathData = treeTileData;
     Type = type;
     // transforms the original texture coordinates to local space
     for (int x = 0; x < UVCoords.GetLength(0); x++)
     {
         for (int y = 0; y < UVCoords.GetLength(1); y++)
         {
             TransformedUVCoords[x, y] = new UV(xOffset + UVCoords[x, y].U * factor, 
                                                yOffset + UVCoords[x, y].V * factor);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Runs through all levels and creates the parameters that are required to
        /// produce all images for each level, and starts the conversion
        /// </summary>
        private void CreatePyramid()
        {
            // The resolution of the image has to be n*2+1 to grid size in x3dom
            int meshDim = Convert.ToInt32(meshDimension.Text) * 2 + 1;  
            double factor = 1.0;
            // List of nodes that is only required for tree extraction
            ArrayList nodes = new ArrayList();
            // Creates the coordinates on the image of the output size of all nodes
            UV[,] VertexData = createVertexData(meshDim);
            int entireTiles = 0;
            int currentTiles = 0;
            TreeTileData rootTreeTileData = null;

            // Calculation of the count of all tiles that should be produced in all levels
            for (int count = 0; count <= Convert.ToDouble(qtDepth.Text); count++)
            {
                entireTiles += (int)Math.Pow(4, count);
            }
            TreeTileData[] treeTileData = null;
            
            // Only required for tree output 
            if (datasetFormat.Text == "tree")
            {
                treeTileData = new TreeTileData[entireTiles];
                rootTreeTileData = new TreeTileData(Convert.ToInt32(qtDepth.Text),storingPath.Text, 0, 0, 0, 1, treeTileData);
            }

            // Convertion of all nodes of all levels
            for (double level = 0.0; level <= Convert.ToDouble(qtDepth.Text); level++)
            {
                int quadNumber = 0;
                int rowCount = (int)Math.Sqrt(Math.Pow(4.0, level));
                double step = 1.0 / (double)((double) rowCount);
                double xStep = 0.0, yStep = 0.0;
                
                // Convertion of all nodes of the current level
                for (int y = 0; y < rowCount; y++)
                {
                    for (int x = 0; x < rowCount; x++)
                    {
                        OutputNode node = new OutputNode(xStep, yStep, factor, (int)level, quadNumber,
                                                         VertexData,image, new Bitmap(meshDim, meshDim,
                                                         System.Drawing.Imaging.PixelFormat.Format32bppArgb),
                                                         storingPath.Text, convertingType.Text,
                                                         x, y, treeTileData);
                        node.CreateImage();
                        // Refresh the progress
                        currentTiles++;
                        convertState.Value = (int)Math.Floor((double)currentTiles / 
                                                            ((double)entireTiles / 
                                                            100.0));
                        quadNumber++;
                        xStep += step;

                        // Refresh the form 
                        convertState.Refresh();
                        this.Refresh();
                        Application.DoEvents();
                    }
                    xStep = 0.0;
                    yStep += step;
                }
                yStep = 0.0;
                factor /= 2;
            }

            // final message
            MessageBox.Show("The convertion has been finished successfully! \n " + 
                            "Please use the following configuration and replace all [] " + 
                            "through right pathes etc. (all settings with '*' are only " + 
                            "required if mode=3D): \n------------------------------------" + 
                            "---------------------------------------\n\n" +
                            "<BVHRefiner maxDepth='" + qtDepth.Text + "'" + 
                            "\n\t     minDepth='[0.." + qtDepth.Text + "]'" +
                            "\n\t     interactionDepth='[0.." + qtDepth.Text + "]'" +
                            "\n\t     smoothLoading='5'" +
                            "\n\t     subdivision='" + meshDimension.Text + " " + meshDimension.Text + "'" +
                            "\n\t     size='" + image.Width + " " + image.Width + "'" +
                            "\n\t     factor='10'" +
                            "\n\t     maxElevation='[0..n]'" +
                            "\n\t     elevationUrl='[path to elevation data]*'" +
                            "\n\t     textureUrl='[path to texture data]'" +
                            "\n\t     normalUrl='[path to normal data]*'" +
                            "\n\t     elevationFormat='[png]*'" +
                            "\n\t     textureFormat='[jpg, png, gif]'" +
                            "\n\t     normalFormat='[jpg, png, gif]*'" +
                            "\n\t     mode='[2D, 3D, bin, bvh]'>" + 
                            "\n</BVHRefiner>\n\n" + 
                            "The node is copied to clipboard automatically. Please insert in HTML with " + 
                            "'Ctrl + V'.", 
                            "Result message", 
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
            convertState.Value = 0;

            // copy the node definition to clipboard
            String clipboardMessage = "<BVHRefiner maxDepth='" + qtDepth.Text + "'" +
                              "\n\t     minDepth='[0.." + qtDepth.Text + "]'" +
                              "\n\t     interactionDepth='[0.." + qtDepth.Text + "]'" +
                              "\n\t     smoothLoading='5'" +
                              "\n\t     subdivision='" + meshDimension.Text + " " + meshDimension.Text + "'" +
                              "\n\t     size='" + image.Width + " " + image.Width + "'" +
                              "\n\t     factor='10'" +
                              "\n\t     maxElevation='[0..n]'" +
                              "\n\t     elevationUrl='[path to elevation data]*'" +
                              "\n\t     textureUrl='[path to texture data]'" +
                              "\n\t     normalUrl='[path to normal data]*'" +
                              "\n\t     elevationFormat='[png]*'" +
                              "\n\t     textureFormat='[jpg, png, gif]'" +
                              "\n\t     normalFormat='[jpg, png, gif]*'" +
                              "\n\t     mode='[2D, 3D, bin, bvh]'>" +
                              "\n</BVHRefiner>";
            Clipboard.SetText(clipboardMessage);
        }