c++arraysgridmultidimensional-arrayogre3d

Create a grid array


I created a grid array in OGRE3D game engine but the array is generic my array skills are pretty basic and need work so I am posting this just to be sure I am doing this correctly.

#define GRIDWIDTH 10
#define GRIDHEIGHT 10

int myGrid [HEIGHT][WIDTH];
int n,m;

int main ()
{
  for (n=0;n<HEIGHT;n++)
    for (m=0;m<WIDTH;m++)
    {
      jimmy[n][m]=(n+1)*(m+1);
    }
  return 0;
}

I am assuming the above will return:

 1 2 3 4 5 6 7 8 9 10
1
2
3
4
5
6
7
8
9
10

Then I can assign each point in the array to a valid node in OGRE3D to create a grid in 3D view would this work? Just need to tell me if I am doing it right or wrong dont need the ogre3d code....


Solution

  • Your array is going to be filled with a multiplication lookup chart with that code:

      1  2  3  4  
    1 1  2  3  4   
    2 2  4  6  8  
    3 6  9 12 15  
    4 8 12 16 20  
    
    

    Is this what you wanted?