需要懂一些線性代數
以下為代碼
-----------------------
on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useAge = true
pCont.usePosition = true
pCont.useSpeed = true
)
on Init pCont do
(
)
on Proceed pCont do
(
if(sliderTime == 0)then
(
global waveCenter = $dummy_123
if(waveCenter == undefined)then
(
aa = dummy()
aa.name = "dummy_123"
aa.pos = [0 , 0 , 10]
)
row = 60
dis = 2
for i in 1 to row do
(
for j in 1 to row do
(
pCont.addParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particlePosition = [i * dis - row * dis / 2 , j * dis - row * dis / 2 , 0]
)
)
)
waveCenter.pos = [sin(currentTime.frame as float / 2) * 100 , cos(currentTime.frame as float / 2) * 100 , 30]
count = pCont.NumParticles()
for i = 1 to count do
(
pDis = distance (pCont.getParticlePosition i) waveCenter.pos
pCont.setParticleSpeed i [0 , 0 , sin(pDis * 10 + currentTime) / 1600]
)
)
on Release pCont do
(
)