Example #1
0
 /// <summary>
 /// view a grid from the given file
 /// </summary>
 /// <param name="d3d"></param>
 /// <param name="dx"></param>
 /// <param name="filename">grid filename</param>
 /// <param name="grid_level">the level of the grid within the grid to be viewed</param>
 /// <param name="min_evidence">minimum evidence threshold</param>
 public void viewOccupancyGrid(Gosub.Direct3d d3d, Microsoft.DirectX.Direct3D.Device dx,
                     String filename, int grid_level, int min_evidence)
 {
     if (!grid_loaded)
     {
         currentGrid = new occupancygrid(64, 100);
         switch(grid_type)
         {
             case "914":
                 {
                     currentGrid.Load(filename);
                     break;
                 }
         }
         grid_loaded = true;
     }
     if (currentGrid != null)
     {
         if (grid_type=="914")
             viewGrid(d3d, dx, currentGrid);
     }
 }
Example #2
0
 /// <summary>
 /// view a grid from the given file
 /// </summary>
 /// <param name="d3d"></param>
 /// <param name="dx"></param>
 /// <param name="filename">grid filename</param>
 /// <param name="grid_level">the level of the grid within the grid to be viewed</param>
 /// <param name="min_evidence">minimum evidence threshold</param>
 public void viewOccupancyGrid(Gosub.Direct3d d3d, Microsoft.DirectX.Direct3D.Device dx,
                               String filename, int grid_level, int min_evidence)
 {
     if (!grid_loaded)
     {
         currentGrid = new occupancygrid(64, 100);
         switch (grid_type)
         {
         case "914":
         {
             currentGrid.Load(filename);
             break;
         }
         }
         grid_loaded = true;
     }
     if (currentGrid != null)
     {
         if (grid_type == "914")
         {
             viewGrid(d3d, dx, currentGrid);
         }
     }
 }
Example #3
0
        public void viewGrid(Gosub.Direct3d d3d, Microsoft.DirectX.Direct3D.Device dx,
                            occupancygrid grid)
        {
            bool ground_plane_drawn = false;
            mCellMesh = new AutoMesh(d3d, Mesh.Box(dx, 1, 1, 1));

            //show the grid cells
            for (int z = grid.dimension-1; z >= 0 ; z--)
            {
                int plane_hits = 0;
                for (int x = 1; x < grid.dimension - 1; x++)
                {
                    for (int y = 1; y < grid.dimension-1; y++)
                    {
                        if (grid.display_cell[x, y, z])
                        {
                            plane_hits++;
                            occupancyGridCell c = grid.cell[x, y, z];
                            int r = 0;
                            int g = 0;
                            int b = 255;
                            if (c != null)
                            {
                                r = c.colour[0];
                                g = c.colour[1];
                                b = c.colour[2];
                            }

                            dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                //* Matrix.Scaling(1, 1, 1) // Make it bigger
                                //* Matrix.RotationYawPitchRoll(0, 0, 0)
                                                 * Matrix.Translation(grid.dimension - 1 - x, y, z)
                                                 * Matrix.RotationYawPitchRoll(0, tilt, 0); // Then move it where you want

                            dx.Material = GraphicsUtility.InitMaterial(Color.FromArgb(r, g, b));

                            mCellMesh.M.DrawSubset(0);
                        }


                        //for (int z = 0; z < grid.dimension; z++)
                        {
                            if (z == grid.dimension / 2)
                            {
                                if ((x == 1) || (x == grid.dimension - 2) || (y == 1) || (y == grid.dimension - 2))
                                {
                                    dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                                         * Matrix.Translation(x, y, z)
                                                         * Matrix.RotationYawPitchRoll(0, tilt, 0); // Then move it where you want

                                    dx.Material = GraphicsUtility.InitMaterial(Color.Green);
                                    mCellMesh.M.DrawSubset(0);
                                }
                            }
                        }
                    }

                }

                if ((plane_hits > 30) && (!ground_plane_drawn))
                {
                    ground_plane_drawn = true;
                    for (int x = 1; x < grid.dimension - 1; x++)
                    {
                        for (int y = 1; y < grid.dimension - 1; y++)
                        {
                            if (grid.empty[x, y])
                            {
                                //occupancyGridCell c = grid.cell[x, y, z];
                                int r = 0;
                                int g = 0;
                                int b = 255;

                                dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                    //* Matrix.Scaling(1, 1, 1) // Make it bigger
                                    //* Matrix.RotationYawPitchRoll(0, 0, 0)
                                                     * Matrix.Translation(grid.dimension - 1 - x, y, z)
                                                     * Matrix.RotationYawPitchRoll(0, tilt, 0); // Then move it where you want

                                dx.Material = GraphicsUtility.InitMaterial(Color.FromArgb(r, g, b));

                                mCellMesh.M.DrawSubset(0);
                            }
                        }
                    }
                }


            }

        }
Example #4
0
        public void viewGrid(Gosub.Direct3d d3d, Microsoft.DirectX.Direct3D.Device dx,
                             occupancygrid grid)
        {
            bool ground_plane_drawn = false;

            mCellMesh = new AutoMesh(d3d, Mesh.Box(dx, 1, 1, 1));

            //show the grid cells
            for (int z = grid.dimension - 1; z >= 0; z--)
            {
                int plane_hits = 0;
                for (int x = 1; x < grid.dimension - 1; x++)
                {
                    for (int y = 1; y < grid.dimension - 1; y++)
                    {
                        if (grid.display_cell[x, y, z])
                        {
                            plane_hits++;
                            occupancyGridCell c = grid.cell[x, y, z];
                            int r = 0;
                            int g = 0;
                            int b = 255;
                            if (c != null)
                            {
                                r = c.colour[0];
                                g = c.colour[1];
                                b = c.colour[2];
                            }

                            dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                                                                                                                   //* Matrix.Scaling(1, 1, 1) // Make it bigger
                                                                                                                                   //* Matrix.RotationYawPitchRoll(0, 0, 0)
                                                 * Matrix.Translation(grid.dimension - 1 - x, y, z)
                                                 * Matrix.RotationYawPitchRoll(0, tilt, 0);                                        // Then move it where you want

                            dx.Material = GraphicsUtility.InitMaterial(Color.FromArgb(r, g, b));

                            mCellMesh.M.DrawSubset(0);
                        }


                        //for (int z = 0; z < grid.dimension; z++)
                        {
                            if (z == grid.dimension / 2)
                            {
                                if ((x == 1) || (x == grid.dimension - 2) || (y == 1) || (y == grid.dimension - 2))
                                {
                                    dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                                         * Matrix.Translation(x, y, z)
                                                         * Matrix.RotationYawPitchRoll(0, tilt, 0);                                        // Then move it where you want

                                    dx.Material = GraphicsUtility.InitMaterial(Color.Green);
                                    mCellMesh.M.DrawSubset(0);
                                }
                            }
                        }
                    }
                }

                if ((plane_hits > 30) && (!ground_plane_drawn))
                {
                    ground_plane_drawn = true;
                    for (int x = 1; x < grid.dimension - 1; x++)
                    {
                        for (int y = 1; y < grid.dimension - 1; y++)
                        {
                            if (grid.empty[x, y])
                            {
                                //occupancyGridCell c = grid.cell[x, y, z];
                                int r = 0;
                                int g = 0;
                                int b = 255;

                                dx.Transform.World = Matrix.Translation(-grid.dimension / 2, -grid.dimension / 2, -grid.dimension / 2) //Center model
                                                                                                                                       //* Matrix.Scaling(1, 1, 1) // Make it bigger
                                                                                                                                       //* Matrix.RotationYawPitchRoll(0, 0, 0)
                                                     * Matrix.Translation(grid.dimension - 1 - x, y, z)
                                                     * Matrix.RotationYawPitchRoll(0, tilt, 0);                                        // Then move it where you want

                                dx.Material = GraphicsUtility.InitMaterial(Color.FromArgb(r, g, b));

                                mCellMesh.M.DrawSubset(0);
                            }
                        }
                    }
                }
            }
        }