diff --git a/src/com/osesm/randy/framework/math/Matrix4.java b/src/com/osesm/randy/framework/math/Matrix4.java index 8612ce5..15998ca 100644 --- a/src/com/osesm/randy/framework/math/Matrix4.java +++ b/src/com/osesm/randy/framework/math/Matrix4.java @@ -1,5 +1,7 @@ package com.osesm.randy.framework.math; +import java.nio.FloatBuffer; + import android.opengl.Matrix; public class Matrix4 { @@ -57,12 +59,17 @@ public Matrix4 rotate(float angle, float scaleX, float scaleY, float scaleZ) { } public Matrix4 multiplyByMatrix(Matrix4 otherMatrix) { - Matrix.multiplyMM(tmp, 0, values, 0, otherMatrix.getValues(), 0); + Matrix.multiplyMM(tmp, 0, values, 0, otherMatrix.values(), 0); return new Matrix4(tmp); } - public float[] getValues() { + public float[] values() { return values; } + public FloatBuffer toFloatBuffer() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/src/com/osesm/randy/framework/math/Quaternion.java b/src/com/osesm/randy/framework/math/Quaternion.java index 93ec94a..81957b1 100644 --- a/src/com/osesm/randy/framework/math/Quaternion.java +++ b/src/com/osesm/randy/framework/math/Quaternion.java @@ -119,4 +119,9 @@ public Quaternion add(Quaternion quaternion) { public Quaternion normalize() { return scaled(1 / FloatMath.sqrt(dot(this))); } + + public Matrix4 toMatrix4() { + // TODO Auto-generated method stub + return null; + } } diff --git a/src/com/osesm/randy/framework/math/Vector3.java b/src/com/osesm/randy/framework/math/Vector3.java index 6bbbe15..562cbdb 100644 --- a/src/com/osesm/randy/framework/math/Vector3.java +++ b/src/com/osesm/randy/framework/math/Vector3.java @@ -4,9 +4,13 @@ public class Vector3 { - private float z; - private float y; - private float x; + public float z; + public float y; + public float x; + + public static int size() { + return 3 * 4; + } public Vector3() { } @@ -21,7 +25,7 @@ public Vector3(Vector3 other) { this(other.x, other.y, other.z); } - public Vector3 cpy() { + public Vector3 copy() { return new Vector3(x, y, z); } @@ -93,5 +97,4 @@ private float distanceSquared(float x2, float y2, float z2) { float distanceZ = this.z - z; return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ; } - } diff --git a/src/com/osesm/randy/framework/math/Vector4.java b/src/com/osesm/randy/framework/math/Vector4.java new file mode 100644 index 0000000..6d75611 --- /dev/null +++ b/src/com/osesm/randy/framework/math/Vector4.java @@ -0,0 +1,66 @@ +package com.osesm.randy.framework.math; + +import java.nio.FloatBuffer; + +public class Vector4 { + public float x; + public float y; + public float z; + public float w; + + public Vector4() { + } + + public Vector4(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = 1.0f; + } + + public Vector4(Vector4 other) { + this(other.x, other.y, other.z, other.w); + } + + public Vector4 copy() { + return new Vector4(x, y, z, w); + } + + public Vector4 add(float x, float y, float z, float w) { + this.x += x; + this.y += y; + this.z += z; + this.w += w; + return this; + } + + public Vector4 add(Vector4 other) { + return add(other.x, other.y, other.z, other.w); + } + + public Vector4 sub(float x, float y, float z, float w) { + this.x -= x; + this.y -= y; + this.z -= z; + this.w -= w; + return this; + } + + public Vector4 sub(Vector4 other) { + return sub(other.x, other.y, other.z, other.w); + } + + public Vector4 mul(float scalar) { + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + return this; + } + + public FloatBuffer toFloatBuffer() { + // TODO Auto-generated method stub + return null; + } + + +}