sidebar features
sidebar content

Go Back   Blender Artists Forums > General Forums > Python & Plugins

Reply
 
Thread Tools
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Download newest version:

TerryNoise requires ScriptUI (a Blender GUI API wrapper).
See: http://elysiun.com/forum/viewtopic.php?t=46231#473268

----
History:

I have TerryNoise ported to blender 2.3x!

Update:
Made some very little improvements.

Update:
Joined Klopes code which uses normals. But I don't create a copy of the origial mesh. You can use Ctrl+Z in Object mode or U in Edit mode to make the manipulations undone.
I forgot: I added a custom Noise: you can enter a short function, using functions from pythons math and Blenders Bleder.Noise moduls.

Update:
Fixed: If update onchange was deactivated, the custom functins didn't get updated!

Update:
Merged more of Klopes Code and speed improvements! maybe there are more possible! (have to read into the blender python API...)
WARNIG: Save and Load dose not work correctly yet and the other code is also not fully tested (after the merge).

Update:
Save/Load works now.

Update:
Removed unnecessary vertex v2 copy in function simple(v,v2,h).
Made it now final. Well I don't know what to add/improve else. (And I don't have the time to.)

Update:
Refactored the whole code. Functionallity (and hopefully speed, too) ist exactly the same than in the old version, but the code is MUCH more reuseable and clean (mayby still can by improved). It's also more code, so I splitted it up into 4 files (TerryNoise.py, TerryNoiseSupport.py, ScriptUI.py, TerryUI.py). I don't like blenders way to handle events (signals and slots, pelase!), so I wrapped it a little.

I hope I didn't overlook a bug.
So, what do you all think about this new version? How do you like the new concepts?

I poste the old version on my blog too, so you still can download it, if you like it better.
TerryNoise 1.0
TerryNoise 1.1

Update to version 1.2 (01.07.2005):
  • ADD: new noise-function "image". use it to deform a mesh by a heightmap painted in a pixelmanipulating program. this feature needs PIL (python image library) installed to work. (thanks Jimmy Haze, creator of A.N.T. to inspire me)
    FIX: seed was unused!
    FIX: update buttons on load
    FIX: removed forgotten debug code (printed all verts positions on redraw)
    FIX: copy rotation, size and location from base-mesh
    DOC: added documentation and license information

TerryNoise 1.2

Update to version 1.2a (02.07.2005):
  • FIX: set HAS_PIL according to the availability of PIL
    FIX: use o.makeDisplayList() so TerryNoise works correct on subsurfed meshes (thanks to tedi)
    DOC: corrected version informatin in the .py files

TerryNoise 1.2a

Update to version 1.3 (24.07.2005):
Changelog:
  • port to ScriptUI 0.5
    changed file format (incompatible with old, but more independent from the GUI)
    ADD: added noise-preview
    FIX: imageNoise

I ported TerryNoise to my new version of ScriptUI (zip, 21KB). This needed a almost whol rewirite of TerryNoise (again), but I think the code is much cleaner now.

I changed the file format, so now it's not any longer dependent on the sorting of the noisfunction-menu. But this means your old TerryNoise files do not longer work, sorry about that. (I'm to lazy to write a convertor.)

Futher I added a noise-preview!

Download:
TerryNoise 1.3 (zip, 823KB)
TerryNoise 1.3 without documentation (zip, 25KB)

Update to version 1.3.1 (27.07.2005):
Changelog:
  • port to ScriptUI 0.6.1
    when psyco (http://psyco.sf.net/) is available, compile the whole script. needs a bit longer to load but should be faster afterwards.
    changed fileformat again: I use now pythons ConfigParser interface so your TerryNoise files are human readable.
    restructured TerryNoise: TerryNoise, TerryNoise.UI, TerryNoise.Support
    ADD: toggle-button to disable preview

Download:
#1   Old 22-Feb-05, 02:09   
Reply With Quote


akator's Avatar
akator akator is offline
Member
 
Join Date: Oct 2003
Posts: 658
Quote:
Originally Posted by panzi
I have TerryNoise ported to blender 2.3x!
Here is rc1:
What is TerryNoise? What does it do?
#2   Old 22-Feb-05, 02:13   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
TerryNoise was a GUI to the dynoise plugin/lib/whatever. See: http://www.iespana.es/klopes/enchufes.htm

This version of TerryNois is a GUI to the Blender.Noise module. You can create terrains and stuff with it.
#3   Old 22-Feb-05, 02:37   
Reply With Quote
Fligh's Avatar
Fligh Fligh is offline
Moderator
 
Join Date: Dec 2002
Location: US
Posts: 9,916
Very nice Panzi. I like the included helpfile that changes with each combination of functions.

%<
............................................
BLENDER - You'll get it when you get it.
#4   Old 22-Feb-05, 02:50   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Quote:
Originally Posted by Fligh %
Very nice Panzi. I like the included helpfile that changes with each combination of functions.

%<
Thanks.

It's actually no "included helpfile", its just the pydoc of the functions. (e.g. Blender.Noise.random.__doc__ without the first two lines)
#5   Old 22-Feb-05, 03:00   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Two examples:

#6   Old 22-Feb-05, 03:47   
Reply With Quote
Gabio's Avatar
Gabio Gabio is offline
Moderator
 
Join Date: Nov 2003
Location: Canada - Québec - Sherbrooke
Posts: 2,195
Here if you can't see anything.(and maybe copy and past)
http://fs6.deviantart.com/i/2005/052...s_by_panzi.png
http://fs6.deviantart.com/i/2005/052...n_by_panzi.png
............................................
Venez nous voir au Québec, on est pas sorteux!
#7   Old 22-Feb-05, 04:13   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Strange broken links....
But these should work:
http://www.deviantart.com/view/15405775/
http://www.deviantart.com/view/15405876/

btw.: I improved the script a little. See first posting.
#8   Old 22-Feb-05, 14:00   
Reply With Quote
tedi tedi is offline
Member
 
Join Date: Jul 2002
Posts: 1,558
hi panzi. here's what i did (quite some time ago). this (233) version didn't quite adequate recreate what it did with the dynoise.dll. that said, i touched up the original klopes version which worked better with dynoise.dll - up to blender 232. hope it helps you somehow, i didn't touch scripting in about half a year.

Code:
#!BPY """ Registration info for Blender menus: Name: 'Terry Noise' Blender: 233 Group: 'Misc' Tip: 'Dynoise terrain generator' """ import Blender from Blender import Noise from Blender.Noise import* from Blender.BGL import* from Blender.Draw import* FUNC = Create(0) octaves = Create(3) soft = Create(0) lacunarity = Create(5.) offset = Create(0.) H = Create(1.5) otro = Create(1.) seed = Create(1) Lx = Create(0.) Ly = Create(0.) Lz = Create(0.) Sx = Create(1.) Sy = Create(1.) Sz = Create(1.) activa = Create(0) old = Create(0) def Trans (v): x, y, z = v x2 = (x + Lx.val) * Sx.val + (0.8 * random()) y2 = (y + Ly.val) * Sy.val + (0.8 * random()) z2 = (z + Lz.val) * Sz.val + (0.8 * random()) return x2, y2, z2 def Guidraw (): glClearColor (0.7, 0.7, 0.7, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f (0.1, 0.1, 0.1) def Argu (f, a): Arguments = ['00000', '00000', '00100', '11100', '11100', '11110', '11110', '11110', '00101', '00000'] return int(Arguments[f - 1][a]) def Itface (): Guidraw() global Lx, Ly, Lz, Sx, Sy, Sz global FUNC, activa, old, seed global H, lacunarity, octaves, offset, soft, otro global functions Lx = Number ("Lx", 2, 180, 130, 60, 18, Lx.val, -1000., 1000.) Ly = Number ("Ly", 2, 180, 110, 60, 18, Ly.val, -1000., 1000.) Lz = Number ("Lz", 2, 180, 90, 60, 18, Lz.val, -1000., 1000.) Sx = Number ("Sx", 2, 180, 70, 60, 18, Sx.val, -100., 100.) Sy = Number ("Sy", 2, 180, 50, 60, 18, Sy.val, -100., 100.) Sz = Number ("Sz", 2, 180, 30, 60, 18, Sz.val, -100., 100.) Button ("Refresh", 2, 120, 140, 50, 20, "Update object") functions = ['cellNoise', 'noise', 'vlNoise', 'fBm', 'multiFractal', 'heteroTerrain', 'hybridMFractal', 'ridgedMFractal', 'turbulence'] menuText = '' for i in range(len(functions)): menuText += '|' + functions[i] + '%x' + str(i + 1) seed = Number ("Seed :", 2, 20, 140, 100, 20, seed.val, 0, 10000) FUNC = Menu ("DYN functions %t" + menuText, 2, 20, 120, 100, 20, FUNC.val, "Noise functions") F = FUNC.val if Argu (F, 0): H = Slider ("XyzFrac: ", 2, 20, 100, 150, 18, H.val, 0.0, 2.0, activa.val, "Fractal dimension") if Argu (F, 1): lacunarity = Slider ("Lacun: ", 2, 20, 80, 150, 18, lacunarity.val, 0., 10., activa.val, "Lacunarity") if Argu (F, 2): octaves = Number ("Octaves: ", 2, 20, 60, 150, 18, octaves.val, 1, 8, "Octaves") if Argu (F, 3): offset = Slider ("Offset: ", 2, 20, 40, 150, 18, offset.val, -1., 2., activa.val, "Displacement") if Argu (F, 4): soft = Toggle ("Soft/Hard: ", 2, 20, 20, 150, 18, soft.val) if F in [7, 8]: otro = Slider ("Glacia: ", 2, 20, 20, 150, 18, otro.val, .0, 2.0, activa.val, "Escalation") if F == 3: otro = Slider ("Distortion: ", 2, 20, 100, 150, 18, otro.val, .0, 5.0, activa.val) glRasterPos2i (10, 200) Text("TERRYNOISE [ for blender 233 ]") glRasterPos2i (10, 185) Text ("Terrain generator", 'small') glRasterPos2i (10, 170) Text("DYNOISE GUI") activa = Toggle ("V", 98, 136, 120, 17, 20, activa.val, 'Cont') old = Toggle ("G", 98, 153, 120, 17, 20, old.val, 'Orig') def event (evt, val): if (evt == ESCKEY or evt == QKEY and not val): Exit() def bevent (evt): try: o = Blender.Object.GetSelected()[0] m = o.getData() n = m.name if old.val: n += '.DyNoised' Blender.NMesh.GetRaw(n) except: name = "NO MESH SELECTED %t| cancel" result = Blender.Draw.PupMenu(name) if result: Exit() return if evt == 2: Noise.setRandomSeed(seed.val) F = FUNC.val print "\n%d DOCUMENTATION:\n" % F, (getattr (Noise, functions[F - 1])).__doc__ for v in m.verts: i = m.verts.index(v) calc = 1 if 'DYNOISE' in m.getVertGroupNames(): t = m.getVertsFromGroup ('DYNOISE', 1, [i]) if t: w = t[0][1] else: calc = 0 else: w = 1. if not calc: continue P = Trans((v.co[0], v.co[1], 0.)) if F == 0: h = 0 elif F in [1, 2]: h = getattr (Noise, functions[F - 1])(P) elif F == 3: h = getattr (Noise, functions[F - 1]) (P, otro.val, octaves.val, 1) elif F in [4, 5]: h = getattr (Noise, functions[F - 1]) (P, H.val, lacunarity.val, octaves.val, otro.val) elif F == 6: h = getattr (Noise, functions[F - 1]) (P, H.val, lacunarity.val, octaves.val, offset.val, 2) elif F in [7, 8]: h = getattr (Noise, functions[F - 1]) (P, H.val, lacunarity.val, octaves.val, offset.val, otro.val, 2) elif F == 9: h = getattr (Noise, functions[F - 1]) (P, octaves.val, soft.val, 2, 1, 1) v.co[2] = w * h Blender.NMesh.PutRaw (m, n) o.makeDisplayList() Blender.Redraw() Register (Itface, event, bevent)
#9   Old 22-Feb-05, 14:28   
Reply With Quote
klopes's Avatar
klopes klopes is offline
Member
 
Join Date: May 2002
Location: Zaragoza (Spain)
Posts: 111
HELLS, I LOVE this script! What a great work, guys. But I'm just working on a version to affect the normals, instead of always the poor z coord... It's harder because there's to do an "original" copy of the mesh and prevent the user to make modifications on it. It's continuosly crashing!

Stay tuned!
............................................
-----------
Klópes
#10   Old 22-Feb-05, 15:35   
Reply With Quote
klopes's Avatar
klopes klopes is offline
Member
 
Join Date: May 2002
Location: Zaragoza (Spain)
Posts: 111
Select objetcs and make Alt+P.
If you want to change the objects selection, do it and press INIT
Now it affects to normals. Make potatoes and planets!
New feature: 'Mult' is a influence factor to prevent fool vertices.
You can modify the base mesh, then press 'Refresh'

Comments!

By the way, I don't know how to name this version (?????) how is named an original script by me, modified by Mathias and retouched by me again?
%|
Code:
#!BPY # vim:encoding=utf-8 """ Name: 'TerryNoise' Blender: 232 Group: 'Mesh' Tooltip: 'TerryNoise (Blender.Noise GUI)' """ __author__ = "original by Klopes, adaption by Mathias Panzenböck" __version__ = "1.0.0-rc2" __bpydoc__ = """\ This script is a frontend to most of the Blender.Noise functions. It is based on the old TerryNoise script from here: http://www.iespana.es/klopes/enchufes.htm """ import Blender from Blender.BGL import * from Blender.Draw import * from Blender.Noise import * import string # buttons: FUNC = Create(0) ntype1 = Create(0) ntype2 = Create(0) octaves = Create(3) hard = Create(0) lacunarity = Create(5.) disortion = Create(1.) offset = Create(0.) H = Create(1.5) gain = Create(1.) ampscale = Create(0.5) freqscale = Create(2.0) seed = Create(0) Multi = Create(1.) Lx = Create(0.) Ly = Create(0.) Lz = Create(0.) Sx = Create(1.) Sy = Create(1.) Sz = Create(1.) activ = Create(0) initev = Create(0) def init(): global obs obs=[] for o in Blender.Object.GetSelected(): m=o.getData() Blender.NMesh.PutRaw(m,m.name[:17]+'.tn') obs.append(o) # noise functions: functions = { 'cellNoise': (lambda P: cellNoise( P ), [], string.split( cellNoise.__doc__, "\n" )[2:] ), 'fBm': (lambda P: fBm( P, H.val, lacunarity.val, octaves.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'type1'], string.split( fBm.__doc__, "\n" )[2:] ), 'heteroTerrain': (lambda P: heteroTerrain( P, H.val, lacunarity.val, octaves.val, offset.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'type1'], string.split( heteroTerrain.__doc__, "\n" )[2:] ), 'hybridMFractal': (lambda P: hybridMFractal( P, H.val, lacunarity.val, octaves.val, offset.val, gain.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'gain', 'type1'], string.split( hybridMFractal.__doc__, "\n" )[2:] ), 'multiFractal': (lambda P: multiFractal( P, H.val, lacunarity.val, octaves.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'type1'], string.split( multiFractal.__doc__, "\n" )[2:] ), 'noise': (lambda P: noise(P, ntype1.val), ['type1'], string.split( noise.__doc__, "\n" )[2:] ), 'random': (lambda P: random(), [], string.split( random.__doc__, "\n" )[2:] ), 'ridgedMFractal': (lambda P: ridgedMFractal( P, H.val, lacunarity.val, octaves.val, offset.val, gain.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'gain', 'type1'], string.split( ridgedMFractal.__doc__, "\n" )[2:] ), 'turbulence': (lambda P: turbulence( P, octaves.val, hard.val, ntype1.val, ampscale.val, freqscale.val ), ['octaves', 'hard', 'type1', 'ampscale', 'freqscale'], string.split( turbulence.__doc__, "\n" )[2:] ), 'vlNoise': (lambda P: vlNoise(P, disortion.val, ntype1.val, ntype2.val), ['disortion', 'type1','type2'], string.split( vlNoise.__doc__, "\n" )[2:] ) } # noise types: ntypes = { 'VORONOI_CRACKLE': 8, 'STDPERLIN': 1, 'VORONOI_F3': 5, 'VORONOI_F2': 4, 'VORONOI_F4': 6, 'VORONOI_F1': 3, 'VORONOI_F2F1': 7, 'CELLNOISE': 14, 'NEWPERLIN': 2, 'BLENDER': 0 } ntypesText = string.join( [ '|' + itm[0] + '%x' + str( itm[1] ) for itm in ntypes.items() ], '' ) # layout things: start_top = 173 big_width = 200 sml_width = 130 height = 18 left = 20 xx_left = left + big_width + 10 xx_width = 70 # button generators: def mkH(bottom): global H H = Slider( "Fract: ", 2,left,bottom,big_width,height, H.val, .0,2., activ.val, "the fractal increment parameter" ) def mklacunarity(bottom): global lacunarity lacunarity = Slider( "Lacunarity: ",2,left,bottom,big_width,height, lacunarity.val,0.0,10., activ.val, "the gap between successive frequencies" ) def mkdisortion(bottom): global disortion disortion = Slider( "Disortion: ",2,left,bottom,big_width,height, disortion.val,0.,10., activ.val, "the amount of distortion" ) def mkoctaves(bottom): global octaves octaves = Number( "Octaves:", 2,left,bottom,big_width,height, octaves.val,1,8, "the number of frequencies in the fBm" ) def mkoffset(bottom): global offset offset = Slider( "Offset: ", 2,left,bottom,big_width,height, offset.val, -1.,1., activ.val, "it raises the terrain from 'sea level'" ) def mkhard(bottom): global hard hard = Toggle( "Hard", 2,left,bottom,big_width,height, hard.val, "noise hardness" ) def mkgain(bottom): global gain gain = Slider( "Gain: ", 2,left,bottom,big_width,height, gain.val,.0,20.,activ.val, "scale factor" ) def mkampscale(bottom): global ampscale ampscale = Slider( "AmpScale: ", 2, left, bottom, big_width, height, ampscale.val, .0, 25., activ.val, "amplitude scale value of the noise frequencies added" ) def mkfreqscale(bottom): global freqscale freqscale = Slider( "FreqScale: ", 2, left, bottom, big_width, height, freqscale.val, .0, 25., activ.val, "amplitude scale value of the noise frequencies added" ) def mktype1(bottom): global ntype1 ntype1 = Menu( "Noisetype1%t" + ntypesText, 2,left,bottom,big_width,height, ntype1.val ) def mktype2(bottom): global ntype2 ntype2 = Menu( "Noisetype2%t" + ntypesText, 2,left,bottom,big_width,height, ntype2.val ) # button map: mkbuttons = { 'H': mkH, 'lacunarity': mklacunarity, 'disortion': mkdisortion, 'octaves': mkoctaves, 'offset': mkoffset, 'hard': mkhard, 'gain': mkgain, 'type1': mktype1, 'type2': mktype2, 'ampscale': mkampscale, 'freqscale': mkfreqscale } def Trans(v): x, y, z = v x2 = (x + Lx.val) * Sx.val y2 = (y + Ly.val) * Sy.val z2 = (z + Lz.val) * Sz.val return x2, y2, z2 def terrynoise(): global Lx, Ly, Lz, Sx, Sy, Sz, Multi global FUNC, activ, initev, seed global H, lacunarity, octaves, offset, hard, gain global functions, mkbuttons, ntypes Multi = Number( "Mult", 2, xx_left, 150, xx_width, 18, Multi.val, -10., 10.,"Influence factor") Lx = Number( "Lx", 2, xx_left, 130, xx_width, 18, Lx.val, -1000., 1000.) Ly = Number( "Ly", 2, xx_left, 110, xx_width, 18, Ly.val, -1000., 1000.) Lz = Number( "Lz", 2, xx_left, 90, xx_width, 18, Lz.val, -1000., 1000.) Sx = Number( "Sx", 2, xx_left, 70, xx_width, 18, Sx.val, -100., 100. ) Sy = Number( "Sy", 2, xx_left, 50, xx_width, 18, Sy.val, -100., 100. ) Sz = Number( "Sz", 2, xx_left, 30, xx_width, 18, Sz.val, -100., 100. ) Button( "Refresh", 2, left + sml_width + 4, start_top, 50, height, "refresh objects" ) Button( "Exit", 3, xx_left, start_top, xx_width, height, "exit TerryNoise" ) activ = Toggle( "R", 98, left + big_width - 17, start_top , 17, height, activ.val, 'realtime slider changes' ) initev = PushButton( "Init", 4, left + big_width - 50, start_top - height, 34, height, 'Restore meshes' ) seed = Number( "Seed:", 2, 20, start_top, sml_width, height, seed.val, 0, 10000, "he seed for the random number generator. If seed = 0, the current time will be used as seed, instead." ) menuText = "Function%t" i = 0 for key in functions.keys(): menuText += '|' + key + '%x' + str(i) i += 1 FUNC = Menu( menuText, 2, 20, start_top - height, sml_width, height, FUNC.val, "the noise-functions" ) bottom = start_top - height - 5 for param in functions.items()[ FUNC.val ][ 1 ][ 1 ]: bottom -= (height + 2) mkbuttons[ param ]( bottom ) lines = functions.items()[ FUNC.val ][ 1 ][ 2 ] pos = start_top + len(lines) * 15 + 30 for line in lines: glRasterPos2i( left, pos ) Text( line, 'small' ) pos -= 15 def event(evt, value): if (evt == ESCKEY and not value): Exit() def bevent(evt): if evt == 4: init() if evt == 3: Exit() elif evt == 2: for o in obs: m = o.getData() n = m.name n2 = n[:17] + '.tn' m2=Blender.NMesh.GetRaw( n ) setRandomSeed( seed.val ) for v2 in m2.verts: i = m2.verts.index( v2 ) v = m.verts[i] calc = 1 if 'DYNOISE' in m.getVertGroupNames(): t = m.getVertsFromGroup( 'DYNOISE', 1, [ i ] ) if t: w = t[ 0 ][ 1 ] else: calc = 0 else: w = 1. if not calc: continue P = Trans( (v.co[0], v.co[1], 0.) ) h = functions.items()[ FUNC.val ][ 1 ][ 0 ]( P ) for c in range(3): v2.co[c] = v.co[c] + v.no[c] * w * h * Multi.val Blender.NMesh.PutRaw( m2, n2 ) Blender.Redraw() init() Register(terrynoise,event,bevent)
............................................
-----------
Klópes
#11   Old 22-Feb-05, 16:23   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Quote:
Originally Posted by klopes
HELLS, I LOVE this script! What a great work, guys. But I'm just working on a version to affect the normals, instead of always the poor z coord... It's harder because there's to do an "original" copy of the mesh and prevent the user to make modifications on it. It's continuosly crashing!

Stay tuned!
Well, I'm actually a total n00b to this stuff (3D modeling and blender python API), so I don't know how to manipulate the normals. I don't even know what all part's of "my" (Klopes') script do.
#12   Old 22-Feb-05, 16:23   
Reply With Quote
klopes's Avatar
klopes klopes is offline
Member
 
Join Date: May 2002
Location: Zaragoza (Spain)
Posts: 111

Boooo...!
............................................
-----------
Klópes
#13   Old 22-Feb-05, 17:17   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
I made some changes, see my first posting in this thread.
#14   Old 22-Feb-05, 18:37   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
@Klopes
As I said, I'm a Blender API n00b.
So can you tell me what this code dose?

Code:
i = m.verts.index( v ) calc = 1 if 'DYNOISE' in m.getVertGroupNames(): t = m.getVertsFromGroup( 'DYNOISE', 1, [ i ] ) if t: w = t[ 0 ][ 1 ] else: calc = 0 else: w = 1. if not calc: continue
#15   Old 22-Feb-05, 19:14   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Two more example pics:
http://www.deviantart.com/deviation/15424249/
http://www.deviantart.com/deviation/15424281/
#16   Old 22-Feb-05, 19:20   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Another example:

CustomNoise: sin(x) * sin(y) + cellNoise( (x,y,z) ) * 0.7
Size Y: 0.7
(ohter values: default)

http://www.deviantart.com/deviation/15425084/
#17   Old 22-Feb-05, 19:47   
Reply With Quote
klopes's Avatar
klopes klopes is offline
Member
 
Join Date: May 2002
Location: Zaragoza (Spain)
Posts: 111
No guy! You're adding in each refreshing:
Code:
v.co[ c ] += v.no[ c ] * h
while you must always consider the initial mesh (freeze) and summing the calculus always to it:
Code:
v.co[c] = v2.co[c] + v2.no[c] * w * h * Multi.val
(here v2 are frezzed-base vertices, and v are the new ones)

By the way, answering:
Code:
i = m.verts.index( v ) calc = 1 if 'DYNOISE' in m.getVertGroupNames(): t = m.getVertsFromGroup( 'DYNOISE', 1, [ i ] ) if t: w = t[ 0 ][ 1 ] else: calc = 0 else: w = 1.
As you can read at the docs, you can define a vertexgroup mamed 'DYNOISE'... or not. If you do then the script consider only the vertices in it, by their weights in the group ('w' variable). If you don't, all vertices are affected as even (w=1).

Code:
if not calc: continue
In the case a vertex is not in 'DYNOISE' group (and this one exists), the script exits the bucle.
............................................
-----------
Klópes
#18   Old 23-Feb-05, 08:50   
Reply With Quote
klopes's Avatar
klopes klopes is offline
Member
 
Join Date: May 2002
Location: Zaragoza (Spain)
Posts: 111
Mat, great addition the custom function!
'MakeCopy' button is obsotele because now IS neccesary such copy (the 'base')

Code:
#!BPY # vim:encoding=utf-8 """ Name: 'TerryNoise' Blender: 232 Group: 'Mesh' Tooltip: 'TerryNoise (Blender.Noise GUI)' """ __author__ = "original by Klopes, adaption by Mathias Panzenböck" __version__ = "1.0.0-rc1" __bpydoc__ = """\ This script is a frontend to most of the Blender.Noise functions. It is based on the old TerryNoise script from here: http://www.iespana.es/klopes/enchufes.htm """ import Blender from Blender.BGL import * from Blender.Draw import * from Blender.Noise import * import string from math import * # buttons: FUNC = Create(0) args = Create(".5, 2, .8") custom = Create("sin(x)*sin(y*args[0])*args[1]+random()*args[2]") ntype1 = Create(0) ntype2 = Create(0) axis = Create(2) octaves = Create(3) hard = Create(0) lacunarity = Create(5.) disortion = Create(1.) offset = Create(0.) H = Create(1.5) gain = Create(1.) ampscale = Create(0.5) freqscale = Create(2.0) seed = Create(0) how = Create(1) amount = Create(1.) Lx = Create(0.) Ly = Create(0.) Lz = Create(0.) Sx = Create(1.) Sy = Create(1.) Sz = Create(1.) activ = Create(0) initev = Create(0) customFunct = eval( "lambda x, y, z, args: " + custom.val ) customArgs = eval( "[" + args.val + "]" ) def init(): global obs obs=[] for o in Blender.Object.GetSelected(): m=o.getData() Blender.NMesh.PutRaw(m,m.name[:17]+'.tn') obs.append(o) def customNoise(P): return customFunct( P[0], P[1], P[2], customArgs ) # noise functions: functions = { 'cellNoise': (lambda P: cellNoise( P ), [], string.split( cellNoise.__doc__, "\n" )[2:] ), 'fBm': (lambda P: fBm( P, H.val, lacunarity.val, octaves.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'type1'], string.split( fBm.__doc__, "\n" )[2:] ), 'heteroTerrain': (lambda P: heteroTerrain( P, H.val, lacunarity.val, octaves.val, offset.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'type1'], string.split( heteroTerrain.__doc__, "\n" )[2:] ), 'hybridMFractal': (lambda P: hybridMFractal( P, H.val, lacunarity.val, octaves.val, offset.val, gain.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'gain', 'type1'], string.split( hybridMFractal.__doc__, "\n" )[2:] ), 'multiFractal': (lambda P: multiFractal( P, H.val, lacunarity.val, octaves.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'type1'], string.split( multiFractal.__doc__, "\n" )[2:] ), 'noise': (lambda P: noise(P, ntype1.val), ['type1'], string.split( noise.__doc__, "\n" )[2:] ), 'random': (lambda P: random(), [], string.split( random.__doc__, "\n" )[2:] ), 'ridgedMFractal': (lambda P: ridgedMFractal( P, H.val, lacunarity.val, octaves.val, offset.val, gain.val, ntype1.val ), ['H', 'lacunarity', 'octaves', 'offset', 'gain', 'type1'], string.split( ridgedMFractal.__doc__, "\n" )[2:] ), 'turbulence': (lambda P: turbulence( P, octaves.val, hard.val, ntype1.val, ampscale.val, freqscale.val ), ['octaves', 'hard', 'type1', 'ampscale', 'freqscale'], string.split( turbulence.__doc__, "\n" )[2:] ), 'vlNoise': (lambda P: vlNoise(P, disortion.val, ntype1.val, ntype2.val), ['disortion', 'type1','type2'], string.split( vlNoise.__doc__, "\n" )[2:] ), '(custom)': (lambda P: customNoise(P), ['custom'], [ 'returns custom value.', 'Arguments is a comma seperated list of arguments, passed to your custom noise function.', 'Noise is your custom noise function. You can use any possible python lambda-expression.', 'Futher you can use all functions within the module math, Blender and Blender.Noise.']) } # noise types: ntypes = { 'VORONOI_CRACKLE': 8, 'STDPERLIN': 1, 'VORONOI_F3': 5, 'VORONOI_F2': 4, 'VORONOI_F4': 6, 'VORONOI_F1': 3, 'VORONOI_F2F1': 7, 'CELLNOISE': 14, 'NEWPERLIN': 2, 'BLENDER': 0 } ntypesText = string.join( [ '|' + itm[0] + '%x' + str( itm[1] ) for itm in ntypes.items() ], '' ) # layout things: start_top = 213 big_width = 200 sml_width = 128 height = 18 left = 20 xx_left = left + big_width + 10 xx_width = 110 # button generators: def mkH(bottom): global H H = Slider( "Fract: ", 2,left,bottom,big_width,height, H.val, .0,2., activ.val, "the fractal increment parameter" ) return height def mklacunarity(bottom): global lacunarity lacunarity = Slider( "Lacunarity: ",2,left,bottom,big_width,height, lacunarity.val,0.,10., activ.val, "the gap between successive frequencies" ) return height def mkdisortion(bottom): global disortion disortion = Slider( "Disortion: ",2,left,bottom,big_width,height, disortion.val,0.,10., activ.val, "the amount of distortion" ) return height def mkoctaves(bottom): global octaves octaves = Number( "Octaves:", 2,left,bottom,big_width,height, octaves.val,1,8, "the number of frequencies in the fBm" ) return height def mkoffset(bottom): global offset offset = Slider( "Offset: ", 2,left,bottom,big_width,height, offset.val, -1.,1., activ.val, "it raises the terrain from 'sea level'" ) return height def mkhard(bottom): global hard hard = Toggle( "Hard", 2,left,bottom,big_width,height, hard.val, "noise hardness" ) return height def mkgain(bottom): global gain gain = Slider( "Gain: ", 2,left,bottom,big_width,height, gain.val,.0,20.,activ.val, "scale factor" ) return height def mkampscale(bottom): global ampscale ampscale = Slider( "AmpScale: ", 2, left, bottom, big_width, height, ampscale.val, .0, 25., activ.val, "amplitude scale value of the noise frequencies added" ) return height def mkfreqscale(bottom): global freqscale freqscale = Slider( "FreqScale: ", 2, left, bottom, big_width, height, freqscale.val, .0, 25., activ.val, "amplitude scale value of the noise frequencies added" ) return height def mktype1(bottom): global ntype1 ntype1 = Menu( "Noisetype1%t" + ntypesText, 2,left,bottom,big_width,height, ntype1.val, "nosie type 1" ) return height def mktype2(bottom): global ntype2 ntype2 = Menu( "Noisetype2%t" + ntypesText, 2,left,bottom,big_width,height, ntype2.val, "noise type 2" ) return height def mkcustom(bottom): global custom, args args = String( "Arguments: ", 5, left, bottom, big_width, height, args.val, 512, "Enter a Argumentlist. (e.g. 5, .06, 'a')" ) custom = String( "Noise: ", 6, left, bottom - height - 2 ,big_width,height, custom.val, 512, "Enter a custom noise function. Parameters are: x=float, y=float, z=float, args=[]" ) return height * 2 + 2 # button map: mkbuttons = { 'H': mkH, 'lacunarity': mklacunarity, 'disortion': mkdisortion, 'octaves': mkoctaves, 'offset': mkoffset, 'hard': mkhard, 'gain': mkgain, 'type1': mktype1, 'type2': mktype2, 'ampscale': mkampscale, 'freqscale': mkfreqscale, 'custom': mkcustom } def Trans(v): x, y, z = v x2 = (x + Lx.val) * Sx.val y2 = (y + Ly.val) * Sy.val z2 = (z + Lz.val) * Sz.val return x2, y2, z2 def terrynoise(): global Lx, Ly, Lz, Sx, Sy, Sz global FUNC, activ, initev, seed, axis global H, lacunarity, octaves, offset, hard, gain global functions, mkbuttons, ntypes, how, amount amount = Number( "Amount" , 2, xx_left, 150, xx_width, 18, amount.val, -10., 10., "Factor") Lx = Number( "Lx", 2, xx_left, 130, xx_width, 18, Lx.val, -1000., 1000.) Ly = Number( "Ly", 2, xx_left, 110, xx_width, 18, Ly.val, -1000., 1000.) Lz = Number( "Lz", 2, xx_left, 90, xx_width, 18, Lz.val, -1000., 1000.) Sx = Number( "Sx", 2, xx_left, 70, xx_width, 18, Sx.val, -100., 100. ) Sy = Number( "Sy", 2, xx_left, 50, xx_width, 18, Sy.val, -100., 100. ) Sz = Number( "Sz", 2, xx_left, 30, xx_width, 18, Sz.val, -100., 100. ) Button( "Refresh", 2, left + sml_width + 4, start_top, 50, height, "refresh objects" ) Button( "Exit", 3, xx_left, start_top, xx_width, height, "exit TerryNoise" ) how = Menu( "How%t|Simple%x0|Along Normales%x1", 2, xx_left, start_top - height, xx_width, height, how.val, "how the noise affects the mesh" ) if how.val == 0: axis = Menu( "Affected Axis%t|X%x0|Y%x1|Z%x2", 2, xx_left, start_top - 2 * height, xx_width, height, axis.val, "affected axis" ) activ = Toggle( "R", 98, left + big_width - 17, start_top , 17, height, activ.val, 'realtime slider changes' ) initev = PushButton( "Init", 4, left + big_width - 50, start_top - height, 34, height, 'Restore meshes and consider selected objects' ) seed = Number( "Seed:", 2, 20, start_top, sml_width, height, seed.val, 0, 10000, "he seed for the random number generator. If seed = 0, the current time will be used as seed, instead." ) menuText = "Function%t" i = 0 for key in functions.keys(): menuText += '|' + key + '%x' + str(i) i += 1 FUNC = Menu( menuText, 2, 20, start_top - height, sml_width, height, FUNC.val, "the noise-functions" ) bottom = start_top - (2 * height) - 7 for param in functions.items()[ FUNC.val ][ 1 ][ 1 ]: bottom -= (mkbuttons[ param ]( bottom ) + 2) lines = functions.items()[ FUNC.val ][ 1 ][ 2 ] pos = start_top + len(lines) * 15 + 30 for line in lines: glRasterPos2i( left, pos ) Text( line, 'small' ) pos -= 15 def event(evt, value): if (evt == ESCKEY and not value): Exit() def alongnormales(v,v2,h): for c in range(3): v.co[c] = v2.co[c] + v2.no[c] * h def simple(v,v2,h): v[:]=v2[:] v.co[ axis.val ] = h def bevent(evt): try: if evt == 5: global customArgs customArgs = eval( "[" + args.val + "]" ) print customArgs elif evt == 6: global customFunct print "\nlambda x, y, z, args: " + custom.val + "\n" customFunct = eval( "lambda x, y, z, args: " + custom.val ) except: PupMenu( "Syntax error! Check your code." ) return if evt == 4: init() if evt == 3: Exit() elif evt == 2: if how.val == 1: # alongnormales donoise = alongnormales trans = Trans else: # simple donoise = simple if axis.val == 0: # X trans = lambda v: Trans( (0., v.co[1], v.co[2]) ) elif axis.val == 1: # Y trans = lambda v: Trans( (v.co[0], 0., v.co[2]) ) else: # Z trans = lambda v: Trans( (v.co[0], v.co[1], 0.) ) for o in obs: m = o.getData() n = m.name n2 = n[:17] + '.tn' m2=Blender.NMesh.GetRaw( n ) setRandomSeed( seed.val ) for v2 in m2.verts: i = m2.verts.index( v2 ) v = m.verts[i] calc = 1 if 'DYNOISE' in m.getVertGroupNames(): t = m.getVertsFromGroup( 'DYNOISE', 1, [ i ] ) if t: w = t[ 0 ][ 1 ] else: calc = 0 else: w = 1. if not calc: continue P = Trans( (v.co[0], v.co[1], 0.) ) funct = functions.items()[ FUNC.val ][ 1 ][ 0 ] for c in range(3): # v.co[c] = v2.co[c] + v2.no[c] * w * funct( P ) * amount.val donoise( v2, v, w * funct( trans( v ) ) * amount.val ) Blender.NMesh.PutRaw( m2, n2 ) Blender.Redraw() init() Register(terrynoise,event,bevent)
............................................
-----------
Klópes
#19   Old 23-Feb-05, 11:52   
Reply With Quote
panzi panzi is offline
Member
 
Join Date: Feb 2005
Posts: 413
Updates, updates, updates!
See first posting.
#20   Old 23-Feb-05, 14:51   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 11:17.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists