Electric Fields


Class : EField.h

Made By : Steve

Uses : GL_LINES

Complexity : LOW

Simulates an electric field between two user supplied coordinates.


The electric field effect is one of the more simple effects in the package. It was meant to be one of the introductory effects (along with sparks), but was coded last.

The electric field is utilized with the EField class. It is initialized with :

EField e = new EField (int numSegments, vector3f c1, vector3f c2, vector3f mag);

This allows the user to define the number of segments, two coordinates, and the magnitude. The magnitude is the maximum change along the 3 axis, which is involved in the generation of each segment. Higher magnitudes give larger (wider) breadth in the current. The magnetic field is drawn using :

e -> drawField();

As with any of the line-based effects, GL_LIGHTING must be disabled before making the call to the drawing method. The values input by the user for this class are not as sensitive as other classes.

  • Magnitude : Any positive float. The magnitude is measured in unit size so the value can be > 1.
  • Speed : The speed should be between 0 and 1. This is the fade speed per frame.
  • Cutoff : This value defines the cutoff alpha value before a new bolt begins. This should be smaller than the alpha value supplied in setColor(R, G, B, A).
  • Line : The line value is an integer > 0. It is the line width of each segment.

Thoughts : This class was the easiest to create. Like lightning, it would look much better with a pixel shader applied. The original idea was to have each EField class to allow users to add multiple bolts instead of one-per-field. I decided against this due to the difficulty of selecting and deleting certain data.