Perlin noise .noise(x,y) method

Hello, I’ve been playing around with the perlin noise generation for making height field maps for a game I’d like to make. I had been using perlinNoiseFill() to make a heightfield but the size is a bit of an issue

I heard that it is possible to make it continuous if use the same object on the points you want. So I had a look at the .noise(x,y) method. This seems to be what I want but my real question is what do I do with the values I get? I get a number between -1 and 1 but I’m not sure where to go from there Am I meant to multiply it by something to make them numbers I can fill an image with (like perlinNoiseFill) or do they have some other purpose.

Thanks for the help

EDIT: occasionally I get a value under -1 like -1.32103050487

Don’t worry I got it working now I did this:

``````p = self.perlin.noise(x+self.offsetx,y+self.offsety)
if p >= 0:
p*=127.5
self.n.setRedVal(x,y,p)
self.n.setGreenVal(x,y,p)
self.n.setBlueVal(x,y,p)``````

I’m not sure if that’s the right way but it works ok.

By the way, if anyone wants to make connecting terrain chunks with the panda3d perlin noise, here is some of my code for doing it (it may not be the best way though )

``````class FPS(object,DirectObject):
name = -1
chunkposx = 0
chunkposy = 0
chunksize = 1025
chunks = []
chunks1 = []
offsetx = 0
offsety = 0
perlin = PerlinNoise2(500,500)``````

This is my function to make a chunk:

``````    def makeChunk(self):
self.n = PNMImage(self.chunksize,self.chunksize)
self.offsety -=self.chunksize
for y in xrange(self.chunksize):
for x in xrange(self.chunksize):
p = self.perlin.noise(x+self.offsetx,y+self.offsety)
if p >= 0:
p*=127.5
self.n.setRedVal(x,y,p)
self.n.setGreenVal(x,y,p)
self.n.setBlueVal(x,y,p)
self.n.makeGrayscale()
self.name+=1
name1 = str(self.name)
self.n.write(name1+".png")
#GeoMipTerrain Stuff
terrain = GeoMipTerrain(name1)
terrain.setHeightfield(self.n)
terrain.setBlockSize(128)
terrain.setNear(256)
terrain.setFar(512)
terrain.setMinLevel(2)
terrain.setFocalPoint(base.camera)
root = terrain.getRoot()
root.reparentTo(render)
root.setSz(100)
self.scaleZ = root.getSz()
terrain.setAutoFlatten(GeoMipTerrain.AFMStrong)
terrain.generate()
ts = TextureStage("ts0")
root.setLight(self.plnp)
root.setLight(self.alnp)
root.setPos(self.chunkposx,self.chunkposy,0)
self.chunks.append(terrain)
self.chunks1.append(root)``````

To calculate when a new chunk is needed, I have not quite finished (at the moment it works in one direction)
I check to see if the player’s position is greater than half the length of the chunk and make a new if that is true.

Hope that helps, I found the sources on perlin noise pretty confusing so hopefully someone will find this ^ useful.

EDIT: just remembered for some reason it should be chunks instead of self.chunks. (make them global in def init(self) because:

``for i in self.chunks:``

gives an error saying self is not defined. The same with self.chunks1