Mapping spatials to a grid

Hi, simple question, I want to create a grid of spheres.  I've been thinking of a number of ways to do this, the first is create an array of spheres then assign them vector3f's dynamically generated from an array although I don't think this is very efficient or extensible, my other idea was to use lines to create the grid then populate the vector3f array by getting the intersections (I don't even know if this can be done).  So if anyone has any ideas on an efficient way to do this don't hesitate to let me know.  Thanks.

Dont see what is so wrong with creating an array - only costs 16 bytes for the array and 16 bytes for each element of.


yeah it really just seems a bit messy to me, because I want to end up with 8 * 8 * 8 cube and once I have that I want the sizes to be user adjustable, so making for if statements to loop around and get everything in the right place for a dynamic grid size would be time consuming I'm just looking for an easier way, thanks for your response though.

mm… even though the size of the grid is dynamic why would it be necessary to move everything around when the user changes the size of the grid? You could just map the array's 1-1-1 sphere to world coordinates 1-1-1 etc - so that each element's world location matches its array position and you are set.



If the array's size changes and you want to keep it centered or whatever, you can just move the camera, not the spheres themselves… keeping the grid centered if necessary.



Can you perhaps explain how it works in your imagination… otherwise it is hard to even understand how it could be more simple :slight_smile:

ok I'm not sure I understand your post, can you give me an example? Thanks

Nevermind, I misunderstood you. I thought you wanted to have the number of elements in the grid adjustable. 8x8x8 to 10x10x10 etc.



I have no good method of just changing the size of the grid.

Maybe an ArrayList or hashtable is what you are after.



If you can decribe what the world is how how you can interact with it, you may get an appropiate response.

ok then the way it's all going down is the grid has randomly colored spheres on it and you click on the spheres to get rid of them then at a time interval the grid/cube rotates to present a fresh grid the size of the grid is adjustable so there can be more or less spheres on it

This to me is state transition.



Maybe you can think of each element in the array as an object that describes the sphere.



Something like



GridedObject

  • Colour colour
  • int position
  • Spatial sphere



    If you want to animate a switch of several spheres, you simply animate the switch and at the end change the position. The sphere's translation will also be updated.

sounds interesting, I'm not sure how easy it will be to change the grid size though. I might give it a go unless someone can come up with something better, thanks for your help.