View Single Post
  #2  
Old 04-29-2011, 12:15 AM
calani calani is offline
Scriptess
calani's Avatar
Join Date: Aug 2003
Location: asmgarden.gmap
Posts: 606
calani is on a distinguished road
Send a message via AIM to calani
Post Emitter Improvements (continued)

Ability to read terrainheight on 3d gmaps
* ability to read particle's height over (or under) terrain
* ability to read the height of the terrain at the particle's xy
Would be nice to be able to read a particle's height above the terrain, too, as well as just the height of the terrain the particle is over. Height above (or below) terrain would actually be much more useful. Ex: changing the opacity of cloudcover based on how high it is off the ground - would cover mountainpeaks in denser clouds, or allow for rolling fog near the shore.
Ex: allows particles to interact with the environment, such as golfballs rolling down hills. With particle grouping, could display shadows under particles, and with reading current vars, could change the size of the shadow based on z, and change the shadow alpha, stretching, and angle based on speed.


Flag to tell the particle to never go below the terrain height
* flag to force a particle's z to always be equal or greater than the terrainheight
* flag would disable checkbelowterrain and dropemitter if present (and optionally dropwateremitter)
Particle always at z>=terrainheight.
With this, you could give a particle a zangle of -pi/2 and speed>0, and it will always be on the terrain while moving around.

Ex: Golfballs: can fly in the air and roll around, but never go below the green.
Ex: Rabbits running (hopping) across the grass. Set their angle, speed, and impulses to make them jump, land with gravity, and change angle, but never go below the terrain or trigger a dropemitter. Attached an example below. Wildlife as emitters, interacting with the terrain!


Flag to tell the particle to never go below the terrain height
* flag to force a particle's z to always be less than or equal to zero (or waterheight)
* flag to force a particle's z to always be equal or greater than the waterheight
* flag would disable checkbelowterrain and all drop emitters present (except when particle lifetime expires)
Particle always at z<=0.
With this, you could give a particle a zangle of pi/2 and speed>0, and it will always be at or under the water on a 3d gmap

Ex: Fish
Ex: Rabbits running (hopping) across the grass. Set their angle, speed, and impulses to make them jump, land with gravity, and change angle, but never go below the terrain or trigger a dropemitter. Attached an example below. Wildlife as emitters, interacting with the terrain!
Ex: Ducks (or toy boats)

Dropairemitter
* Dropairemitter - triggers when z>=0 (or waterheight)
* same as a dropemitter or dropwateremitter, but in reverse.

Ex: Bubbles rising from the seafloor to pop at the surface
Ex: Fish jumping
Ex: Waves



Events based on emitters' vars
While I don't expect this to happen, it would be extremely useful.
Ex: If the particle's alpha<=zero, apply these modifiers.
Ex: with(AddLocalEvent("speed >= 30")) { /* Attach cloud-ring emitter for sonic boom*/ }
Ex: Use as a fix for dropemitters not inheriting particle values: shrapnel hitting the ground (saving rotation, image); event removes speed, spin, etc. and fades particle out, or bounce the particle


Particles applying modifiers to nearby particles
I don't expect this either, as particles would have to add modifiers to other emitter's particles. The distance checking, cross-script access, etc. would not be easy to implement.
Implementing this for only particles belonging to the same emitter would still be useful for collisions, though!

perhaps addAreaModifier() with a condition such as Z<2, or dist<3, etc
Ex: collisions
Ex: speed reduction for marbles rolling into and through slime
Ex: adding angular momentum to cloud particles when more 'solid' particles fly through them, such as a cannonball















Examples

Rainfall: (uses: ignore-z-when-drawing, dropemitter changes drawlayers, read current particle vars)

Base Emitter:
- layer 3
- check below terrain
- autorotation
- ignore z when drawing
- image g4_particle_spark
- initial angle = -pi/2 + random(-pi/10,pi/10);
- add -64..64 to x
- add -64..32 to y
- set z to 32
- set mode to 1
- set alpha to between 0.25 .. 1 (picks a random target alpha)
- range: replace alpha from 0 to (alpha) over 0.5 seconds (fade in from zero to current (target) alpha)
- 0.05 sec impulse: add -.1 to z

Scheduleevent outside of emitter, every 0.05:
- modify emit angle by +/- pi/32, but keep within bounds of {-pi/2 +/- pi/10} (for changing wind)

Drop emitter:
- image: g4_particle_ring.png
- set stretchy to 0.5 (keeps perspective)
- set mode to 1
- emissionoffset of {0,1,0}
- range: replace zoom from 0 to 0.5 over 0.75 seconds
- range: replace alpha from 1 to 0 over 0.75 seconds

Drop water emitter:
- image: g4_particle_ring.png
- set stretchy to 0.5 (keeps perspective)
- set mode to 1
- emissionoffset of {0,1,0}
- range: replace zoom from 0 to 0.8 over 1 seconds
- range: replace alpha from 1 to 0 over 1 seconds



Bouncing ball: (uses: dropemitter particle inheriting)

Base Emitter:
- layer 3
- ball graphic
- children_particles_inherit_values
- add -15..15 to x/y
- set z to 10..15
- set zangle to -pi/2
- set angle to 0..2*pi
- set speed to 0.1;
- .05 sec impulse: add 0.1 to speed (apply fixed gravity)

Drop Emitter 1: (inherits particle data)
- multiply speed by -.6 (ball changes direction, loses momentum)
- 0.05 sec impulse: add 0.1 to speed (pull particle back to the ground with fixed gravity)

Drop Emitter 2:
- multiply speed by -.6
- 0.05 sec impulse: add 0.1 to speed

Drop Emitter 3:
- multiply speed by -.6
- 0.05 sec impulse: add 0.1 to speed

Drop Emitter 4:
- multiply speed by -.6
- 0.05 sec impulse: add 0.1 to speed

Drop Emitter 5:
- set speed to 0
- range: replace alpha from 1 to 0 over 3 seconds



Running Rabbit: (Uses: always above terrain flag, change image after emit)
Problems: will run over water (perhaps along the seafloor depending on 'AlwaysAboveTerrain' flag behavior)

Base Emitter:
- layer 1
- image of a rabbit running
- AlwaysAboveTerrain=true (disables drop emitter, lets rabbit run up hills)
- set angle to 0..2*pi
- 1 sec impulse: add pi/3 to zangle (hopping)
- 0.05 sec impulse: add -0.1 to Z and multiply zangle by .85 (gravity, coupled with hopping by using zangle, should make for realistic-looking hopping)
- (0.1 to 3) sec impulse: add +/- pi/8 to angle (running around randomly)
- (10 to 60) sec impulse: set speed to (10 to 12) and change image to running // running
- (5 to 40) sec impulse: set speed to (5 to 8) and change image to running // hopping
- (0 to 30) sec impulse: set speed to 0 and change image to an idle and scratching animation // stop and scratch, look around



Running Rabbit: (Uses: events)

Base Emitter:
- layer 1
- image of a rabbit running
- set angle to 0..2*pi
- 1 sec impulse: add pi/4 to zangle
- 0.1 sec impulse: add +/- pi/32 to angle

Events:
- if Z>=TerrainHeight: 0.05 sec impulse: lower zangle by pi/48 (for running down terrain)
- if Z<=TerrainHeight: add pi/8 to zangle (for hopping and climbing terrain)
- if Z<=0.5: add pi/3 to angle (so it doesn't hit the water)
- if Z<=0: stop moving, fade alpha 1 to 0; respawn




Semi-intelligent school of fish: (uses: events, grouping, terrainheight)

layer 0, so always below player

Emitter for individual fish:
- spawns several particles with random graphic (animated graphic of the fish swimming slowly)
- adds a few tiles to their x/y/z so they're in a school
- set their angle to between 0..2*pi

Group fish particles:
- apply an impulse to slowly change the group's angle and speed

Events based on Z:
- if group terrainheight>=-3: enable an impulse to change the group's angle by pi/16 every half a second
- if group terrainheight<-3: disable above impulse
- if group terrainheight<=-1: add pi/3 to angle.
__________________
Reply With Quote