Search in sources :

Example 1 with Matrix4f

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;
}
Also used : Matrix4f(org.joml.Matrix4f)

Example 2 with Matrix4f

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);
    }
}
Also used : Matrix4f(org.joml.Matrix4f) Vector3f(org.terasology.math.geom.Vector3f) Quat4f(org.terasology.math.geom.Quat4f)

Example 3 with Matrix4f

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);
}
Also used : Matrix4f(org.joml.Matrix4f) Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector3f(org.joml.Vector3f)

Example 4 with Matrix4f

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);
    }
}
Also used : GameWindow(io.xol.chunkstories.api.rendering.GameWindow) Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Matrix4f(org.joml.Matrix4f) Shader(io.xol.chunkstories.api.rendering.shader.Shader)

Example 5 with Matrix4f

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;
}
Also used : Matrix4fc(org.joml.Matrix4fc) Matrix4f(org.joml.Matrix4f) SkeletonBone(io.xol.chunkstories.api.animation.SkeletalAnimation.SkeletonBone)

Aggregations

Matrix4f (org.joml.Matrix4f)62 Vector3f (org.joml.Vector3f)34 Quaternionf (org.joml.Quaternionf)13 LocationComponent (org.terasology.engine.logic.location.LocationComponent)7 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)5 Vector3d (org.joml.Vector3d)5 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)5 Shader (io.xol.chunkstories.api.rendering.shader.Shader)4 AABBf (org.terasology.joml.geom.AABBf)4 com.badlogic.gdx.physics.bullet.collision.btPairCachingGhostObject (com.badlogic.gdx.physics.bullet.collision.btPairCachingGhostObject)3 TFloatArrayList (gnu.trove.list.array.TFloatArrayList)3 Location (io.xol.chunkstories.api.Location)3 GameWindow (io.xol.chunkstories.api.rendering.GameWindow)3 ByteBuffer (java.nio.ByteBuffer)3 Matrix3f (org.joml.Matrix3f)3 Vector4f (org.joml.Vector4f)3 PointerBuffer (org.lwjgl.PointerBuffer)3 Camera (org.terasology.engine.rendering.cameras.Camera)3 ClosestRayResultCallback (com.badlogic.gdx.physics.bullet.collision.ClosestRayResultCallback)2 TFloatList (gnu.trove.list.TFloatList)2