Change order of for loops?

realpower

New Member
I have a situation where i need to loop though xyz coordinates in different orders depending on a users input. So i an area in 3D space then a set of for loops like so.\[code\]for(int x = 0; x < build.getWidth(); x++){ for(int y = 0; y < build.getHeight(); y++){ for(int z = 0; z < build.getLength(); z++){ //do stuff } } }\[/code\]but depending on the users input, the order may be like this.\[code\]for(int z = 0; z < build.getLenght(); z++){ for(int y = 0; y < build.getHeight(); y++){ for(int x = 0; x < build.getWidth(); x++){ //do stuff } } }\[/code\]or even negative.\[code\]for(int x = build.getWidth(); x > 0; x--){ for(int y = 0; y < build.getHeight(); y++){ for(int z = 0; z < build.getLength(); z++){ //do stuff } }}\[/code\]Is there any way to do this without hard coding every case?
 
Back
Top