How to use the projection/camera technique in c#

Viewed 1439

I drew the following grid:

Grid (Top-View)

The above grid is drawn using the following two methods, one to calculate the grid and the other to calculate the centers for each cell:

//makes grid in picture box
private void drawGrid(int numOfCells, int cellSize, Graphics gr)
{
    Pen p = new Pen(Color.SteelBlue);

    for (int i = 0; i < Math.Sqrt(numOfCells) + 1; i++)
    {
        // Vertical
        gr.DrawLine(p, i * cellSize + 300, 200, i * cellSize + 300, 700);
        // Horizontal
        gr.DrawLine(p, 300, i * cellSize+200, 800, i * cellSize+200);
    }

    this.topology.SendToBack();
}


//draw the center point for each cell of the grid 
private void drawCenters(Graphics gr)
{
    for (int j = 0; j < rows; j++)
    {
        for (int i = 0; i < columns; i++)
        {
            gr.FillRectangle(Brushes.IndianRed, cellsCenters[0, i], cellsCenters[1, j], 3, 3);
        }
    }
}

My question is how to make this grid appear as in the following picture and how to place the nodes at different cells (random deployment) in such grid.

Expected result

I need the grid to be drawn in a 3D view in which I have z as well as x and y!

1 Answers
Related