home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Maximum 3D 3
/
m3d-p3.iso
/
3DS_MAX
/
3DSMAX.2_0
/
SCRIPTS
/
PARTICLE.MS
< prev
next >
Wrap
Text File
|
1997-10-19
|
4KB
|
129 lines
-- particle.ms
-- John Wainwright
--
-- this is a utility that demo's the new particle system
-- access functions n Beta 2.1. It lets you pick a particle system
-- and a source of scene objects and will make copies of
-- the source, 1 for each particle and then animate them to
-- follow particle movement - essentially turning any
-- of the MAX particle systems into a geometry-based
-- system.
--
-- For the source you can pick a master object to clone
-- or use the current selection, from which it will
-- take a random set of clones for the particle objects.
-- You can also make the objects z-axis follow the direction
-- of particle flow by checking the follow checkbox.
-- There's also visibility checkbox which controls whether the
-- utility use a visibility track to hide particle objects
-- corresponding to when their associated particles are
-- born and die. (note this doesn't hide them in the viewports
-- so you might see odd movements there - render to see
-- the visibility control working).
--
-- If you've got a lot of particles, it can take a while to
-- do the animation - see the "processing frame #" message
-- under the create button in the rollout.
--
-- have fun!!
utility object_particle "Object Particles"
(
local system, master, particles,
start = animationRange.start.frame,
end = animationRange.end.frame
group "Particle system"
(
pickbutton pick_system "Pick particle system"
label system_name
)
group "Object source"
(
radiobuttons source_type
labels:#("Current selection", "Pick")
pickbutton pick_master "Pick master object" enabled:false
label master_name
)
group "Animation"
(
checkbox follow "Follow velocity direction" checked:true
checkbox hide_em "Hide when outside range" checked:true
spinner start_frame "Start frame:" type:#integer range:[start, end, start]
spinner end_frame "End frame:" type:#integer range:[start, end, end]
button create_parts "Create object particles"
label status
button delete_parts "Delete object particles"
)
on object_particle open do
(
master_name.text = system_name.text = ""
particles = #()
)
on pick_system picked obj do
( system = obj; system_name.text = system.name )
on pick_master picked obj do
( master = obj; master_name.text = master.name )
on source_type changed btn do
(
if btn == 1 then
(
master_name.text = ""
pick_master.enabled = false
)
else
pick_master.enabled = true
)
on delete_parts pressed do
( delete particles; particles = #() )
on create_parts pressed do
(
if system == undefined or
(source_type.state == 1 and selection.count == 0) or
(source_type.state == 2 and master == undefined) then
return undefined
-- get the particles
status.text = "copying particle objects..."
particles = for i in 1 to particleCount system collect
(
if source_type.state == 1 then -- current selection
copy selection[random 1 (selection.count)]
else
copy master -- picked master
)
-- animate particles
animate on for t in start_frame.value to end_frame.value do at time t
(
status.text = "Processing frame " + (t as string)
for i in 1 to particleCount system do
(
local pos = particlePos system i
if pos != undefined then
(
particles[i].pos = pos
if follow.checked then
particles[i].dir = particleVelocity system i
if hide_em.checked then
particles[i].visibility = true
)
else
(
particles[i].pos = [0,0,0]
if hide_em.checked then
particles[i].visibility = false
)
)
)
status.text = ""
)
)