PARTICLES - PART 1 - CHRISTMAS SHOW

The possibility of particles creation is a funny resource of Director.

Director doesn't accept the 3ds max particles. Our particles will be Director objects (like the Director sphere that we created in previous lesson).

The basic two lines of code to create a "particle emitter" are, by example:

   snowem1 = myworld.newModelResource("snowem", #particle)
   myworld.newModel("snowem",  snowem1):

To place the emitter in some place, better to create an "auxiliary sphere" - that can be invisible:

myworld.modelResource("snowem").emitter.region = [auxs0.transform.position]
Pay atention: we have an array element!

We can define 4 points of this array and we will have not a point of emission - our case - but a square/region.

We will see, in next lessons some definitions of properties of the emiter. In our demo we have:

 snowem1.emitter.maxSpeed = 100
 snowem1.emitter.minSpeed = 50
 snowem1.emitter.angle    = 180
 snowem1.lifeTime         = 2000
 snowem1.emitter.direction = vector(1 ,0 , 0)

The property lifeTime can be used to define the extension of the emission.

Look the new setupscript (new code in bold face):

global myworld
global avatarobj, cameraobj

on preparemovie me
  setupobjects
  
end

on setupobjects
  clearglobals 
  member("world").resetworld()
  myworld = member("world")
  avatarobj = new(member("avatarobj").script) 
  cameraobj = new(member("cameraobj").script) 
  
  -- Creating lights
  
  myworld.newLight("spot1", #spot)
  logolight = myworld.light("spot1")
  logolight.color = rgb(255, 255, 192)
  logolight.spotangle=80
  auxs0=myworld.model("auxs0")
  logolight.transform.position = auxs0.transform.position
  logop=myworld.model("logo").worldposition
  logolight.pointAt(logop)
  
  -- Creating particles 
   snowem1 = myworld.newModelResource("snowem", #particle)
   myworld.newModel("snowem",  snowem1)
   snowem1.emitter.maxSpeed = 100
   snowem1.emitter.minSpeed = 50
   snowem1.emitter.angle    = 180
   snowem1.lifeTime         = 2000
   snowem1.emitter.direction = vector( 1, 0, 0)
   myworld.modelResource("snowem").emitter.region = [auxs0.transform.position]
end 

Walk as usual using the arrow keys.


PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE