本文整理匯總了Java中org.lwjgl.util.vector.Matrix4f類的典型用法代碼示例。如果您正苦於以下問題:Java Matrix4f類的具體用法?Java Matrix4f怎麽用?Java Matrix4f使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Matrix4f類屬於org.lwjgl.util.vector包,在下文中一共展示了Matrix4f類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: update
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
@Override
public void update(){
updatePrevs();
pos.y(65);
if(model.isLoaded()&&!model.getFrustrumShape().withTransform(scale, rot).isVisibleAt(pos, Game.get().renderer.frustrum)){
Vec3f vec=new Vec3f(0, -((FrustrumCube)model.getFrustrumShape()).getSizeY()*scale.y()*1.4F, 0);
rot.rotate(vec);
vec.add(Game.get().renderer.getCamera().pos).sub(pos).normalize().directionToEuler();
Matrix4f mat=new Matrix4f();
MatrixUtil.rotateX(mat, vec.x());
MatrixUtil.rotateY(mat, vec.y());
Quat4.interpolate(rot, rot, new Quat4().fromMatrix(mat), 0.2F);
}
// rot.set(Game.get().renderer.getCamera().activeRotQuat);
//this.pos.add(RandUtil.RF(0.1), RandUtil.RF(0.1), RandUtil.RF(0.1));
}
示例2: toRotationMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public Matrix4f toRotationMatrix(Matrix4f dest){
final float xy=x*y,xz=x*z,xw=x*w,yz=y*z,yw=y*w,zw=z*w,xSquared=x*x,ySquared=y*y,zSquared=z*z;
dest.m00=1-2*(ySquared+zSquared);
dest.m01=2*(xy-zw);
dest.m02=2*(xz+yw);
dest.m03=0;
dest.m10=2*(xy+zw);
dest.m11=1-2*(xSquared+zSquared);
dest.m12=2*(yz-xw);
dest.m13=0;
dest.m20=2*(xz-yw);
dest.m21=2*(yz+xw);
dest.m22=1-2*(xSquared+ySquared);
dest.m23=0;
dest.m30=0;
dest.m31=0;
dest.m32=0;
dest.m33=1;
return dest;
}
示例3: equals
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public static boolean equals(Matrix4f mat1, Matrix4f mat2){
if(mat1==null?mat2==null:mat1==mat2) return true;
return mat1.m00==mat2.m00&&
mat1.m01==mat2.m01&&
mat1.m02==mat2.m02&&
mat1.m03==mat2.m03&&
mat1.m10==mat2.m10&&
mat1.m11==mat2.m11&&
mat1.m12==mat2.m12&&
mat1.m13==mat2.m13&&
mat1.m20==mat2.m20&&
mat1.m21==mat2.m21&&
mat1.m22==mat2.m22&&
mat1.m23==mat2.m23&&
mat1.m30==mat2.m30&&
mat1.m31==mat2.m31&&
mat1.m32==mat2.m32&&
mat1.m33==mat2.m33;
}
示例4: Camera
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
/**
* Creates a camera with the specified projection matrix
* @param projection
*/
public Camera(Matrix4f projection) {
this.projection = projection;
// Set the view to a default identity matrix
view = new Matrix4f();
// Set the position to origin
position = new Vector3f();
// Set the orientation to standard
orientation = new Quaternion();
// Create the default local axes (right handed)
up = new Vector3f(AXIS_Y);
forward = new Vector3f(AXIS_Z).negate(null);
right = new Vector3f(AXIS_X);
}
示例5: processTransforms
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
private void processTransforms(String jointName, String[] rawData, KeyFrameData[] keyFrames, boolean root){
FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
float[] matrixData = new float[16];
for(int i=0;i<keyFrames.length;i++){
for(int j=0;j<16;j++){
matrixData[j] = Float.parseFloat(rawData[i*16 + j]);
}
buffer.clear();
buffer.put(matrixData);
buffer.flip();
Matrix4f transform = new Matrix4f();
transform.load(buffer);
transform.transpose();
if(root){
//because up axis in Blender is different to up axis in game
Matrix4f.mul(CORRECTION, transform, transform);
}
keyFrames[i].addJointTransform(new JointTransformData(jointName, transform));
}
}
示例6: createTransformationMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public static Matrix4f createTransformationMatrix(final Vector3f translation, final float rx, final float ry, final float rz, final float scale) {
final Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
Matrix4f.translate(translation, matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1, 0, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0, 1, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0, 0, 1), matrix, matrix);
Matrix4f.scale(new Vector3f(scale, scale, scale), matrix, matrix);
return matrix;
}
示例7: createTransformationMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public static Matrix4f createTransformationMatrix(Vector3f translation, float rx, float ry, float rz, float scale) {
Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
Matrix4f.translate(translation, matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1, 0, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0, 1, 0), matrix, matrix);
Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0, 0, 1), matrix, matrix);
Matrix4f.scale(new Vector3f(scale, scale, scale), matrix, matrix);
return matrix;
}
示例8: createViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public static Matrix4f createViewMatrix(Camera camera) {
Matrix4f viewMatrix = new Matrix4f();
viewMatrix.setIdentity();
Matrix4f.rotate((float) Math.toRadians(camera.getPitch()), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(camera.getYaw()), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);
Vector3f cameraPos = camera.getPosition();
Vector3f negativeCameraPos = new Vector3f(-cameraPos.x, -cameraPos.y, -cameraPos.z);
Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix);
return viewMatrix;
}
示例9: createProjectionMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
private void createProjectionMatrix() {
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
float x_scale = y_scale / aspectRatio;
float frustum_lenght = FAR_PLANE - NEAR_PLANE;
projectionMatrix = new Matrix4f();
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_lenght);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_lenght);
projectionMatrix.m33 = 0;
}
示例10: EntityRenderer
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public EntityRenderer(StaticShader shader, Matrix4f projectionMatrix) {
this.shader = shader;
shader.start();
shader.loadAmbientalLight(0.5f);
shader.loadProjectionMatrix(projectionMatrix);
shader.stop();
}
示例11: TerrainRenderer
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
public TerrainRenderer(TerrainShader shader, Matrix4f projectionMatrix) {
this.shader = shader;
shader.start();
shader.loadAmbientalLight(0.6f);
shader.loadProjectionMatrix(projectionMatrix);
shader.connectTextureUnits();
shader.stop();
}
示例12: getTransform
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
@Override
public Matrix4f getTransform(){
TRANSFORM.setIdentity();
POS.set(spacePos);
TRANSFORM.translate(POS);
return TRANSFORM;
}
示例13: createViewMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
/**
* Creates view matrix based off camera for rendering
* @param camera - camera to base view matrix
* @return - New view matrix
*/
public static Matrix4f createViewMatrix(Camera camera) {
Matrix4f viewMatrix = new Matrix4f();
viewMatrix.setIdentity();
Matrix4f.rotate((float) Math.toRadians(camera.getPitch()), new Vector3f(1, 0, 0), viewMatrix, viewMatrix);
Matrix4f.rotate((float) Math.toRadians(camera.getYaw()), new Vector3f(0, 1, 0), viewMatrix, viewMatrix);
Vector3f cameraPos = camera.getPosition();
Vector3f negativeCameraPos = new Vector3f(-cameraPos.x, -cameraPos.y, -cameraPos.z);
Matrix4f.translate(negativeCameraPos, viewMatrix, viewMatrix);
return viewMatrix;
}
示例14: createProjectionMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
private static Matrix4f createProjectionMatrix() {
Matrix4f projectionMatrix = new Matrix4f();
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))));
float x_scale = y_scale / aspectRatio;
float frustum_length = FAR_PLANE - NEAR_PLANE;
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
projectionMatrix.m33 = 0;
return projectionMatrix;
}
示例15: toRotationMatrix
import org.lwjgl.util.vector.Matrix4f; //導入依賴的package包/類
/**
* Converts the quaternion to a 4x4 matrix representing the exact same
* rotation as this quaternion. (The rotation is only contained in the
* top-left 3x3 part, but a 4x4 matrix is returned here for convenience
* seeing as it will be multiplied with other 4x4 matrices).
*
* More detailed explanation here:
* http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/
*
* @return The rotation matrix which represents the exact same rotation as
* this quaternion.
*/
public Matrix4f toRotationMatrix(){
Matrix4f matrix=new Matrix4f();
final float xy=x*y;
final float xz=x*z;
final float xw=x*w;
final float yz=y*z;
final float yw=y*w;
final float zw=z*w;
final float xSquared=x*x;
final float ySquared=y*y;
final float zSquared=z*z;
matrix.m00=1-2*(ySquared+zSquared);
matrix.m01=2*(xy-zw);
matrix.m02=2*(xz+yw);
matrix.m03=0;
matrix.m10=2*(xy+zw);
matrix.m11=1-2*(xSquared+zSquared);
matrix.m12=2*(yz-xw);
matrix.m13=0;
matrix.m20=2*(xz-yw);
matrix.m21=2*(yz+xw);
matrix.m22=1-2*(xSquared+ySquared);
matrix.m23=0;
matrix.m30=0;
matrix.m31=0;
matrix.m32=0;
matrix.m33=1;
return matrix;
}