views:

55

answers:

1

Okay so I am looking to create a grided 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....

A: 

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?

Michael Dorgan
ahh i see, what I want is: for (n=0;n<HEIGHT;n++) for (m=0;m<WIDTH;m++) { myGrid[n][m]= x and y values that refer to array position; } return 0;so if array position is myGrid[1][2] x=1 and y=2
Anicho
Okay so what I wanted is an multidimensional array, it will create a new node based on its n and m position in the array so it will be as simple as (n + m) * 10, * 10 because I want to create a decent amount of space between each node, those this sound valid to you?
Anicho
Anicho