|
@@ -48,19 +48,47 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
|
|
|
static final long serialVersionUID = 1;
|
|
|
|
|
|
private static final Logger logger = Logger.getLogger(Vector4f.class.getName());
|
|
|
-
|
|
|
+ /**
|
|
|
+ * shared instance of the all-zero vector (0,0,0,0) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f ZERO = new Vector4f(0, 0, 0, 0);
|
|
|
+ /**
|
|
|
+ * shared instance of the all-NaN vector (NaN,NaN,NaN,NaN) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f NAN = new Vector4f(Float.NaN, Float.NaN, Float.NaN, Float.NaN);
|
|
|
+ /**
|
|
|
+ * shared instance of the +X direction (1,0,0,0) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f UNIT_X = new Vector4f(1, 0, 0, 0);
|
|
|
+ /**
|
|
|
+ * shared instance of the +Y direction (0,1,0,0) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f UNIT_Y = new Vector4f(0, 1, 0, 0);
|
|
|
+ /**
|
|
|
+ * shared instance of the +Z direction (0,0,1,0) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f UNIT_Z = new Vector4f(0, 0, 1, 0);
|
|
|
+ /**
|
|
|
+ * shared instance of the +W direction (0,0,0,1) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f UNIT_W = new Vector4f(0, 0, 0, 1);
|
|
|
+ /**
|
|
|
+ * shared instance of the all-ones vector (1,1,1,1) - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f UNIT_XYZW = new Vector4f(1, 1, 1, 1);
|
|
|
+ /**
|
|
|
+ * shared instance of the all-plus-infinity vector (+Inf,+Inf,+Inf,+Inf)
|
|
|
+ * - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f POSITIVE_INFINITY = new Vector4f(
|
|
|
Float.POSITIVE_INFINITY,
|
|
|
Float.POSITIVE_INFINITY,
|
|
|
Float.POSITIVE_INFINITY,
|
|
|
Float.POSITIVE_INFINITY);
|
|
|
+ /**
|
|
|
+ * shared instance of the all-negative-infinity vector (-Inf,-Inf,-Inf,-Inf)
|
|
|
+ * - Do not modify!
|
|
|
+ */
|
|
|
public final static Vector4f NEGATIVE_INFINITY = new Vector4f(
|
|
|
Float.NEGATIVE_INFINITY,
|
|
|
Float.NEGATIVE_INFINITY,
|
|
@@ -824,6 +852,11 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a copy of this vector.
|
|
|
+ *
|
|
|
+ * @return a new instance, equivalent to this one
|
|
|
+ */
|
|
|
@Override
|
|
|
public Vector4f clone() {
|
|
|
try {
|
|
@@ -942,6 +975,13 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
|
|
|
return "(" + x + ", " + y + ", " + z + ", " + w + ")";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Serialize this vector to the specified exporter, for example when
|
|
|
+ * saving to a J3O file.
|
|
|
+ *
|
|
|
+ * @param e (not null)
|
|
|
+ * @throws IOException from the exporter
|
|
|
+ */
|
|
|
@Override
|
|
|
public void write(JmeExporter e) throws IOException {
|
|
|
OutputCapsule capsule = e.getCapsule(this);
|
|
@@ -951,6 +991,13 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
|
|
|
capsule.write(w, "w", 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * De-serialize this vector from the specified importer, for example
|
|
|
+ * when loading from a J3O file.
|
|
|
+ *
|
|
|
+ * @param e (not null)
|
|
|
+ * @throws IOException from the importer
|
|
|
+ */
|
|
|
@Override
|
|
|
public void read(JmeImporter e) throws IOException {
|
|
|
InputCapsule capsule = e.getCapsule(this);
|
|
@@ -960,37 +1007,81 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable
|
|
|
w = capsule.readFloat("w", 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the X component of this vector.
|
|
|
+ *
|
|
|
+ * @return x
|
|
|
+ */
|
|
|
public float getX() {
|
|
|
return x;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the X component of this vector.
|
|
|
+ *
|
|
|
+ * @param x the desired value
|
|
|
+ * @return this vector, modified
|
|
|
+ */
|
|
|
public Vector4f setX(float x) {
|
|
|
this.x = x;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the Y component of this vector.
|
|
|
+ *
|
|
|
+ * @return y
|
|
|
+ */
|
|
|
public float getY() {
|
|
|
return y;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the Y component of this vector.
|
|
|
+ *
|
|
|
+ * @param y the desired value
|
|
|
+ * @return this vector, modified
|
|
|
+ */
|
|
|
public Vector4f setY(float y) {
|
|
|
this.y = y;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the Z component of this vector.
|
|
|
+ *
|
|
|
+ * @return z
|
|
|
+ */
|
|
|
public float getZ() {
|
|
|
return z;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the Z component of this vector.
|
|
|
+ *
|
|
|
+ * @param z the desired value
|
|
|
+ * @return this vector, modified
|
|
|
+ */
|
|
|
public Vector4f setZ(float z) {
|
|
|
this.z = z;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the W component of this vector.
|
|
|
+ *
|
|
|
+ * @return w
|
|
|
+ */
|
|
|
public float getW() {
|
|
|
return w;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the W component of this vector.
|
|
|
+ *
|
|
|
+ * @param w the desired value
|
|
|
+ * @return this vector, modified
|
|
|
+ */
|
|
|
public Vector4f setW(float w) {
|
|
|
this.w = w;
|
|
|
return this;
|