/** * translate the matrix in matrix space * <p/> * @param vec translation vector * <p/> * @return the manipulated matrix */ public Matrix4 translate(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return translate(t.getX(), t.getY(), t.getZ()); }
public Matrix4 setWorldTranslate(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return setWorldTranslate(t.getX(), t.getY(), t.getZ()); }
/** * translate the matrix in world space * <p/> * @param vec translation vector * <p/> * @return the manipulated matrix */ public Matrix4 worldTranslate(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return worldTranslate(t.getX(), t.getY(), t.getZ()); }
/** * scales the matrix space * <p/> * @param scale scale factor vector * <p/> * @return the manipulated matrix */ public Matrix4 scale(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return scale(t.getX(), t.getY(), t.getZ()); }
/** * Rotates the GenericMatrix with the given Eular Angles. Rotation order is * x,y,z. * <p/> * @param angles 3D Vector which holds the rotation angles for each axis * <p/> * @return the same GenericMatrix */ public Matrix4 rotateEuler(ImmutableVector<Vector3> vec) { Vector3 t = vec.clone(); return rotateEuler(t.getX(), t.getY(), t.getZ()); }
private Float[] calculateTangent(Vertex v0, Vertex v1, Vertex v2) { Vector3 pos1 = getPosition(v0); Vector3 pos2 = getPosition(v1); Vector3 pos3 = getPosition(v2); Vector2 uv1 = getTexCoord(v0); Vector2 uv2 = getTexCoord(v1); Vector2 uv3 = getTexCoord(v2); Vector3 v2v1 = pos2.clone().sub(pos1); Vector3 v3v1 = pos3.clone().sub(pos1); float c2c1b = uv2.getY() - uv1.getY(); float c3c1b = uv3.getY() - uv1.getY(); Vector3 n = getNormal(v0); Vector3 t = new Vector3(c3c1b * v2v1.getX() - c2c1b * v3v1.getX(), c3c1b * v2v1.getY() - c2c1b * v3v1.getY(), c3c1b * v2v1.getZ() - c2c1b * v3v1.getZ()); Vector3 b = n.cross(t); Vector3 smoothTangent = b.cross(n).normalize(); return float2Float(smoothTangent.getCoords()); }
/** * Builds a orthogonal Coordinate System, where the given Vector represents * the given Axis. Both other Axis are generated in a way that no gurantee * can be given how their orientation are. * <p/> * @param dir direction Vector of the given Axis * @param a Axis of the given Vektor */ public static Matrix4 createCoordinateSystem(ImmutableVector<Vector3> dir, Axis a) { Matrix4 res = new Matrix4(); res.loadIdentity(); Vector3 di = dir.clone().normalize(); res.setAxis(di, a); Vector3 dir2 = new Vector3(di.getY(), di.getZ(), -di.getX()); Vector3 dir3 = dir.clone().cross(dir2); Axis[] vals = Axis.values(); int a2 = a.ordinal(); a2 = (1 << a2) & 3; //(ordinal+1)%3 int a3 = (1 << a2) & 3;//(ordinal+2)%3 res.setAxis(dir2, vals[a2]); res.setAxis(dir3, vals[a3]); return res; }