-
Hello,
Has anybody successfully created a 1-dimensional perlin number generator
in actionscript? I had built one in Lingo using this website:
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm to help me,
but when I converted it into actionscript, the numbers just kept rising!
Anyone have anything similar? Here's my lingo behaviour:
--PERLIN NOISE GENERATOR
property pSprite, pTime
on beginsprite me
pSprite = me.spritenum
pTime = 0.1
end
on exitframe me
pTime = pTime + 0.1
vBlend = myPerlin()
sprite(pSprite).blend = vBlend
end
on myPerlin me
vTotal = 0
repeat with i = 0 to 4
vFreq = 2 * i
vAmpl = i
vTotal = vTotal + interpolateNoise(float(pTime) * vFreq) * vAmpl
end repeat
return vTotal
end
on interpolateNoise vX
vIntX = integer(vX)
vFraX = vX - vIntX
v1 = smoothNoise(vIntX)
v2 = smoothNoise(vIntX + 1)
return interpolateCosine(v1, v2, vFraX)
end
on interpolateCosine a, b, vX
ft = vX * 3.1415927
f = (1 - cos(ft)) * .5
return a*(1-f) + b*f
end
on smoothNoise vX
vX = float(vX)
return noise(vX)/2 + noise(vX-1)/4 + noise(vX+1)/4
end
on noise vX
vX = integer(vX)
return (1.0 - ((vX * (vX * vX * 15731 + 789221) + 1376312589) + 79) /
1073741824.0)
end
--
-------------------------------------
Mike Cobb
Creative Director
HMC Interactive
-------------------------------------
Tel: + 44 (0)845 20 11 462
Mob: + 44 (0)785 52 54 743
Web: http://www.hmcinteractive.co.uk
-------------------------------------
Grosvenor House, Belgrave Lane,
Plymouth, PL4 7DA, UK.
-------------------------------------
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com