|
|
@ -48,19 +48,47 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
static final long serialVersionUID = 1; |
|
|
|
static final long serialVersionUID = 1; |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = Logger.getLogger(Vector4f.class.getName()); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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); |
|
|
|
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( |
|
|
|
public final static Vector4f POSITIVE_INFINITY = new Vector4f( |
|
|
|
Float.POSITIVE_INFINITY, |
|
|
|
Float.POSITIVE_INFINITY, |
|
|
|
Float.POSITIVE_INFINITY, |
|
|
|
Float.POSITIVE_INFINITY, |
|
|
|
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( |
|
|
|
public final static Vector4f NEGATIVE_INFINITY = new Vector4f( |
|
|
|
Float.NEGATIVE_INFINITY, |
|
|
|
Float.NEGATIVE_INFINITY, |
|
|
|
Float.NEGATIVE_INFINITY, |
|
|
|
Float.NEGATIVE_INFINITY, |
|
|
@ -824,6 +852,11 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create a copy of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return a new instance, equivalent to this one |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Vector4f clone() { |
|
|
|
public Vector4f clone() { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -942,6 +975,13 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
return "(" + x + ", " + y + ", " + z + ", " + w + ")"; |
|
|
|
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 |
|
|
|
@Override |
|
|
|
public void write(JmeExporter e) throws IOException { |
|
|
|
public void write(JmeExporter e) throws IOException { |
|
|
|
OutputCapsule capsule = e.getCapsule(this); |
|
|
|
OutputCapsule capsule = e.getCapsule(this); |
|
|
@ -951,6 +991,13 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
capsule.write(w, "w", 0); |
|
|
|
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 |
|
|
|
@Override |
|
|
|
public void read(JmeImporter e) throws IOException { |
|
|
|
public void read(JmeImporter e) throws IOException { |
|
|
|
InputCapsule capsule = e.getCapsule(this); |
|
|
|
InputCapsule capsule = e.getCapsule(this); |
|
|
@ -960,37 +1007,81 @@ public final class Vector4f implements Savable, Cloneable, java.io.Serializable |
|
|
|
w = capsule.readFloat("w", 0); |
|
|
|
w = capsule.readFloat("w", 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Determine the X component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return x |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getX() { |
|
|
|
public float getX() { |
|
|
|
return x; |
|
|
|
return x; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Alter the X component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param x the desired value |
|
|
|
|
|
|
|
* @return this vector, modified |
|
|
|
|
|
|
|
*/ |
|
|
|
public Vector4f setX(float x) { |
|
|
|
public Vector4f setX(float x) { |
|
|
|
this.x = x; |
|
|
|
this.x = x; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Determine the Y component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return y |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getY() { |
|
|
|
public float getY() { |
|
|
|
return y; |
|
|
|
return y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Alter the Y component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param y the desired value |
|
|
|
|
|
|
|
* @return this vector, modified |
|
|
|
|
|
|
|
*/ |
|
|
|
public Vector4f setY(float y) { |
|
|
|
public Vector4f setY(float y) { |
|
|
|
this.y = y; |
|
|
|
this.y = y; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Determine the Z component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return z |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getZ() { |
|
|
|
public float getZ() { |
|
|
|
return z; |
|
|
|
return z; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Alter the Z component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param z the desired value |
|
|
|
|
|
|
|
* @return this vector, modified |
|
|
|
|
|
|
|
*/ |
|
|
|
public Vector4f setZ(float z) { |
|
|
|
public Vector4f setZ(float z) { |
|
|
|
this.z = z; |
|
|
|
this.z = z; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Determine the W component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return w |
|
|
|
|
|
|
|
*/ |
|
|
|
public float getW() { |
|
|
|
public float getW() { |
|
|
|
return w; |
|
|
|
return w; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Alter the W component of this vector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param w the desired value |
|
|
|
|
|
|
|
* @return this vector, modified |
|
|
|
|
|
|
|
*/ |
|
|
|
public Vector4f setW(float w) { |
|
|
|
public Vector4f setW(float w) { |
|
|
|
this.w = w; |
|
|
|
this.w = w; |
|
|
|
return this; |
|
|
|
return this; |
|
|
|