summaryrefslogtreecommitdiff
path: root/src/tesseract/forces/Gravity.java
blob: 79e7f6a6429ee1f25d74ab67ae38a00cde591562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package tesseract.forces;

import javax.vecmath.Vector3f;

import tesseract.objects.Forceable;

/**
 * Generic downward force class (aka Gravity).
 * 
 * @author Jesse Morgan
 */
public class Gravity extends Force {
	/**
	 * Default gravity force.
	 */
	private static final float DEFAULT_GRAVITY = 1f;
	
	/**
	 * The force used here.
	 */
	private float myGravity;
	
	/**
	 * Create a default gravity.
	 */
	public Gravity() {
		myGravity = DEFAULT_GRAVITY;
	}
	
	/**
	 * Create gravity with a custom strength.
	 * 
	 * @param gravity The strength of gravity.
	 */
	public Gravity(final float gravity) {
		myGravity = gravity;
	}
	
	/**
	 * Calculate the force of gravity...
	 * 
	 * @param obj The object the force is calculated for.
	 * @return A vector describing the force
	 */
	protected Vector3f calculateForce(final Forceable obj) {
		return new Vector3f(0, -myGravity, 0);
	}

}