Particle
objects act as a fixed point where soft particles are emitted from given a velocity. Emitted particles behave as they would in the normal world, meaning they act as physical points affected by gravity and optional collisions. Furthermore, Particle
objects have options for how long they last, a wait time for how long to wait before spawning a new particle, and how their transparency and size changes over time, soft/volumetric light options, and more. More information on the soft particle system can be found here.Particle
object has a set of interesting options for modifying the appearance of emitted particles over time.alphaRange
of a Particle
object represents how the opacity of emitted particles changes over it’s lifetime. The best way to think about a number range is as graph with an x and y axis.alphaRange
number using setAlphaRangeIndex(time [number], value [number])
, where time
is a number from 0 to 1 representing the lifetime, and value
represents another number from 0 to 1 representing the opacity at that current lifetime number.setScaleRangeIndex(time [number], value [vector3])
, where value
is a lovr vector3
instead of a number.alphaRange
and scaleRange
are automatically set to 1 and (1, 1, 1), and for lifetime 1, 0 and (0, 0, 0). So by default every emitted particle will scale down and become more transparent over time.directionalForceRange
, which represents a random directional force the particle will be sent in.directionalForceRange
is a table that includes variables xRange
, yRange
, and zRange
. All of these variables are lovr vector2
’s.xRange
equal to a lovr vector2
with (-20, 20), every new particle will have it’s x initial directional force be a random number between -20 and 20.useLookVector
of the Particle
object is set to true, then this initial directional force will be based on the rotation of the Particle
object.friction
of the Particle
object!type
string [default = “Particle”]: The class type of the object.
diffuseMap
lovr texture: The diffuse texture for the Model.enabled
bool [default = true]: Whether new particles are created on each update call.faceCamera
bool [default = true]: Whether particles are always oriented to face the camera.hasDepthTest
bool [default = true]: Whether particles appear in front of objects blocking them.hasShadowCastings
bool [default = true]: Whether shadows from a light source can be casted onto particles.brightness
number [default = 1]: How bright the particle is when being rendered.
gravity
number [default = 30]: The force of gravity enacted on the particle.friction
number [default = 0.99]: The amount of friction that dampens the directionalForceRange
of each particle.timeStep
number [default = 3]: The speed of the particle simulation.hasCollision
bool [default = false]: Whether particles collide with surfaces.collisionDist
number [default = 0.15]: The distance that collided particles will be from the surface they collide with.incrementTime
number [default = 2]: The time between emitting a new particle.edgeSmooth
: number [default 0.2]: The smoothness a particle will have when intersecting a surface. Setting this to -1.0 will disable soft particles entirely.
useLookVector
: bool [default = true]: Whether emitted particles have their initial velocity based on the globalTransform
orientation of the node.directionalForceRange
table: When emitting particles, a random value is picked from directionalForceRange.xRange
, directionalForceRange.yRange
, and directionalForceRange.zRange
to determine the initial velocity of the particle. These values are all Vector2
’s where the random value is picked between the x and y value.alphaRange
table: When emitting particles, There needs to be an initial transparency and final transparency. The alphaRange
represents how the transparency changes over the lifetime of a particle.scaleRange
table: Functions exactly the same as alphaRange
except this determines how the scale of a particle changes over time. The final scale is the current scale range number multiplied by localTransform.scale
.Particle
object is done by passing in a table.
LGE.Particle(
{
-- In addition to the options supported in "LGE.Node"...
diffuseMap_filepath = filepathToTexture, [string] -- Necessary, this is the filepath to the texture the node will use
}
)
directionalForceRange
.axis
should be "xRange"
, "yRange"
, or "zRange"
.Particle:setDirectionalForceIndex(axis [string], vec [vector2])
time
and value
should be a number from 0 to 1.Particle:setAlphaRangeIndex(time [number], value [number])
time
should be a number from 0 to 1.value
can be any vector3
.Particle:setScaleRangeIndex(time [number], value [vector3])
globalTransform
information of the Particle.localTransform
is not updated since it is always set manually.Model:update(dt [number])
pass
.mode
can either be "depth"
or "full"
."full"
mode should be done during the lovr.draw(pass)
function.
Particle:draw(pass [lovr pass], mode [string])