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


Java Matrix4f.mul方法代码示例

本文整理汇总了Java中org.joml.Matrix4f.mul方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4f.mul方法的具体用法?Java Matrix4f.mul怎么用?Java Matrix4f.mul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joml.Matrix4f的用法示例。


在下文中一共展示了Matrix4f.mul方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderTile

import org.joml.Matrix4f; //导入方法依赖的package包/类
public void renderTile(Tile tile, int x, int y, Shader shader, Matrix4f world, Camera camera) {
    shader.bind();
    if (tile_textures.containsKey(tile.getTexture() ))
        tile_textures.get(tile.getTexture()).bind(0);

    Matrix4f tile_position = new Matrix4f().translate(new Vector3f(x * 2, y * 2, 0));
    Matrix4f target = new Matrix4f();

    camera.getProjection().mul(world, target);
    target.mul(tile_position);

    shader.setUniform("sampler", 0);
    shader.setUniform("projection", target);

    model.render();
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:17,代码来源:TileRenderer.java

示例2: render

import org.joml.Matrix4f; //导入方法依赖的package包/类
public void render(Shader shader, Camera camera, World world) {
    Matrix4f target = camera.getProjection();
    target.mul(world.getWorldMatrix());

    shader.bind();
    shader.setUniform("sampler", 0);
    shader.setUniform("projection", transform.getProjection(target));
    animations[use_animation].bind(0);
    model.render();
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:11,代码来源:Entity.java

示例3: renderTile

import org.joml.Matrix4f; //导入方法依赖的package包/类
public void renderTile(Tile tile, int x, int y, Shader shader, Matrix4f world, Camera cam) {
	shader.bind();
	if (tileTextures.containsKey(tile.getTexture())) tileTextures.get(tile.getTexture()).bind(0);
	
	Matrix4f tile_pos = new Matrix4f().translate(new Vector3f(x * 2, y * 2, 0));
	Matrix4f target = new Matrix4f();
	
	cam.getProjection().mul(world, target);
	target.mul(tile_pos);
	
	shader.setUniform("sampler", 0);
	shader.setUniform("projection", target);
	
	tileModel.render();
}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:16,代码来源:TileRenderer.java

示例4: onRenderUpdate

import org.joml.Matrix4f; //导入方法依赖的package包/类
@Override
protected void onRenderUpdate(RenderEngine renderEngine)
{
	Scene scene = Pong.ENGINE.getSceneManager().getCurrentScene();
	Pong pong = (Pong) scene;

	this.renderer.bind(pong.getCamera().view(), pong.getCamera().projection());
	{
		Collection<Entity> entities = pong.getEntityManager().getEntitiesWith(new HashSet<>(), ComponentRenderable.class);
		final Matrix4f transform = new Matrix4f();
		for (Entity entity : entities)
		{
			ComponentRenderable componentRenderable = entity.getComponent(ComponentRenderable.class);
			Model model = componentRenderable.customModel;
			if (model == null)
			{
				model = this.modelManager.getModel(componentRenderable.modelName);
			}

			ComponentTransform componentTransform = entity.getComponent(ComponentTransform.class);
			if (componentTransform != null)
			{
				componentTransform.transform.getTransformation(transform);
			}
			transform.mul(model.transformation());

			this.renderer.draw(model.getMesh(), model.material(), transform);
		}
	}
	this.renderer.unbind();
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:32,代码来源:PongRenderer.java

示例5: getModelViewMatrix

import org.joml.Matrix4f; //导入方法依赖的package包/类
public Matrix4f getModelViewMatrix(GameItem gameItem, Matrix4f viewMatrix) {
    Matrix4f rotation = gameItem.getRotationMatrix();
    modelViewMatrix.identity().translate(gameItem.getPosition()).mul(rotation)
            .scale(gameItem.getScale());
    Matrix4f viewCurr = new Matrix4f(viewMatrix);
    return viewCurr.mul(modelViewMatrix);
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:8,代码来源:Transformation.java

示例6: processAnimationFrame

import org.joml.Matrix4f; //导入方法依赖的package包/类
private static AnimatedFrame processAnimationFrame(MD5Model md5Model, MD5AnimModel animModel, MD5Frame frame,
                                                   List<Matrix4f> invJointMatrices) {
    AnimatedFrame result = new AnimatedFrame();

    MD5BaseFrame baseFrame = animModel.getBaseFrame();
    List<MD5Hierarchy.MD5HierarchyData> hierarchyList = animModel.getHierarchy().getHierarchyDataList();

    List<MD5JointInfo.MD5JointData> joints = md5Model.getJointInfo().getJoints();
    int numJoints = joints.size();
    float[] frameData = frame.getFrameData();
    for (int i = 0; i < numJoints; i++) {
        MD5JointInfo.MD5JointData joint = joints.get(i);
        MD5BaseFrame.MD5BaseFrameData baseFrameData = baseFrame.getFrameDataList().get(i);
        Vector3f position = baseFrameData.getPosition();
        Quaternionf orientation = baseFrameData.getOrientation();

        int flags = hierarchyList.get(i).getFlags();
        int startIndex = hierarchyList.get(i).getStartIndex();

        if ((flags & 1) > 0) {
            position.x = frameData[startIndex++];
        }
        if ((flags & 2) > 0) {
            position.y = frameData[startIndex++];
        }
        if ((flags & 4) > 0) {
            position.z = frameData[startIndex++];
        }
        if ((flags & 8) > 0) {
            orientation.x = frameData[startIndex++];
        }
        if ((flags & 16) > 0) {
            orientation.y = frameData[startIndex++];
        }
        if ((flags & 32) > 0) {
            orientation.z = frameData[startIndex++];
        }
        // Update Quaternion's w component
        orientation = MD5Utils.calculateQuaternion(orientation.x, orientation.y, orientation.z);

        // Calculate translation and rotation matrices for this joint
        Matrix4f translateMat = new Matrix4f().translate(position);
        Matrix4f rotationMat = new Matrix4f().rotate(orientation);
        Matrix4f jointMat = translateMat.mul(rotationMat);

        // Joint position is relative to joint's parent index position. Use parent matrices
        // to transform it to model space
        if (joint.getParentIndex() > -1) {
            Matrix4f parentMatrix = result.getLocalJointMatrices()[joint.getParentIndex()];
            jointMat = new Matrix4f(parentMatrix).mul(jointMat);
        }

        result.setMatrix(i, jointMat, invJointMatrices.get(i));
    }

    return result;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:58,代码来源:MD5Loader.java

示例7: setMatrix

import org.joml.Matrix4f; //导入方法依赖的package包/类
public void setMatrix(int pos, Matrix4f localJointMatrix, Matrix4f invJointMatrix) {
    localJointMatrices[pos] = localJointMatrix;
    Matrix4f mat = new Matrix4f(localJointMatrix);
    mat.mul(invJointMatrix);
    jointMatrices[pos] = mat;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:7,代码来源:AnimatedFrame.java

示例8: addRotation

import org.joml.Matrix4f; //导入方法依赖的package包/类
public void addRotation(Matrix4f additionalRotation) {
  Matrix4f additional = new Matrix4f(additionalRotation);
  this.rotation = additional.mul(this.rotation);
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:5,代码来源:GameItem.java

示例9: getRotationMultiplier

import org.joml.Matrix4f; //导入方法依赖的package包/类
/**
 * Get the additional rotation matrix, which should be multiplied by the current rotation matrix to get the new rotation matrix
 */
public static Matrix4f getRotationMultiplier(float x, float y, float z) {

  float rotateXAngle = (float) Math.toRadians(x);
  float rotateYAngle = (float) Math.toRadians(y);
  float rotateZAngle = (float) Math.toRadians(z);

  Matrix4f rotationUpdate = new Matrix4f().identity();

  if (rotateXAngle!=0) {
    Matrix4f xRotation = new Matrix4f().identity();
    float sinAlpha = (float) Math.sin(rotateXAngle);
    float cosAlpha = (float) Math.cos(rotateXAngle);
    xRotation.m11(cosAlpha);
    xRotation.m12(-sinAlpha);
    xRotation.m21(sinAlpha);
    xRotation.m22(cosAlpha);

    rotationUpdate.mul(xRotation);
  }
  if (rotateYAngle!=0) {
    Matrix4f yRotation = new Matrix4f().identity();
    float sinBeta = (float) Math.sin(rotateYAngle);
    float cosBeta = (float) Math.cos(rotateYAngle);
    yRotation.m00(cosBeta);
    yRotation.m02(sinBeta);
    yRotation.m20(-sinBeta);
    yRotation.m22(cosBeta);

    rotationUpdate.mul(yRotation);
  }
  if (rotateZAngle!=0) {
    Matrix4f zRotation = new Matrix4f().identity();
    float sinGamma = (float) Math.sin(rotateZAngle);
    float cosGamma = (float) Math.cos(rotateZAngle);
    zRotation.m00(cosGamma);
    zRotation.m01(-sinGamma);
    zRotation.m10(sinGamma);
    zRotation.m11(cosGamma);

    rotationUpdate.mul(zRotation);
  }

  return rotationUpdate;


}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:50,代码来源:GameItem.java


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