There are many ways to control the LEDs.
You could have 513 wires the computer (aka pinouts), 1 ground 512 control. Another method is called multiplexing, this technique also used in LED matrixs (like the kind you see on scrolling led signs).
With multiplexing, you can greatly reduce the number of pins needed to control each led individually, but you have to flash the leds individually, not in a group, but in a sequence. The sequence happens so fast, that our brain perceives this happening at once. The concept is called "Persistance of VIsion" and its what makes movies look like moving pictures, rather than a series of still images.
Im working on a 64 led cube (4x4x4), I could build it with 65 wires, but that would be more than an arduino can handle.
Ok, so if you use multiplexing you can actually multiplex in a variety of ways. I chose to break my cube up into 16 columns and 4 planes which requires 20 pinouts (16 columns, plus 4 planes = 20), which is exactly how many an arduino has, so the way i have it setup. I could have also set it up as 8 by 8 matrix, its the same number of LEDs, but that arrangement uses 8 positive, and 8 negative, totalling 16 pinouts.
Now things get really gooey, there is this thing called charlieplexing. Charlieplexing, named after a dude named charlie, is a method of getting even more complex, but also reducing the pinouts required to control large numbers of LEDS. In the case of my 4x4x4 cube, I think I need a total of 9 pinouts to control all 64 LEDs! Its actually quite the clever little trick that only works with LEDs.
Those are all ways of controlling many leds, with few control lines. but there is more...
There are components called shift registers, they are ICs that convert serial to parallel, and vice verse. They come in sizes like 8, 16,32,64, bit, and they can be chained together to create huge large registers, for controlling many many pinouts, each 8 bit chip is 8 pinouts, all of these pinouts are controlled by 3 pintouts on the microcontroller (its sending the data in serial, then the shift register delivers in parallel.)
Now, if thats not complex enough for you, there are special chips that are kinda like fancy shift registers, that have all the good stuff LEDs like in one package, and those are called LED drivers.
OK, so... If you are going to try to control 512 LEDs, you will need some shift registers or LED drivers multiplexing and charlieplexing will not be enough, you will probably want multiplexing and shift registers.
I just converted my cube over from 20 pins to about 8 or 9 wires, but I havent tried it out yet.
heres a good start:
http://www.instructables.com/id/Led-Cube-8x8x8/ it was the first link when I googled 8x8x8 led cube arduino