A.N.T. Landscape creator

Please do, this script is terrific, I use it all the time. Working to make some nice materials too. :smiley:

Here’s one I’ve been working on:

http://img50.exs.cx/img50/619/gobi3zh.th.jpg

:slight_smile: Nice image Bijin.

And this is the ‘Basic’ version, only the basic functions.


#!BPY

"""
Name: 'Landscape Basic'
Blender: 234
Group: 'Add'
"""


##########################################################################
##        : A.N.T.(Another Noise Tool) Landscape 'Basic'
##        : Jimmy Hazevoet 
##        : Jan. 2005
##########################################################################
## Only the basic Noise and Height parameters.
##########################################################################

import Blender
from Blender import *
from Blender.Noise import *
from math import sqrt
from Blender.Draw import *
from Blender.BGL import *

### Initialize  ----------------------------------
#-------------------------------------------------
MEName         = "LandscapeName" #= Landscape Mesh Name ( ME:LandscapeName )
Auto_Update     = Create(1)     #= Automatic mesh update
Quality         = Create(2)     #= Quality menu
resolution      = Create(50)    #= Manual Mesh resolution, n*n
Q_T             = Create(0)     #= Quads or Triangles
smooth          = Create(0)     #= Set Smooth
FalTyp          = Create(1)     #= Falloff type
plev            = Create(1.0)   #= Plateau level
slev            = Create(-1.0)  #= Sealevel
offset          = Create(0.0)   #= Z Offset
iScale          = Create(0.1)   #= Noise Height
NSize           = Create(0.25)  #= Noise Size
Sx              = Create(1.0)   #= Noise SizeX
Sy              = Create(1.0)   #= Noise SizeY
Lx              = Create(0.0)   #= Noise Loc.X
Ly              = Create(0.0)   #= Noise Loc.Y
Noise_Type      = Create(0)     #= Noise Type's
Noise_Basis     = Create(0)     #= Noise Basis Type's
Oc              = Create(2.0)   #= Octaves
La              = Create(2.0)   #= Lacunarity
Ha              = Create(1.0)   #= H
Ga              = Create(1.0)   #= Gain
Of              = Create(1.0)   #= Offset
Depth           = Create(2)     #= Turbulence Depth
Hard            = Create(0)     #= Soft/Hard
Amp             = Create(0.5)   #= Ampscale
Freq            = Create(2.0)   #= Freqscale
Distortion_Noise=Create(0)      #= DistortionNoise
Damnt           = Create(1.0)   #= Distortion amount
VFunc           = Create(0)     #= Voronoi DistanceMetrics type
VExp            = Create(2.5)   #= Exponent MINKOVSKI
VDep            = Create(0)     #= Depth

#--------------------------------
### Reset ----------------------------------
#------------------------------
def reset():
   global Auto_Update, Quality, resolution, Q_T, smooth
   global FalTyp, NSize, iScale, offset, slev, plev
   global Noise_Type, Noise_Basis, Distortion_Noise, Damnt, VFunc, VExp, VDep
   global Ha, La, Oc, Of, Ga, Depth, Hard, Amp, Freq, Lx, Ly, Sx, Sy

   Auto_Update = Create(1)
   Quality     = Create(2)
   resolution  = Create(50)
   Q_T         = Create(0)
   smooth      = Create(0)
   FalTyp = Create(1)
   plev   = Create(1.0)
   slev   = Create(-1.0)
   offset   = Create(0.0)
   iScale = Create(0.1)
   NSize  = Create(0.25)
   Sx     = Create(1.0)
   Sy     = Create(1.0)
   Lx     = Create(0.0)
   Ly     = Create(0.0)
   Noise_Type  = Create(0)
   Noise_Basis = Create(0)
   Oc = Create(2.0)
   La = Create(2.0)
   Ha = Create(1.0)
   Ga = Create(1.0)
   Of = Create(1.0)
   Depth = Create(2)
   Hard  = Create(0)
   Amp   = Create(0.5)
   Freq  = Create(2.0)
   Distortion_Noise = Create(0)
   Damnt = Create(1.0)
   VFunc = Create(0)
   VExp  = Create(2.5)
   VDep  = Create(0)

#--------------------------------
## Noise --------------------------------------------------------
###-----------------------------------
def Noise_func(x,y,z):
   global NSize, Sx, Sy, Lx, Ly, Noise_Type, Noise_Basis
   global Distortion_Noise, Damnt, VFunc, VExp, VDep
   global Ha, La, Oc, Of, Ga, Depth, Hard, Amp, Freq

   ## Size and Position ##
   x1 = (x / Sx.val + Lx.val) / NSize.val
   y1 = (y / Sy.val + Ly.val) / NSize.val
   z1 = 0

   Basis = Noise_Basis.val
   if Basis == 9:   Basis = 14   ## 9=14 : Noise Basis 'CellNoise' !? ##

   if Noise_Type.val < 5:
      ha = Ha.val
      la = La.val 
      oc = Oc.val
      of = Of.val
      ga = Ga.val
      if Noise_Type.val == 0:
         z = multiFractal((x1,y1,z1),ha, la, oc, Basis)
      elif Noise_Type.val == 1:
         z = ridgedMFractal((x1,y1,z1),ha, la, oc, of, ga, Basis)
      elif Noise_Type.val == 2:
         z = hybridMFractal((x1,y1,z1),ha, la, oc, of, ga, Basis)
      elif Noise_Type.val == 3:
         z = heteroTerrain((x1,y1,z1),ha, la, oc, of, Basis)
      elif Noise_Type.val == 4:
         z = fBm((x1,y1,z1),ha, la, oc, Basis)
   elif Noise_Type.val == 5:
      z = turbulence((x1,y1,z1),1+Depth.val, Hard.val, Basis,Amp.val,Freq.val)
   elif Noise_Type.val == 6:
      z = voronoi((x1,y1,z1),VFunc.val,VExp.val)[0][VDep.val]
   elif Noise_Type.val == 7:
      vlBasis = Distortion_Noise.val
      if vlBasis == 9:   vlBasis = 14
      distortion = Damnt.val
      z = vlNoise((x1,y1,z1), distortion, vlBasis, Basis)

   return x,y,z

#--------------------------------
## Height --------------------------------------------------------
###-----------------------------------
def Height(x,y,z):
   global iScale, offset, FalTyp, slev, plev

   Nfunc = Noise_func(x,y,z)

   height = Nfunc[2] * (iScale.val/2) + offset.val

   if FalTyp.val != 0:    # falloff type
      if   FalTyp.val == 1:   dist = sqrt( (x*x)**2 + (y*y)**2 )
      elif FalTyp.val == 2:   dist = sqrt( (x*x + y*y) )
      elif FalTyp.val == 3:   dist = sqrt( (x*x)**4 + (y*y)**4 )
      elif FalTyp.val == 4:   dist = sqrt(y*y)
      elif FalTyp.val == 5:   dist = sqrt(x*x)

      radius = 1.0        # falloff
      if( dist <  radius ):
         dist = dist / radius
         dist = ( (dist) * (dist) * ( 3-2*(dist) ) )
         z = ( height - height * dist )
      else:
         z = 0.0
   else:
      z = height

   sealevel = slev.val
   plateau  = plev.val
   if (z < sealevel):  z = sealevel
   if (z > plateau):   z = plateau

   return x,y,z

#--------------------------------
## Mesh -----------------------------------------------------------
###-----------------------------------
def Crea():
   global MEName, Quality, resolution, Q_T, smooth

   if   Quality.val == 0:   n = 16+1
   elif Quality.val == 1:   n = 32+1
   elif Quality.val == 2:   n = 64+1
   elif Quality.val == 3:   n = 128+1
   elif Quality.val == 4:   n = 256+1
   else:                    n = resolution.val+1

   me = NMesh.GetRaw()
   #-----------------------------------
   i=j=h=0.0
   for i in range(0, n, 1):
      i = i-(n-1)/2
      i = i*2.0/(n-1)
      for j in range(0, n, 1):
         j = j-(n-1)/2
         j = j*2.0/(n-1)
         Result = Height(i, j, h)
         h = Result[2]
         v=NMesh.Vert(i, j, h)
         me.verts.append(v)

   ### Triangles -------------------------------------
   if Q_T.val == 1:
      for i in range(n-1):
         for j in range(n-1):
            f = NMesh.Face()
            f.v.append(me.verts[n*i+j])
            f.v.append(me.verts[n*i+(j+1)])
            f.v.append(me.verts[n*(i+1)+j])
            f.smooth = smooth.val
            me.faces.append(f)
            f = NMesh.Face()
            f.v.append(me.verts[n*i+(j+1)])
            f.v.append(me.verts[n*(i+1)+(j+1)])
            f.v.append(me.verts[n*(i+1)+j])
            f.smooth = smooth.val
            me.faces.append(f)
   #### Quads ---------------------------------------
   else:
      for i in range(n-1):
         for j in range(n-1):
            f= NMesh.Face()
            f.v.append(me.verts[i*n+j])
            f.v.append(me.verts[i*n+j+1])
            f.v.append(me.verts[(i+1)*n+j+1])
            f.v.append(me.verts[(i+1)*n+j])
            f.smooth = smooth.val
            me.faces.append(f)

   NMesh.PutRaw(me, MEName, 1)

#--------------------------------
## G.U.I. -----------------------------------------------------------
###-----------------------------------
def GUI():
   global Auto_Update, Quality, resolution, Q_T, smooth
   global NSize, iScale, FalTyp, offset, Lx, Ly, Sx, Sy, slev, plev
   global Noise_Type, Noise_Basis, Distortion_Noise, Damnt, VFunc, VExp, VDep
   global Ha, La, Oc, Of, Ga, Depth, Hard, Amp, Freq

   BGL.glClearColor(0.66, 0.66, 0.66, 1)
   BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
   glColor3f(0.73,0.73,0.73)
   glRecti(5, 5, 265, 200)
   glColor3f(0.61,0.61,0.61)
   glRecti(5, 200, 265, 218)
   glColor3f(1.0,1.0,1.0)
   glRasterPos2d(18, 206)
   Text("Landscape 'Basic'",'small')

   ntype  = "Noise Type's %t|multiFractal %x0|ridgedMFractal %x1|hybridMFractal %x2|heteroTerrain %x3|fBm %x4|turbulence %x5|Voronoi %x6|DistortedNoise %x7"
   Noise_Type = Menu(ntype,102,10,50,120,20, Noise_Type.val, "Noise Type")
   nbasis = "Noise Basis%t|Blender Original%x0|Original Perlin%x1|Improved Perlin%x2|Voronoi_F1%x3|Voronoi_F2%x4|Voronoi_F3%x5|Voronoi_F4%x6|Voronoi_F2-F1%x7|Voronoi Crackle%x8|CellNoise%x9"
   if Noise_Type.val == 6:
      Vf  = "Voronoi%t|Distance %x0|Distance Squared %x1|Manhattan %x2|Chebychev %x3|Minkovsky 1/2 %x4|Minkovsky 4 %x5|Minkovsky %x6"
      VFunc = Menu(Vf, 102, 10,70,120,15, VFunc.val)
   else:
      Noise_Basis = Menu(nbasis,102,10,70, 120, 15, Noise_Basis.val, "Noise Basis")
   if Noise_Type.val < 5:
         Oc    = Slider("Octs: ", 102, 10,180,120,15, Oc.val,0.0,8.0 ,0)
         La    = Slider("Lacu: ", 102, 10,165,120,15, La.val,0.0,6.0 ,0)
         Ha    = Slider("H: ", 102, 10,150,120,15, Ha.val,0.0,2.0 ,0)
         if Noise_Type.val == 1:
            Of = Slider("Ofs: ", 102, 10,135,120,15, Of.val,0.0,6.0 ,0)
            Ga = Slider("Gain: ", 102, 10,120,120,15, Ga.val,0.0,6.0 ,0)
         elif Noise_Type.val == 2:
            Of = Slider("Ofs: ", 102, 10,135,120,15, Of.val,0.0,6.0 ,0)
            Ga = Slider("Gain: ", 102, 10,120,120,15, Ga.val,0.0,6.0 ,0)
         elif Noise_Type.val == 3:
            Of = Slider("Ofs: ", 102, 10,135,120,15, Of.val,0.0,6.0 ,0)
   elif Noise_Type.val == 5:
         Hard  = Toggle("Soft / Hard", 102, 10,180,120,15,Hard.val)
         Amp   = Number("Amp.: ", 102,10,165,120,15,Amp.val,0.0,10.0)
         Freq  = Number("Freq.: ", 102,10,150,120,15,Freq.val,0.0,10.0)
         Depth = Number("Depth: ", 102,10,135,120,15,Depth.val,0.0,10.0)
   elif Noise_Type.val == 6:
         VDep    = Number("Depth:",102,10,180,120,15,VDep.val,0,3)
         if (VFunc.val == 6):
            VExp = Number("Exp.: ",102,10,165,120,15,VExp.val,0.0,10.0)
   elif Noise_Type.val == 7:
         Distortion_Noise = Menu(nbasis ,102,10,165,120,15, Distortion_Noise.val, "Distortion Noise")
         Damnt            = Number("Distortion: ",102,10, 180, 120, 15, Damnt.val, 0.0,10.0)

   NSize = Number("NoiseSize: ",102,140,70, 120, 20, NSize.val, 0.001, 10.0)
   Sx    = Number("x",102,140,90,60,15,Sx.val,0.001,2.0,"Size X")
   Sy    = Number("y",102,200,90,60,15,Sy.val,0.001,2.0,"Size Y")
   Lx    = Number("x",102,140,50,60,15,Lx.val,-1000.0,1000.0,"Position X")
   Ly    = Number("y",102,200,50,60,15,Ly.val,-1000.0,1000.0,"Position Y")
   iScale = Number("iScale: ",102,140, 110, 120, 20, iScale.val, -2.0,2.0)
   offset = Number("Offset: ",102,140,130,120,15,offset.val,-2.0,2.0)
   plev   = Number("Plateau:",102,140,165,120,15,plev.val, slev.val,1.0)
   slev   = Number("Sealevel:",102,140,150,120,15,slev.val, -1.0,plev.val)
   falmnu = "Falloff type's %t|None %x0|Default %x1|Rounded %x2|Squared %x3|Linear y %x4|Linear x %x5"
   FalTyp = Menu(falmnu,102,140,180,120,15, FalTyp.val, "Edge falloff")

   resmnu = "Mesh Quality%t|16 %x0|32 %x1|64 %x2|128 %x3|256 %x4|Manual %x5"
   if Quality.val == 5:
      resolution = Number(":",102,140,25,60,15, resolution.val, 2,512,"Mesh resolution ( n*n )")
      Quality = Menu(resmnu,102,200,25,60,15, Quality.val, "Mesh Quality")
   else:
      Quality = Menu(resmnu,102,140,25,120,15, Quality.val, "Mesh Quality")
   if Q_T.val == 0: qtext ="Quads"
   elif Q_T.val == 1: qtext ="Triangles"
   Q_T = Toggle(qtext,102,200,10,60,15,Q_T.val,"Faces : Quads or Triangles")
   if smooth.val == 0: stext ="Solid"
   elif smooth.val == 1: stext ="Smooth"
   smooth = Toggle(stext,102,140,10,60,15,smooth.val,"Faces : Set Smooth / Set Solid")

   Auto_Update = Toggle("A",105,112,10,18,30, Auto_Update.val,"Automatic mesh update.")
   Button("Update", 103, 10, 10, 102, 30,"Update mesh.")
   Button("X", 999, 245, 202, 15, 15,"Reset / Exit")

###-----------------------------------
def event(evt, val):
   if (evt== ESCKEY and not val):
      Exit()
###-----------------------------------
def bevent(evt):
   global Auto_Update

   if   (evt== 999):
      name = "OK ?%t|Exit %x1|Reset %x2"
      result = Blender.Draw.PupMenu(name)
      if result == 2:
         if Auto_Update.val == 1:
            reset()
            do_it()
         if Auto_Update.val == 0:
            reset()
            Draw()
      if result == 1:
         Exit()

   if (evt == 103):
      do_it()
   if Auto_Update.val == 1:
      if (evt == 102):
         do_it()
   elif Auto_Update.val == 0:
      if (evt == 102):
         Draw()

###-----------------------------------
def do_it():
   Blender.Window.WaitCursor(1)
   Crea()
   Blender.Window.WaitCursor(0)
   Redraw()

Register(GUI, event, bevent)

You mean this is the same as the previous release, only without fx? (trying to figure out why you posted it, maybe someone asked?)

It’s just a simplified version, for those who like it simple. :wink:
did you see the updated version on page one ?

Kewl script, man:)

Really nice work on this one :smiley: Was just playing with it for a short while. I’ll definitely be using it next time I need some landscapes :smiley:

Absolutely totally cool and right on time! Thanks you so much.

Wow, this is really an improvement. I was really happy to see the cliff preset (for some reason) :slight_smile:

Thanks for sharing your hard work, JH!

See the final update, much better presets,

Nice script … well laid out … lots to play with … lots of variations … nice GUI.

Here is a quick test render:

http://img198.exs.cx/img198/2033/grassydunes9pc.th.jpg

The grass is generated with a very old ‘Grass_Gen.py’ by Ripsting,
made some copy’s of the grass, changed position,size and rotation of the grass a little bit,
and used Harkyman’s ‘Drop2Ground.py’(flip normals of landscape first)

Yes, this is a very nice script. It’s definitly a must have in the Blender arsenal.

Holy crap that’s gotta be over 3 years old… :o

If you could add a ‘makeDisplayList()’ anywhere to update the subsurfacing of the Landscape, it will be perfect for me. :wink:

… and to have the ‘normal’ in the right side, just replace lines 589 to 615 with:


   ### Triangles -------------------------------------
   if Q_T.val == 1:
      for i in range(n-1):
         for j in range(n-1):
            f = NMesh.Face()
            f.v.append(me.verts[n*i+j])
            f.v.append(me.verts[n*(i+1)+j])
            f.v.append(me.verts[n*i+(j+1)])
            f.smooth = smooth.val
            me.faces.append(f)
            f = NMesh.Face()
            f.v.append(me.verts[n*i+(j+1)])
            f.v.append(me.verts[n*(i+1)+j])
            f.v.append(me.verts[n*(i+1)+(j+1)])
            f.smooth = smooth.val
            me.faces.append(f)
   #### Quads ---------------------------------------
   else:
      for i in range(n-1):
         for j in range(n-1):
            f= NMesh.Face()
            f.v.append(me.verts[i*n+j])
            f.v.append(me.verts[(i+1)*n+j])
            f.v.append(me.verts[(i+1)*n+j+1])
            f.v.append(me.verts[i*n+j+1])
            f.smooth = smooth.val
            me.faces.append(f)

++
ph

Great work on the script

It would be a more then worthy additon to the blender scripts arsenal

Loads of uses for this, it reminds me of something cinema 4d has, only, this has a lot more options and flexibility

awsome

greets

Great script. Testing it now.

I have to second harkyman’s post regarding the GUI. Just great to see it layed out and explained so well.

BgDM

[quote=“Ph”]

If you could add a ‘makeDisplayList()’ anywhere to update the subsurfacing of the Landscape, it will be perfect for me. :wink:

… and to have the ‘normal’ in the right side, just replace lines 589 to 615 with:


   ### Triangles -------------------------------------
   if Q_T.val == 1:
      for i in range(n-1):
         for j in range(n-1):
            f = NMesh.Face()
            f.v.append(me.verts[n*i+j])
            f.v.append(me.verts[n*(i+1)+j])
            f.v.append(me.verts[n*i+(j+1)])
            f.smooth = smooth.val
            me.faces.append(f)
            f = NMesh.Face()
            f.v.append(me.verts[n*i+(j+1)])
            f.v.append(me.verts[n*(i+1)+j])
            f.v.append(me.verts[n*(i+1)+(j+1)])
            f.smooth = smooth.val
            me.faces.append(f)
   #### Quads ---------------------------------------
   else:
      for i in range(n-1):
         for j in range(n-1):
            f= NMesh.Face()
            f.v.append(me.verts[i*n+j])
            f.v.append(me.verts[(i+1)*n+j])
            f.v.append(me.verts[(i+1)*n+j+1])
            f.v.append(me.verts[i*n+j+1])
            f.smooth = smooth.val
            me.faces.append(f)

++
ph[/quote]

Thank’s for the tips PH , i have updated the script.

( There will never be any ‘final’ update again.)

Thank’s, this realy make’s me happy. :smiley:

But actualy i think that lots of stuff in my script can be done better,
so if someone can HELP me with :

_ Mesh/Object/Material handling
_ better and more ‘naturalistic’ filters and effects
_ better collorband preview
_ good presets

and if you have other ideas let me know… thank’s

I do have another idea. But first I wanted to say this script is great and it has only gotten better and better. That said on to my idea. I used to use various grey scale images includeing some I got from terragen raw renders. I then loaded these into Blender and used noise to create a landscape. I think it would be cool if you could load in something like that , (grey scale images )generate a basic starting landscape and then further manipulate it with your choices in your script. I don’t know how hard this would be to do or if it is even practical but I thought I would mention it as it would help to make this an even more complete landscape program. Even so, as it stands now I find it very useful and as soon as I finish some things I’m working on, I’ll be going back to creating landscapes again.
Paradox
PS if you click on my web site icon and go to my landscape page you can see a couple of old examples I did. I took others out to make room for new ones and never put anymore back in. I plan on using your script and all the new tools of blender (lighting ect) to fill it back up again.