Built-in Functions
ParticleScript has a number of built-in operators and functions. These are listed here:
math operators
The operators + - * / are all supplied. These operate componentwise. The type returned is equal to the type you pass in - ie, if you multiply float3, it returns float3. If the inputs are not of the same type, it converts the smaller one to the larger.
swizzle operators
A period followed by the letters X,Y,Z,W is a swizzle. This rearranges the components, and possibly changes the number of components in the input value.
comparison operators
Comparison operators like > < >= <= == work on values of type float1. If you pass in a value that is not float1, only the first component will be used. These operators return selection sets. Boolean operators like 'and' and 'or' are not yet implemented.
new
New is a built-in expression that returns a selection set containing the most-recently-spawned particles.
all
All is a built-in expression that returns a selection set containing all particles.
host.position
The expression host.position returns the current position of the SceneObject to which this particle system is applied.
host.forward, etc
The expressions host.right, host.left, host.forward, host.backward, host.up, and host.down return the six axis vectors of the SceneObject to which this particle system is applied.
rand.unitvec
Returns a random float3 unit vector, evenly distributed on the unit circle.
rand.negpos
Returns a random float4 vector, with each component between -1 and 1.
rand.zeroone
Returns a random float4 vector, with each component between 0 and 1.
age
Returns the age of the particle, in seconds.
time.frame
Returns the amount of time elapsed in this rendering frame. Note that particles are one of the few aspects of Wild Pockets that do not run at a fixed framerate.
time.curr
Returns the real-time clock of the current frame.
time.prev
Returns the real-time clock of the previous frame.
trajectory(...)
Computes the position of an inertial particle, given four parameters: initial position, initial velocity, gravity, and time elapsed. Uses a closed-form equation.
undulate(...)
Returns a smooth waveform that rises and falls randomly. The waveform was constructed by generating short samples of sinusoidal waveforms at random frequencies and overlapping these short samples at random offsets. The undulating waveform is good for modeling many physical phenomena, such as the way a spark drifts away from a camp-fire in a semi-random walk. The return value is float4, each component undulates independently. The first parameter is time (offset within the waveform), the second is a random seed.
lerp(...)
Interpolation. Takes three parameters: A, B, fraction. If fraction is zero, returns A. If fraction is 1, returns B. Otherwise, interpolates.
circle(...)
Computes the position of a particle that is rotating in a unit circle around the Z-axis at a rate of 1 revolution per second. The input is an amount of time elapsed.
normalize(...)
Given a float3, returns a normalized version (a vector of unit length).
What's Missing?
Clearly, this is a very skeletal function list. There should be dozens, if not hundreds of useful functions. This will be expanded in time.
- Printer-friendly version
- Login or register to post comments
-




Great to know about particles
Great to know about particles finally.