[0.8.9][NK] Emmitters & Attractors

johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
edited December 2015 in Modding Tutorials
Particle Systems in TUG consist of three parts: particles, emitters and attractors.

Particles are 2d sprite objects.
Particles are the main part of the system, only particles are rendered.
Each particle has a texture, color, position, velocity and age.

Emitters are in-game objects, they can be spawned in the world or attached to other in-game objects.
Each emitter has type, position, spawn rate, oscillation cycle and age(can be endless or spawn as burst).
Emitters are basically controllers used to spawn particles.

Attractors are in-game objects, they need be attached to other in-game objects.
One attractor can be assigned to multiple emitters, but each emitter can only be attached to one attractor at a time.
Attractors can attract particles forwards the center of the attractor or repel particles away from the center of the attractor.

Particle (with default values)

Particles
{
Particle Name
{
# Path to diffuse texture (string)
# Required!
textureName = "FX/Textures/NULLPART.tga"

# Texture size (int)
# Required!
# Must be a power of 2
textureSize = 256

# Add color (vec3 color RGB)
# This color is added to the texture
# Range <0.0-255.0, 0.0-255.0, 0.0-255.0>
# Example <100.0, 0.0, 0.0> = add 100 to the red channel of the texture
addColor = <0.0, 0.0, 0.0>

# Multiply color (vec3 scale RGB)
# Scale use to multiply the texture’s colors
# Example <1.0, 0.0, 0.0> = only red channel of the texture will be used
multiplyColor = <1.0, 1.0, 1.0>

# Rotation speed (float)
# Makes the particle rotate about the z-axis
# Should be in degrees per second
rotationSpeed = 0.0

# Scaling (vec3 scale XYZ)
# Initial scale of the particle
# Note: Z value isn’t used
scaling = <1.0, 1.0, 1.0>

# Scaling speed (vec3 scale XYZ)
# Speed of growing/shrinking over time, in a % of total size
# Note: Z value isn’t used
scalingSpeed = <0.0, 0.0, 0.0>

# Scaling variance (float)
# Variance to the base scale of the particle
# Applies to all axis
scalingVariance = 0.0

# Acceleration (vec3 XYZ)
# Particle acceleration on each axis
# Negative Y will simulate gravity
acceleration = <0.0, 0.0, 0.0>

# Max age (float)
# Required!
# Max life time of the particle.
maxAge = 0.0

# Age variance (float)
# Variance to the base age of the particle
ageVariance = 0.0

# Fading age (float)
# Age at which the particle will start fading
# 0.0 = disabled/maxAge
ageToStartFading = 1.0

# Shrinking age (float)
# Age at which the particle will start shrinking
# 0.0 = disabled/maxAge
ageToStartShrinking = 1.0

# Grow [alpha] age (float)
# Age at which the particle will be fully opaque (visible)
# All particles spawn fully transparent
# Must be lower than ageToStartFading!
fadeInAge = 0.0

# Grow [size] age (float)
# Age at which the particle will reach it’s base size
# All particles spawn at a very small size
# Must be lower than ageToStartShrinking!
growInAge = 0.0

# Blend type (string)
# default - normal blending
# additive - additive alpha blending
# default = "default"
blendType = "default"

# Speed limit (float)
speedCap = 100

# Orientation (string)
# normal - face camera
# locked - based on emitter object’s rotation
# default = "normal"
orientation = "normal"
}
}

Emitter (with default values)

{
FX
{
Emitter Name
{

Emitter
{
# Emitter never stops emitting particles and will cycle until destroyed.
endless

# Emitter will spawn all of its particles once and then die.
burst

# Should be the subfolder this emitter is in within the emitter folders
# For organizational purposes
type = "Strike"

Particle Name
{
# Spawn rate (float)
# Required!
# How many particles per second should be spawned
rate = 0

# Spawn rate variance (float)
# Variance (+/-) to the base spawn rate
rateVariance = 0

# oscillation, start, stop (float)
# Oscillation is used to define a cycle length
# Start is used to define starting range of spawning
# Stop is used to define stopping range of spawning
# Example:
# oscillation = 8
# start = 0.25
# stop = 0.75
# cycle starts
# ^ wait for 2s (0.25*8)
# | spawn particles for 4s ([0.25-0.75]*8)
# | wait for 2s ([0.75-1.0]*8)
# repeat cycle
oscillation = 1
start = 0
stop = 1

# Velocity (vec3 XYZ)
# Initial velocity of this particle after the emitter creates it
velocity = <0.0, 0.0, 0.0>

# Velocity variance (vec3 XYZ)
# Variance (+/-) to the base velocity
velocityVariance = <0.0, 0.0, 0.0>

# Rotation (float)
# Rotation of the particle, in degrees, around its z-axis
rotation = 0

# Rotation variance (float)
# Variance (+/-) to the base rotation, in degrees
rotationVariance = 0

### Defines the spawning type of the emitter.
# Required!
#
# Type (point)
# Spawns particles at the location of the emitter.
# type = "point"
#
#
# Type (radial)
# Particle spawning area is a disk, centered at the emitter
# type = "radial"
# radius = 0.0
#
# # Defines the normal for the disk for orienting it
# upVector = <0.0, 0.0, 0.0>
#
# # emissionDirection
# # "outward" - Particles travel away from the emitter
# # "inward" - Particles travel toward the emitter
# emissionDirection = ""
#
# # radialSpawningType
# # "orbit" - Emit point will orbit around the emitter
# # orbitSpeed - How fast the emit point should orbit
# # in degrees per second
# orbitSpeed = 0.0
# # "default" - Normal spawning behavior
# radialSpawningType = "default"
#
#
# Type (spherical)
# Particle spawning area is a sphere, centered at the emitter
# type = "spherical"
# radius = 0.0
# # emissionDirection
# # "outward" - Particles travel away from the emitter
# # "inward" - Particles travel toward the emitter
# emissionDirection = ""
#
#
# Type (hemispherical)
# Particle spawning area is a hemisphere
# centered at the center of the flat face
# type = "hemispherical"
# radius = 0.0 (float)
#
# # emissionDirection
# # "outward" - Particles travel away from the emitter
# # "inward" - Particles travel toward the emitter
# emissionDirection = ""
#
#
# Type (box)
# Spawns particles within a box, centered at the emitter
# type = "box"
# boxDimensions = <0.0, 0.0, 0.0>
#
#
# Type (ribbon)
# Spawns particles in ribbons
# type = "ribbon"
#
###
type = "point"

# Randomize at spawn (flag)
# Randomizes the starting time for the oscillation period
randomizeAtSpawn

# Respect rotation (flag)
# If this tag is set, the velocities of particles emitted will
# match their parent’s emitter orientation.
respectRotation
}
Example Particle02
{
# ...
}
}
Transform
{
}
}
}
}

Attractor (with default values)

{
FX
{
Attractor Name
{
Transform
{
}

Attractor
{
# Acceleration (vec3 XYZ)
# Particle acceleration towards this attractor on each axis
# Use negative values to repel particles
# Speed is in voxels per second
accelerationStrength = <0.0, 0.0, 0.0>

# Velocity (vec3 XYZ)
# Particle velocity towards this attractor on each axis
# Use negative values to repel particles
# Speed is in voxels per second
velocityStrength = <0.0, 0.0, 0.0>
}
}
}
}

Using Emitters

Enabling an emitter(the emitter needs to exist on target):
target:NKActivateEmitterByName(emitterName)
Disabling an emitter(the emitter needs to exist on target):
target:NKDeactivateEmitterByName(emitterName)
Spawning an emitter in the world:
Eternus.ParticleSystem:NKPlayWorldEmitter(position, emitterName)

Creating a new emitter:
local newEmitter = Eternus.GameObjectSystem:NKCreateGameObject(emitterName, true)
if (newEmitter == nil) then
NKWarn("Failed to create emitter by name: " .. emitterName)
return
end
Setting up the new emitter:
newEmitter:NKSetShouldSave(false)
newEmitter:NKSetPosition(worldPostion)
newEmitter:NKPlaceInWorld(false, false)
[Optional] Attaching the emitter:
target:NKAddChildObject(newEmitter)
[Optional] Setting orientation and scale:
newEmitter:NKSetOrientation(orientation)
newEmitter:NKScale(scale, false)
Activating the emitter:
newEmitter:NKSetEmitterActive(true)
Deactivating the emitter:
newEmitter:NKSetEmitterActive(false)

Examples

Example Attractor ([MOD]/FX/Attractors/Example Attractor/Example Attractor.txt)
{
FX
{
Example Attractor
{
Transform
{
}

Attractor
{
accelerationStrength = <4.0, 4.0, 4.0>
velocityStrength = <6.0, 6.0, 6.0>
}
}
}
}
Example Particles ([MOD]/FX/Particles/Live/Example Particle.txt)
Particles
{
Example Particle01
{
textureName = "FX/Textures/hit_burst.tga"
textureSize = 256
addColor = <0.0, 0.0, 0.0>
multiplyColor = <1.0, 1.0, 1.0>
rotationSpeed = 195.0
scaling = <0.5,0.5,0.5>
scalingSpeed = <0.2, 0.2, 0.2>
scalingType = "multiply"
scalingVariance = 0.2
acceleration = <0.0, 2.0, 0.0>
maxAge = 2.0
ageVariance = 0.5
ageToStartFading = 1.6
ageToStartShrinking = 1.4
blendType = "additive"
fadeInAge = 0.3
growInAge = 0.2
speedCap = 100
}

Example Particle02
{
textureName = "FX/Textures/energy_rise01.tga"
textureSize = 256
addColor = <0.0, 0.0, 0.0>
multiplyColor = <1.0, 1.0, 1.0>
rotationSpeed = 195.0
scaling = <0.9,0.9,0.9>
scalingSpeed = <0.7, 0.7, 0.7>
scalingType = "multiply"
scalingVariance = 0.5
acceleration = <0.0, 2.0, 0.0>
maxAge = 0.7
ageVariance = 0.15
ageToStartFading = 0.5
ageToStartShrinking = 0.4
blendType = "additive"
fadeInAge = 0.1
growInAge = 0
speedCap = 100
}
}
Example Emitter ([MOD]/FX/Emitters/Combat/Example Emitter.txt)
{
FX
{
Example Emitter
{
Emitter
{
endless
type = "Strike"

Example Particle01
{
rate = 2
oscillation = 1
start = 0
stop = 1
velocity = <0.0, 0.0, 0.0>
velocityVariance = <1.0, 1.0, 1.0>
rotation = 180
rotationVariance = 360
type = "Spherical"
radius = .3
randomizeAtSpawn
}
Example Particle02
{
rate = 4
oscillation = 1
start = 0
stop = 1
velocity = <0.0, 0.0, 0.0>
velocityVariance = <4.0, 4.0, 4.0>
rotation = 180
rotationVariance = 360
type = "Spherical"
radius = .3
randomizeAtSpawn
}
}
Transform
{
}
}
}
}
Emitter (without Attractor)
image
Emitter (without Attractor) - Moving
image
Emitter (with Attractor)
image
Emitter (with Attractor) - Moving
image
My Blog
jc.png
  yt.png  t.png  
Sign In or Register to comment.