- Home /
Question by
Yog0 · Feb 18, 2014 at 06:20 PM ·
gridproceduralvoxelvolume
How to fill a volume with a procedurally generated 3d voxel grid?
I'm trying to make a script that takes a cube, raycasts out of each face, and instantiates it until the ray collides with something.
I've been playing around with generating voxel grids from a boolean array, as in this question, but I can't quite figure out how to generate the grid to fill a space.
The basic grid code:
var voxelArray : boolean[,,] = new boolean[10,10,10];
var cube : GameObject;
function Start()
{
for(var z=0;z<10;z++) {
for(var y=0;y<10;y++) {
for(var x=0;x<10;x++) {
voxelArray[x,y,z] = true;
var temp = Instantiate(cube,Vector3(x,y,z),Quaternion.identity);
temp.name = "voxel"+x+y+z;
}}}
Comment
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Draw object on 2d line? 0 Answers
Infinite 2D placement grid 1 Answer
What is wrong with this mesh editing code? 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers