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);
}
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));
}
}
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);
}
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;
}
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;
}
Aggregations