当前位置: 首页>>代码示例>>Java>>正文


Java Matrix4f类代码示例

本文整理汇总了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));
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:18,代码来源:EntityPlayer.java

示例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;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:24,代码来源:Quat4.java

示例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;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:23,代码来源:MatrixUtil.java

示例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);
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:21,代码来源:Camera.java

示例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));
	}
}
 
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:21,代码来源:AnimationLoader.java

示例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;
}
 
开发者ID:Biacode,项目名称:bia-engine,代码行数:11,代码来源:Maths.java

示例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;
}
 
开发者ID:DevipriyaSarkar,项目名称:Terrain,代码行数:11,代码来源:Maths.java

示例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;
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:11,代码来源:Maths.java

示例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;
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:15,代码来源:MasterRenderer.java

示例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();
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:8,代码来源:EntityRenderer.java

示例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();
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:9,代码来源:TerrainRenderer.java

示例12: getTransform

import org.lwjgl.util.vector.Matrix4f; //导入依赖的package包/类
@Override
public Matrix4f getTransform(){
	
	TRANSFORM.setIdentity();
	POS.set(spacePos);
	TRANSFORM.translate(POS);
	return TRANSFORM;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:9,代码来源:Chunk.java

示例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;
}
 
开发者ID:Essentria,项目名称:Elgin-Plant-Game,代码行数:16,代码来源:Maths.java

示例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;
}
 
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:16,代码来源:Camera.java

示例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;
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:42,代码来源:Quaternion.java


注:本文中的org.lwjgl.util.vector.Matrix4f类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。