Skip to content

Instantly share code, notes, and snippets.

@JokerMartini
Last active July 5, 2017 14:19
Show Gist options
  • Save JokerMartini/81c1789be54d8e35dca5 to your computer and use it in GitHub Desktop.
Save JokerMartini/81c1789be54d8e35dca5 to your computer and use it in GitHub Desktop.
Maxscript: There are two functions here which create a single wave in maxscript using point helps to display the wave.
-- http://cameroncarson.com/nuke-wave-expressions/
-- https://davemne.wordpress.com/2011/05/16/nuke-wave-expressions-to-copy-and-paste/
fn BuildBounceArc =
(
waveWidth = 10
minVal = 0
maxVal = 10
numSamples = 20
-- abs(sin(pi*(frame + offset)/waveLength))* (maxVal-minVal) + minVal
for i = 0 to numSamples do
(
ang = i * 180.0 / numSamples
posZ = abs(sin(ang)) * (maxVal - minVal) + minVal
posX = 1.0 * i / numSamples * waveWidth
point pos:[posX, 0, posZ] size:.5 wirecolor:green name:("ang_" + ang as string)
)
)
fn BuildLinearArc =
(
waveWidth = 10
minVal = 0.0
maxVal = 10
numSamples = 50
-- (asin(sin(2*pi*(frame+offset)/waveLength))/pi+0.5) * (maxVal-minVal) + minVal
for i = 0 to numSamples do
(
ang = i * 180.0 / numSamples
posZ = (asin(sin(ang))/90) * (maxVal - minVal) + minVal
posX = 1.0 * i / numSamples * waveWidth
point pos:[posX, 0, posZ] size:.5 wirecolor:red name:("ang_" + ang as string)
)
)
fn BuildConcaveArc =
(
waveWidth = 10
minVal = 0.0
maxVal = 10
numSamples = 50
for i = 0 to numSamples do
(
ang = i * 180.0 / numSamples
w = pow (asin(sin(ang))/90) 3.0 --increase or decrease value for steeper/shallower curve
posZ = w * (maxVal - minVal) + minVal
posX = 1.0 * i / numSamples * waveWidth
point pos:[posX, 0, posZ] size:.5 wirecolor:blue name:("ang_" + ang as string)
)
)
fn BuildConvexArc =
(
waveWidth = 10
minVal = 0.0
maxVal = 10
numSamples = 50
for i = 0 to numSamples do
(
ang = i * 180.0 / numSamples
w = pow (asin(sin(ang))/90) .5 --increase or decrease value for steeper/shallower curve
posZ = w * (maxVal - minVal) + minVal
posX = 1.0 * i / numSamples * waveWidth
point pos:[posX, 0, posZ] size:.5 wirecolor:orange name:("ang_" + ang as string)
)
)
fn BuildSmoothArc =
(
waveWidth = 10
minVal = 0
maxVal = 10
numSamples = 20
for i = 0 to numSamples do
(
ang = i * 180.0 / numSamples
w = pow (abs(sin(ang))) 3 --increase or decrease value for steeper/shallower curve
posZ = w * (maxVal - minVal) + minVal
posX = 1.0 * i / numSamples * waveWidth
point pos:[posX, 0, posZ] size:.5 wirecolor:black name:("ang_" + ang as string)
)
)
delete objects
clearlistener()
format "\n"
BuildBounceArc()
BuildLinearArc()
BuildConcaveArc()
BuildConvexArc()
BuildSmoothArc()
/*
in other programs, sin/asin work with Radians
but in MAXScript, you need to divide by degrees
and 0.5*Pi is 180 degrees
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment