Пример #1
0
	def run(self):
	  
	 #  	perlin = Perlin(12345)
		# frac = FractalNoise(h=1.0, lacunarity=50.0, octaves=4.2, noise=perlin )

		self._perlin_data = []

		z = 0.5

		octaves = 6

		scale = 2 * octaves

		ls3 = 10 * octaves

		ls2 = 15 * octaves

		ls = 20 * octaves

		for x in range(self._x_start, self._x_end):
		  for y in xrange(self._size):
		    value = _perlin.noise3(float(x) / ls, float(y) / ls, z, octaves, 0.5)#, base=0)

		    if value > 0.8 or value < 0:
		      value = -1
		    else:
		      value += _perlin.noise3(float(x) / scale, float(y) / scale, z, octaves, 0.5)#, base=0)
		  
		      value += _perlin.noise3(float(x) / ls2, float(y) / ls2, z, octaves, 0.5)#, base=0)

		      value += _perlin.noise3(float(x) / ls3, float(y) / ls3, z, octaves, 0.5)#, base=0)
			
		    value = value * 127.0 + 128.0
		    self._perlin_data += [value, value, value, 1.0] 
Пример #2
0
    def _get_noise(self, pos):
        # noise
        x = pos.x
        y = pos.y
        z = pos.z

        #first_scale = 8 * self._octaves

        # h = self._planet_root.max_height * self._planet_root.noise.ridged_multi_fractal3(p.x, p.y, p.z, 0.0, 1.0)
        
        #frac = self._noise.ridged_multi_fractal3(x / first_scale, y / first_scale, z / first_scale, -0.1, 1.0)
        #frac += self._noise.turbulance3(x / first_scale, y / first_scale, z / first_scale)

        # data.append( perlin.noise3( v.x, v.y, v.z) * 255.0 )
        # data.append( self._noise.brownian_motion3( v.x, v.y, v.z) * 255.0 )
        # data.append( ( (self._noise.ridged_multi_fractal3(v.x, v.y, v.z, -0.1, 1.0) + 1.0) / 2.0) * 255.0 )

        # frac = self._noise.ridged_multi_fractal3(v.x / first_scale, v.y / first_scale, v.z / first_scale, -0.1, 1.0)
        
        # frac += self._noise.turbulance3(v.x / first_scale, v.y / first_scale, v.z / first_scale)
        
        #frac = pnoise3(v.x / first_scale, v.y / first_scale, v.z / first_scale)#, octaves=4)
        #frac += pnoise3(v.x / second_scale, v.y / second_scale, v.z / second_scale)#, octaves=4 )

        #frac += pnoise3(v.x / second_scale, v.y / second_scale, v.z / second_scale, octaves=4 )

        #height = ( frac * 127.0 ) + 128.0

        octaves = 6.0

        ioct = int(octaves)
        scale = 2 * octaves
        ls3 = 10 * octaves
        ls2 = 15 * octaves
        ls = 20 * octaves

        value = _perlin.noise3(x / ls, y / ls, z / ls, ioct, 0.5)#, base=0)

        if value > 0.8 or value < 0:
          value = -1
        # else:
        # if value < -0.8:
        #   value = -1
        else:
          value += _perlin.noise3(x / scale, y / scale, z / scale, ioct, 0.5)#, base=0)      
          value += _perlin.noise3(x / ls2,   y / ls2,   z / ls2,   ioct, 0.5)#, base=0)
          value += _perlin.noise3(x / ls3,   y / ls3,   z / ls3,   ioct, 0.5)#, base=0)
        
        frac = value
        #print frac
        return frac
Пример #3
0
  def single_threaded_image(self):
    
    # perlin = Perlin(12345)
    # frac = FractalNoise(h=1.0, lacunarity=50.0, octaves=4.2, noise=perlin )

    perlin_data = []

    x = 0#self._image_size

    octaves = 6.0
    ioct = int(octaves)

    scale = 2 * octaves

    ls3 = 10 * octaves

    ls2 = 15 * octaves

    ls = 20 * octaves

    for y in xrange(self._image_size):
      for z in xrange(self._image_size):
        #value = ( (perlin.noise3(float(x) / scale, float(y) / scale, z) * 127.0) + 128.0)
        # value = pnoise3(float(x) / scale, float(y) / scale, z) * 127.0 + 128.0
        # value = snoise3(float(x) / scale, float(y) / scale, z) * 127.0 + 128.0
        # value = perlin.noise3(x,y,z)

        #value = frac.ridged_multi_fractal3(float(x) / scale, float(y) / scale, z, 0, 1.0)

        #value = snoise3(float(x) / scale, float(y) / scale, z)

        #value = _simplex.noise3(float(x) / scale, float(y) / scale, z, 32, 1.0)#, base=0)
      
        ######
        # value = _perlin.noise3(float(x) / ls, float(y) / ls, z / ls, octaves, 0.5)#, base=0)

        # if value > 0.8 or value < 0:
        #   value = -1
        # else:
        #   value += _perlin.noise3(float(x) / scale, float(y) / scale, z / ls, octaves, 0.5)#, base=0)
      
        #   value += _perlin.noise3(float(x) / ls2, float(y) / ls2, z / ls, octaves, 0.5)#, base=0)

        #   value += _perlin.noise3(float(x) / ls3, float(y) / ls3, z / ls, octaves, 0.5)#, base=0)
        ####

        value = _perlin.noise3(x / ls, y / ls, z / ls, ioct, 0.5)#, base=0)

        if value > 0.8 or value < 0:
          value = -1
        else:
          value += _perlin.noise3(x / scale, y / scale, z / scale, ioct, 0.5)#, base=0)
          value += _perlin.noise3(x / ls2, y / ls2, z / ls2, ioct, 0.5)#, base=0)
          value += _perlin.noise3(x / ls3, y / ls3, z / ls2, ioct, 0.5)#, base=0)


        # value *= 1000
        #print value
        #value = max(min(value, 0.6), 0.4)

        # value += math.cos(x + value)

        # value *= 20
        # value = value - int(value)

        #value += frac.ridged_multi_fractal3(float(x) / scale, float(y) / scale, z, 0, 1.0)

        value = value * 127.0 + 128.0
        perlin_data += [value, value, value, 1.0] 

    return perlin_data   
Пример #4
0
    def process_image_section(out_queue, pr):

        perlin_data = []
        octaves = 6.0
        scale = 2 * octaves
        ls3 = 10 * octaves
        ls2 = 15 * octaves
        ls = 20 * octaves

        # If the FRONT or BACK
        if pr.face == 4 or pr.face == 1:
            z = pr.zstart
            x_start = pr.x_start
            x_end = pr.x_end
            y_end = pr.y_end

            for x in range(x_start, x_end):
              for y in xrange(y_end):

                value = _perlin.noise3(x / ls, y / ls, z / ls, octaves, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls2, octaves, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                perlin_data += [value, value, value, 1.0] 

        # if the TOP or BOTTOM
        elif pr.face == 0 or pr.face == 3:
            y = pr.ystart

            x_start = pr.x_start
            x_end = pr.x_end
            z_end = pr.z_end

            for x in range(x_start, x_end):
              for z in xrange(z_end):

                value = _perlin.noise3(x / ls, y / ls, z, octaves, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls3, octaves, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                perlin_data += [value, value, value, 1.0]


        # if the RIGHT or LEFT
        elif pr.face == 2 or pr.face == 5:
            x = pr.xstart

            y_end  = pr.y_end
            z_start = pr.z_start
            z_end = pr.z_end

            for z in range(z_start, z_end):
              for y in xrange(y_end):

                value = _perlin.noise3(x / ls, y / ls, z, octaves, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, octaves, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls3, octaves, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                perlin_data += [value, value, value, 1.0]
                
        out_queue.put([face, pos, perlin_data] )
Пример #5
0
    def __call__(self):

        octaves = 6.0
        ioct = int(octaves)
        scale = 2 * octaves
        ls3 = 10 * octaves
        ls2 = 15 * octaves
        ls = 20 * octaves

        # If the FRONT or BACK
        if self._pr.face == 4 or self._pr.face == 1:
            z = self._pr.z_start
            x_start = self._pr.x_start
            x_end = self._pr.x_end
            y_end = self._pr.y_end

            for x in range(x_start, x_end):
              for y in xrange(y_end):

                value = _perlin.noise3(x / ls, y / ls, z / ls, ioct, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls2, ioct, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                self._perlin_data += [value, value, value, 1.0] 

        # if the TOP or BOTTOM
        elif self._pr.face == 0 or self._pr.face == 3:
            y = self._pr.y_start

            x_start = self._pr.x_start
            x_end = self._pr.x_end
            z_end = self._pr.z_end

            for x in range(x_start, x_end):
              for z in xrange(z_end):

                value = _perlin.noise3(x / ls, y / ls, z / ls, ioct, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls3, ioct, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                self._perlin_data += [value, value, value, 1.0]


        # if the RIGHT or LEFT
        elif self._pr.face == 2 or self._pr.face == 5:
            x = self._pr.x_start

            y_end  = self._pr.y_end
            z_start = self._pr.z_start
            z_end = self._pr.z_end

            for z in range(z_start, z_end):
              for y in xrange(y_end):

                value = _perlin.noise3(x / ls, y / ls, z / ls, ioct, 0.5)#, base=0)

                if value > 0.8 or value < 0:
                  value = -1
                else:
                  value += _perlin.noise3(x / scale, y / scale, z / scale, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls2, y / ls2, z / ls2, ioct, 0.5)#, base=0)
                  value += _perlin.noise3(x / ls3, y / ls3, z / ls3, ioct, 0.5)#, base=0)

                value = value * 127.0 + 128.0
                self._perlin_data += [value, value, value, 1.0]
                
        return [self._pr.face, self._pr.pos, self._perlin_data]