use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class OpenVRState method getEyePose.
/**
* Get the pose of an eye.
* @param eyeIndex - An integer specifying the eye: 0 for the left eye, 1 for the right eye.
* @return the pose, as a Matrix4f
*/
public Matrix4f getEyePose(int eyeIndex) {
Matrix4f matrixReturn = new Matrix4f(headPose);
matrixReturn.mul(eyePoses[eyeIndex]);
return matrixReturn;
}
use of org.joml.Matrix4f in project Terasology by MovingBlocks.
the class FirstPersonHeldItemMountPointComponent method poseChanged.
/**
* A callback target for the controller listener. When this callback triggers, the pos of the mount point will
* cuange to the value of the pose parameter. This is mainly designed as a callback, and not intended to be part
* of the public interface of this class.
* @param pose - the controller pose - a homogenous transformation matrix.
* @param handIndex - the hand index - 0 for left and 1 for right.
*/
public void poseChanged(Matrix4f pose, int handIndex) {
// TODO: put a hand for the second controller.
if (handIndex != 0) {
return;
}
trackingDataReceived = true;
Matrix4f adjustedPose = pose.mul(toolAdjustmentMatrix);
translate = new Vector3f(adjustedPose.m30(), adjustedPose.m31(), adjustedPose.m32());
org.joml.Vector4f jomlQuaternion = org.terasology.rendering.openvrprovider.OpenVRUtil.convertToQuaternion(adjustedPose);
if (rotationQuaternion == null) {
rotationQuaternion = new Quat4f(jomlQuaternion.x, jomlQuaternion.y, jomlQuaternion.z, jomlQuaternion.w);
} else {
rotationQuaternion.set(jomlQuaternion.x, jomlQuaternion.y, jomlQuaternion.z, jomlQuaternion.w);
}
}
use of org.joml.Matrix4f in project chunkstories-core by Hugobros3.
the class DefaultItemRenderer method renderItemInWorld.
@Override
public void renderItemInWorld(RenderingInterface renderingInterface, ItemPile pile, World world, Location location, Matrix4f handTransformation) {
Matrix4f handTransformation2 = new Matrix4f(handTransformation);
handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 0.0f, 1.0f));
handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 1.0f, 0.0f));
handTransformation2.translate(new Vector3f(-0.0f, 0.0f, 0.2f));
// handTransformation2.translate(new Vector3f(-0.00f, -0.15f, 0.0f));
handTransformation2.scale(new Vector3f(1.0f, 0.20f * pile.getItem().getDefinition().getSlotsWidth(), 0.20f * pile.getItem().getDefinition().getSlotsHeight()));
renderingInterface.setObjectMatrix(handTransformation2);
textures.getTexture(pile.getTextureName()).setLinearFiltering(false);
Texture2D texture = textures.getTexture(pile.getTextureName());
if (texture == null)
texture = textures.getTexture("items/icons/notex.png");
texture.setLinearFiltering(false);
renderingInterface.bindAlbedoTexture(texture);
draw3DPlane(renderingInterface);
}
use of org.joml.Matrix4f in project chunkstories-core by Hugobros3.
the class GBuffersOpaquePass method render.
@Override
public void render(RenderingInterface renderingInterface) {
if (fbo != null) {
GameWindow gameWindow = pipeline.getRenderingInterface().getWindow();
renderingInterface.getRenderTargetManager().setConfiguration(fbo);
renderingInterface.getRenderTargetManager().clearBoundRenderTargetAll();
// Set fixed-function parameters
renderingInterface.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
renderingInterface.setBlendMode(BlendMode.DISABLED);
renderingInterface.setCullingMode(CullingMode.COUNTERCLOCKWISE);
Shader opaqueBlocksShader = renderingInterface.useShader("blocks_opaque");
Texture2D blocksAlbedoTexture = gameWindow.getClient().getContent().voxels().textures().getDiffuseAtlasTexture();
Texture2D blocksNormalTexture = gameWindow.getClient().getContent().voxels().textures().getNormalAtlasTexture();
Texture2D blocksMaterialTexture = gameWindow.getClient().getContent().voxels().textures().getMaterialAtlasTexture();
renderingInterface.bindAlbedoTexture(blocksAlbedoTexture);
renderingInterface.bindNormalTexture(blocksNormalTexture);
renderingInterface.bindMaterialTexture(blocksMaterialTexture);
renderingInterface.bindTexture2D("lightColors", renderingInterface.textures().getTexture("./textures/environement/light.png"));
renderingInterface.bindTexture2D("vegetationColorTexture", worldRenderer.getWorld().getGenerator().getEnvironment().getGrassTexture(renderingInterface));
// renderingInterface.bindTexture2D("vegetationColorTexture", getGrassTexture());
// Set texturing arguments
blocksAlbedoTexture.setTextureWrapping(false);
blocksAlbedoTexture.setLinearFiltering(false);
blocksAlbedoTexture.setMipMapping(false);
blocksAlbedoTexture.setMipmapLevelsRange(0, 4);
blocksNormalTexture.setTextureWrapping(false);
blocksNormalTexture.setLinearFiltering(false);
blocksNormalTexture.setMipMapping(false);
blocksNormalTexture.setMipmapLevelsRange(0, 4);
blocksMaterialTexture.setTextureWrapping(false);
blocksMaterialTexture.setLinearFiltering(false);
blocksMaterialTexture.setMipMapping(false);
blocksMaterialTexture.setMipmapLevelsRange(0, 4);
// World stuff
opaqueBlocksShader.setUniform1f("mapSize", world.getSizeInChunks() * 32);
opaqueBlocksShader.setUniform1f("overcastFactor", world.getWeather());
opaqueBlocksShader.setUniform1f("wetness", world.getGenerator().getEnvironment().getWorldWetness(renderingInterface.getCamera().getCameraPosition()));
opaqueBlocksShader.setUniform1f("time", worldRenderer.getAnimationTimer());
opaqueBlocksShader.setUniform1f("animationTimer", worldRenderer.getAnimationTimer());
opaqueBlocksShader.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
renderingInterface.getCamera().setupShader(opaqueBlocksShader);
renderingInterface.setObjectMatrix(new Matrix4f());
worldRenderer.getChunksRenderer().renderChunks(renderingInterface);
worldRenderer.getChunksRenderer().renderChunksExtras(renderingInterface);
worldRenderer.getEntitiesRenderer().renderEntities(renderingInterface);
worldRenderer.getParticlesRenderer().renderParticles(renderingInterface);
}
}
use of org.joml.Matrix4f in project chunkstories-api by Hugobros3.
the class CompoundAnimationHelper method getBoneHierarchyTransformationMatrixInternal.
private final Matrix4fc getBoneHierarchyTransformationMatrixInternal(String boneName, double animationTime) {
SkeletalAnimation animation = getAnimationPlayingForBone(boneName, animationTime);
SkeletonBone bone = animation.getBone(boneName);
// Out if null
if (bone == null) {
System.out.println("null bone");
return new Matrix4f();
}
// Get this very bone transformation matrix
Matrix4fc thisBoneMatrix = getBoneTransformationMatrix(boneName, animationTime);
// Transform by parent if existant
SkeletonBone parent = animation.getBone(boneName).getParent();
if (parent != null) {
Matrix4f thisBoneMatrix2 = new Matrix4f();
getBoneHierarchyTransformationMatrixInternal(parent.getName(), animationTime).mul(thisBoneMatrix, thisBoneMatrix2);
return thisBoneMatrix2;
}
return thisBoneMatrix;
}
Aggregations