View Single Post
  #1   Spotlight this post!  
Unread 15-02-2004, 13:16
reisser's Avatar
reisser reisser is offline
Ph.D. User
AKA: Brandon Reiss
#0103 (Cybersonics Technology Team)
Team Role: Animator
 
Join Date: Mar 2002
Location: Kintnersville, PA
Posts: 68
reisser is on a distinguished road
Send a message via AIM to reisser
Cybersonics 103 Animation Teaser...

on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useInteger = true
pCont.usePosition = true
pCont.useSpeed = true
)

on Init pCont do
(
count = pCont.NumParticles()

--random targets
for i in 1 to count do
(
pCont.particleIndex = i
pCont.particleInteger = random 0 23
)
)

on Proceed pCont do
(
count = pCont.NumParticles()

for i in 1 to count do
(
pCont.particleIndex = i

--determine distance from origin (correct straying particles)
point = pCont.particlePosition
dist = sqrt ((point.x * point.x) + (point.y * point.y))
dist = sqrt ((dist * dist) + (point.z * point.z))

--adjust stray particles
if dist > 50 then
(
if point.x > 0 then
pCont.particlePosition.x = pCont.particlePosition.x - .25
else
pCont.particlePosition.x = pCont.particlePosition.x + .25

if point.y > 0 then
pCont.particlePosition.y = pCont.particlePosition.y - .25
else
pCont.particlePosition.y = pCont.particlePosition.y + .25

if point.z > 0 then
pCont.particlePosition.z = pCont.particlePosition.z - .25
else
pCont.particlePosition.z = pCont.particlePosition.z + .25
)

--set target position
sel = execute("$conn_target_" + pCont.particleInteger as string + ".pos")

--find vector of separation
vect = sel - pCont.particlePosition

--set target finding
pCont.particleSpeed = vect / 1000

--success test, is particle considerably close to target?
if ((vect.x > -4) and (vect.x < 4)) and ((vect.y > -4) and (vect.y < 4)) and ((vect.z > -4) and (vect.z < 4)) then
(
--choose new target at random
old = pCont.particleInteger
do
(
num = random 0 23
if not (old == num) then
new = true
)
while new = false
pCont.particleInteger = num
--store position
pos = pCont.particlePosition

--spawn new on success
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particlePosition = pos
do
(
num = random 0 23
if not (old == num) then
new = true
)
while new = false
pCont.particleInteger = num
)
)
)

on Release pCont do
(

)
__________________
Doctor?