Search in sources :

Example 11 with Matrix4f

use of javax.vecmath.Matrix4f in project MinecraftForge by MinecraftForge.

the class TRSRTransformation method blockCornerToCenter.

/**
     * convert transformation from assuming corner-block system to center-block system
     */
public static TRSRTransformation blockCornerToCenter(TRSRTransformation transform) {
    Matrix4f ret = new Matrix4f(transform.getMatrix()), tmp = new Matrix4f();
    tmp.setIdentity();
    tmp.m03 = tmp.m13 = tmp.m23 = -.5f;
    ret.mul(tmp, ret);
    tmp.m03 = tmp.m13 = tmp.m23 = .5f;
    ret.mul(tmp);
    return new TRSRTransformation(ret);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 12 with Matrix4f

use of javax.vecmath.Matrix4f in project ImmersiveEngineering by BluSunrize.

the class ModelConveyor method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
    TileEntity tile = null;
    String key = "default";
    EnumFacing facing = EnumFacing.NORTH;
    if (blockState == null)
        key = conveyor != null ? ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString() : "immersiveengineering:conveyor";
    else {
        facing = blockState.getValue(IEProperties.FACING_ALL);
        if (blockState instanceof IExtendedBlockState) {
            IExtendedBlockState exState = (IExtendedBlockState) blockState;
            if (exState.getUnlistedNames().contains(BlockConveyor.ICONEYOR_PASSTHROUGH))
                conveyor = ((IExtendedBlockState) blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH);
            if (exState.getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
                tile = ((IExtendedBlockState) blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
            if (conveyor != null && tile != null)
                key = conveyor.getModelCacheKey(tile, facing);
        }
    }
    List<BakedQuad> cachedQuads = modelCache.get(key);
    if (cachedQuads != null)
        return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
    else {
        cachedQuads = Collections.synchronizedList(Lists.newArrayList());
        Matrix4f facingMatrix = TRSRTransformation.getMatrix(facing);
        if (conveyor != null)
            facingMatrix = conveyor.modifyBaseRotationMatrix(facingMatrix, tile, facing);
        Matrix4 matrix = new Matrix4(facingMatrix);
        ConveyorDirection conDir = conveyor != null ? conveyor.getConveyorDirection() : ConveyorDirection.HORIZONTAL;
        boolean[] walls = conveyor != null && tile != null ? new boolean[] { conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1) } : new boolean[] { true, true };
        TextureAtlasSprite tex_conveyor = ClientUtils.mc().getTextureMapBlocks().getMissingSprite();
        TextureAtlasSprite tex_conveyor_colour = null;
        int colourStripes = -1;
        if (conveyor != null) {
            tex_conveyor = ClientUtils.getSprite(tile != null ? (conveyor.isActive(tile) ? conveyor.getActiveTexture() : conveyor.getInactiveTexture()) : conveyor.getActiveTexture());
            if ((colourStripes = conveyor.getDyeColour()) >= 0)
                tex_conveyor_colour = ClientUtils.getSprite(conveyor.getColouredStripesTexture());
        }
        cachedQuads.addAll(getBaseConveyor(facing, 1, matrix, conDir, tex_conveyor, walls, new boolean[] { true, true }, tex_conveyor_colour, colourStripes));
        if (conveyor != null)
            cachedQuads = conveyor.modifyQuads(cachedQuads, tile, facing);
        modelCache.put(key, cachedQuads);
        return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ConveyorDirection(blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection) Matrix4(blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)

Example 13 with Matrix4f

use of javax.vecmath.Matrix4f in project ImmersiveEngineering by BluSunrize.

the class Matrix4 method invert.

public final void invert() {
    Matrix4f temp = toMatrix4f();
    temp.invert();
    this.fromMatrix4f(temp);
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 14 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class Camera method fov.

public float fov() {
    Matrix4f p = projection();
    float fov;
    if (type == Type.PERSPECTIVE) {
        fov = (float) (Math.atan(1 / p.m11) * 2);
    } else {
        fov = 2 / p.m11;
    }
    return fov;
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Example 15 with Matrix4f

use of javax.vecmath.Matrix4f in project bdx by GoranM.

the class Camera method projection.

public Matrix4f projection() {
    Matrix4f m = new Matrix4f();
    m.set(data.projection.getValues());
    m.transpose();
    return m;
}
Also used : Matrix4f(javax.vecmath.Matrix4f)

Aggregations

Matrix4f (javax.vecmath.Matrix4f)29 Vector3f (javax.vecmath.Vector3f)10 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)4 Matrix3f (javax.vecmath.Matrix3f)3 Matrix4 (com.badlogic.gdx.math.Matrix4)2 Vector3 (com.badlogic.gdx.math.Vector3)2 ManifoldPoint (com.bulletphysics.collision.narrowphase.ManifoldPoint)2 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 Transform (com.bulletphysics.linearmath.Transform)2 Mesh (com.nilunder.bdx.gl.Mesh)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Vector4f (javax.vecmath.Vector4f)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 ConveyorDirection (blusunrize.immersiveengineering.api.tool.ConveyorHandler.ConveyorDirection)1 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 IMixinTextureAtlasSprite (com.almuradev.content.mixin.iface.IMixinTextureAtlasSprite)1 Face (com.almuradev.content.model.obj.geometry.Face)1 Group (com.almuradev.content.model.obj.geometry.Group)1 Vertex (com.almuradev.content.model.obj.geometry.Vertex)1