[Closed] how to store grid(Perlin Noise)?
Hi,
I’m trying to do the perlin noise. I’ve read this and this about perlin noise and I think I get it.
But I have a problem with step 1 of Perlin Noise, which is the grid definision. For each grid I need to assign a gradient vector of unit length. But how can I store these values?
I think that math representation of the grid is a matrix. And accoriding to help maxscript, there is a matrix3 which is a matrix 4×3. And that is pretty lowres.
What if I want to use some 64x64x64 grid? Can this be done in maxscript or do I need to do this in c++ (just guessing, I’ve just started with c++)?
Any help would be great!
Well, you can always make your own datastructure, let’s say
struct gridDef
(
xCount, yCount, zCount,
x = for i = 1 to xCount collect normalize (random [-1,-1,-1] [1,1,1]),
y = for i = 1 to yCount collect normalize (random [-1,-1,-1] [1,1,1]),
z = for i = 1 to zCount collect normalize (random [-1,-1,-1] [1,1,1])
)
grid64 = gridDef xCount:64 yCount:64 zCount:64
Thanks! This looks very promising! I didn’t know about structures before and I will give it a try
Oops, obviously.
struct gridDef
(
private data = #(),
public xCount, yCount, zCount,
fn getVoxel x y z =
if x <= xCount AND y <= yCount AND z <= zCount do
data[x + xCount * (y - 1) + (xCount * yCount) * (z - 1)],
on create do
for x = 1 to xCount do
for y = 1 to yCount do
for z = 1 to zCount do
append data (normalize (random [-1,-1,-1] [1,1,1]))
)
grid64 = gridDef xCount:64 yCount:64 zCount:64
-- grid64.getVoxel 10 15 30