Gravity:
ps.setGravity(Gy);
The setGravity function takes a float value indicating how strong gravity
is in the downward Y direction. Calling this function will set gravity
in the X and Z directions to zero (which is normal). It makes sense
to call gravity once in your setup function because you typically
only need to set the global gravity once (in setup(), say) unless
there is a circumstance in your program that makes gravity change.
The default gravity value is 0.03.
ps.setGravity(Gx,
Gy, Gz);
This function is just like the one above, but it lets you also specify
the gravity in the X and Z directions in case things in your world
should be falling to the side or forwards or backwards. The default
gravity values are Gx: 0.0, Gy: 0.03, Gz: 0.0.
ps.drag = SOME_FLOAT;
Drag is a float value indicating how much drag resists
the movement of particles. It is equivalent to air-resistance. Setting
the drag high is like putting it in water. Too little drag will
keep the system from finding equilibrium. The default drag value
is 0.03.
particle.setPos(X,
Y, Z);
This
will set "particle's" position to (X, Y, Z).
particle.fixed()
For a variable of a particle type called "particle" this boolean function indicates whether this particle is fixed or free to move by the forces applied to it. Note that a fixed particle can be moved around, but the PSystem itself will not be doing it automatically.
particle.fix()
Sets a particle to fixed.
particle.unfix()
Sets a particle to un-fixed.
particle.fix(int axis, float value)
Fixes a particle in a particular axis only. Axes are 0=X, 1=Y, 2=Z. This will in effect constrain a particle to a line. You can constrain two different axes by calling this with two different axes. A particle's "fixed()" function will not return true unless it is fixed in all dimensions.
particle.pos
Pos is an array of three floats that contains the particle's
position in space.
particle.mass = SOME_FLOAT;
For a variable of a particle type called "particle" this
variable is the mass of the particle. The default mass is 1.0.
particle.enableCollision(collisionRadius);
Enables collision with a radius of collisionRadius for this
particle. Collision will only occur between two particles who both
have collision enabled.
particle.disableCollision();
Disables collision for this particle.
ps.addSpring(particleA,
particleB);
This is a convenience function that adds a new spring to the system between particleA
and particleB. By default the spring has a rest length of 18.0,
a strength of 0.005, and a damping of 0.001. If you want to modify
this spring's properties, you might want to hold the spring in a
variable by writing a line like this:
Spring s = addSpring(particleA,
particleB);
addSpring is equivalent to creating a new Spring and also adding it to the PSystem.
addSpring(particleA,
particleB, strength, damping, length);
This function is just like the above addSpring(), but you can manually
specify the strength, damping, and length. If you make a spring
too strong or give it too little or negative damping, you will witness
a very interesting numerical explosion. It's worth trying to see
it happen.
ps.drawForces = BOOLEAN_VALUE;
This field tells a particle system whether or not to draw each force. By default Springs are the only forces that know how to draw themselves, but you can add a draw method to any custom force, and it will automatically draw if ps.drawForces is true, which is the default.
ps.drawSprings();
This function will be called automatically if drawForces is true (the default), but if you set drawForces to false, you may decide to call this manually.
spring.restLength = SOME_FLOAT;
For a Spring variable "spring" this variable is the rest
length of the spring.
spring.damping = SOME_FLOAT;
For a Spring variable "spring" this variable is the damping
of the spring.
spring.strength = SOME_FLOAT;
For a Spring variable "spring" this variable is the strength
of the spring.
ps.defaultSpringStrength = SOME_FLOAT;
This sets the default spring strength for new springs that
are created after the function is called to this value. This way
you can create many springs with the same strength.
ps.defaultSpringDamping = SOME_FLOAT;
This sets the default spring damping for new springs that
are created after the function is called to this value. This way
you can create many springs with the same damping.
ps.defaultSpringRestLength = SOME_FLOAT;
This sets the default spring rest length for new springs
that are created after the function is called to this value. This
way you can create many springs with the same rest length.
ps.addMagnet(particleA);
This function adds a new magnet to the system whose location is
attached to particleA. By default the magnet has a strength of 1.0.
If you want to modify this magnet's properties, you might want to
hold the magnet in a variable by writing a line like this:
Magnet m = addMagnet(particleA);
It is possible to attach a magnet to a particle that is fixed or moving.
addMagnet(particleA,
strength);
This function is just like the above addMagnet(), but you can manually
specify the strength.
magnet.strength = SOME_FLOAT;
For a Magnet variable "magnet" this variable is the strength
of the magnet. |