use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.
the class GateIntegratedCircuit method renderStatic.
// Rendering
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
switch(getFace()) {
case DOWN:
break;
case UP:
renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
break;
case NORTH:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case SOUTH:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case WEST:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case EAST:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
default:
break;
}
int rotation = getRotation();
if (rotation != -1)
renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
IIcon[] icons = new IIcon[] { getIcon(ForgeDirection.DOWN), getIcon(ForgeDirection.UP), getIcon(ForgeDirection.WEST), getIcon(ForgeDirection.EAST), getIcon(ForgeDirection.NORTH), getIcon(ForgeDirection.SOUTH) };
renderer.renderBox(new Vec3dCube(0, 0, 0, 1, 1 / 16D, 1), icons);
renderer.renderBox(new Vec3dCube(0, 1 / 16D, 0, 1, 2 / 16D, 1 / 16D), icons);
renderer.renderBox(new Vec3dCube(0, 1 / 16D, 15 / 16D, 1, 2 / 16D, 1), icons);
renderer.renderBox(new Vec3dCube(0, 1 / 16D, 0, 1 / 16D, 2 / 16D, 1), icons);
renderer.renderBox(new Vec3dCube(15 / 16D, 1 / 16D, 0, 1, 2 / 16D, 1), icons);
for (IGateComponent c : getComponents()) c.renderStatic(translation, renderer, pass);
double scale = (1 - border * 2D) / getSize();
renderer.addTransformation(new Scale(scale, scale, scale));
for (int x = 0; x < getSize(); x++) {
for (int z = 0; z < getSize(); z++) {
IIntegratedCircuitPart part = getPart(x, z);
if (part == null)
continue;
int s = getSize();
if (s % 2 == 1)
s -= 1;
double a = (getSize() - 1) / 2D;
renderer.addTransformation(new Translation(-(s - x - a), -a, -(s - z - a)));
part.renderStatic(translation, renderer, renderBlocks, pass);
renderer.addTransformation(new Translation(s - x - a, a, s - z - a));
}
}
renderer.removeTransformation();
return true;
}
use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.
the class GateNullCell method drawHighlight.
@Override
public boolean drawHighlight(QMovingObjectPosition mop, EntityPlayer player, float frame) {
Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
Vec3 pos = player.getPosition(frame);
ItemStack held = player.getCurrentEquippedItem();
if (held == null)
return false;
if (held.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) held.getItem()).createPart(held, player, null, null);
if (part == null)
return false;
if (!(part instanceof PartRedwireFaceUninsulated))
return false;
PartRedwireFace wire = (PartRedwireFace) part;
RenderHelper renderer = RenderHelper.instance;
renderer.fullReset();
renderer.setRenderCoords(getWorld(), getX(), getY(), getZ());
double height = 2 / 16D;
IIcon wireIcon = IconSupplier.wire;
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.addTranslation((float) -pos.xCoord, (float) -pos.yCoord, (float) -pos.zCoord);
{
switch(getFace()) {
case DOWN:
break;
case UP:
renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
break;
case NORTH:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case SOUTH:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case WEST:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case EAST:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
default:
break;
}
int rotation = getRotation();
if (rotation != -1)
renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
renderer.setOpacity(0.5);
renderer.setColor(WireHelper.getColorForPowerLevel(wire.getRedwireType(ForgeDirection.UNKNOWN), (byte) (255 / 2)));
ForgeDirection dir = ForgeDirection.NORTH;
if (getRotation() % 2 == 1)
dir = dir.getRotation(getFace());
if (hit.getY() > 2 / 16D) {
if (typeB == null) {
renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wireIcon);
renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wireIcon);
}
} else {
if (typeA == null)
renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + height, 16 / 16D), wireIcon);
}
renderer.fullReset();
}
Tessellator.instance.addTranslation((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord);
Tessellator.instance.draw();
GL11.glDisable(GL11.GL_BLEND);
return true;
} else if (held.getItem() instanceof IScrewdriver) {
// List<Vec3dCube> l = new ArrayList<Vec3dCube>();
// super.addBoxes(l);
// boolean def = false;
// for (Vec3dCube c : l)
// if (mop.getCube().equals(c.clone().rotate(getFace(), Vec3d.center).rotate(0, 90 * -getRotation(), 0, Vec3d.center)))
// def = true;
// if (def || hit.getY() <= 2 / 16D) {
// Vec3dCube c = Vec3dCube.merge(getSelectionBoxes()).expand(0.001);
//
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// GL11.glDisable(GL11.GL_TEXTURE_2D);
// GL11.glColor4f(0, 0, 0, 0.4F);
// GL11.glLineWidth(2);
// GL11.glDepthMask(true);
// GL11.glPushMatrix();
//
// Tessellator var2 = Tessellator.instance;
// var2.startDrawing(3);
// Tessellator.instance.addTranslation((float) -pos.xCoord + getX(), (float) -pos.yCoord + getY(), (float) -pos.zCoord
// + getZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(3);
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.draw();
// var2.startDrawing(1);
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
// var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
// var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
// Tessellator.instance.addTranslation((float) pos.xCoord - getX(), (float) pos.yCoord - getY(), (float) pos.zCoord - getZ());
// var2.draw();
//
// GL11.glPopMatrix();
// GL11.glDepthMask(false);
// GL11.glEnable(GL11.GL_TEXTURE_2D);
// GL11.glDisable(GL11.GL_BLEND);
//
// return true;
// }
//
// return true;
}
return false;
}
use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.
the class PartWireFace method renderStatic.
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
renderer.setIgnoreLighting(shouldIgnoreLighting());
renderer.setLightingOverride(getBrightness());
double height = (getHeight() / 16D) - 0.001;
double width = getWidth() / 32D;
int color = getColorMultiplier();
ForgeDirection d1 = ForgeDirection.NORTH;
ForgeDirection d2 = ForgeDirection.SOUTH;
ForgeDirection d3 = ForgeDirection.WEST;
ForgeDirection d4 = ForgeDirection.EAST;
if (getFace() == ForgeDirection.NORTH) {
d1 = ForgeDirection.UP;
d2 = ForgeDirection.DOWN;
} else if (getFace() == ForgeDirection.SOUTH) {
d1 = ForgeDirection.DOWN;
d2 = ForgeDirection.UP;
} else if (getFace() == ForgeDirection.WEST) {
d3 = ForgeDirection.UP;
d4 = ForgeDirection.DOWN;
} else if (getFace() == ForgeDirection.EAST) {
d3 = ForgeDirection.DOWN;
d4 = ForgeDirection.UP;
} else if (getFace() == ForgeDirection.UP) {
d3 = ForgeDirection.EAST;
d4 = ForgeDirection.WEST;
}
switch(getFace()) {
case DOWN:
break;
case UP:
renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
break;
case NORTH:
renderer.addTransformation(new Rotation(90, 90, 0, Vec3d.center));
d1 = d1.getRotation(getFace());
d2 = d2.getRotation(getFace());
d3 = d3.getRotation(getFace());
d4 = d4.getRotation(getFace());
break;
case SOUTH:
renderer.addTransformation(new Rotation(-90, 90, 0, Vec3d.center));
d1 = d1.getRotation(getFace());
d2 = d2.getRotation(getFace());
d3 = d3.getRotation(getFace());
d4 = d4.getRotation(getFace());
break;
case WEST:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case EAST:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
default:
break;
}
boolean s1 = shouldRenderConnection(d1);
boolean s2 = shouldRenderConnection(d2);
boolean s3 = shouldRenderConnection(d3);
boolean s4 = shouldRenderConnection(d4);
renderer.setColor(color);
// Center
renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D - width, 8 / 16D + width, height, 8 / 16D + width), getIcons(ForgeDirection.UNKNOWN));
// Sides
if (s4 || s3) {
if (s3 || (!s3 && s4 && !s1 && !s2))
renderer.renderBox(new Vec3dCube(s3 ? (extendsToCorner(d3) ? -height : 0) : 4 / 16D, 0, 8 / 16D - width, 8 / 16D - width, height, 8 / 16D + width), getIcons(ForgeDirection.WEST));
if (s4 || (s3 && !s4 && !s1 && !s2))
renderer.renderBox(new Vec3dCube(8 / 16D + width, 0, 8 / 16D - width, s4 ? 1 + (extendsToCorner(d4) ? height : 0) : 12 / 16D, height, 8 / 16D + width), getIcons(ForgeDirection.EAST));
if (s1)
renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, s1 ? (extendsToCorner(d1) ? -height : 0) : 4 / 16D, 8 / 16D + width, height, 8 / 16D - width), getIcons(ForgeDirection.NORTH));
if (s2)
renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D + width, 8 / 16D + width, height, s2 ? 1 + (extendsToCorner(d2) ? height : 0) : 12 / 16D), getIcons(ForgeDirection.SOUTH));
} else {
renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, s1 ? (extendsToCorner(d1) ? -height : 0) : 4 / 16D, 8 / 16D + width, height, 8 / 16D - width), getIcons(ForgeDirection.NORTH));
renderer.renderBox(new Vec3dCube(8 / 16D - width, 0, 8 / 16D + width, 8 / 16D + width, height, s2 ? 1 + (extendsToCorner(d2) ? height : 0) : 12 / 16D), getIcons(ForgeDirection.SOUTH));
}
renderer.setIgnoreLighting(false);
renderer.setColor(0xFFFFFF);
return true;
}
use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.
the class GateBase method renderStatic.
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
Transformation t = null;
if (getFace() == ForgeDirection.UP)
t = new Rotation(180, 180, 0, Vec3d.center);
if (getFace() == ForgeDirection.NORTH)
t = new Rotation(90, 0, 0, Vec3d.center);
if (getFace() == ForgeDirection.SOUTH)
t = new Rotation(-90, 0, 0, Vec3d.center);
if (getFace() == ForgeDirection.WEST)
t = new Rotation(0, 0, -90, Vec3d.center);
if (getFace() == ForgeDirection.EAST)
t = new Rotation(0, 0, 90, Vec3d.center);
if (t != null)
renderer.addTransformation(t);
int rotation = getRotation();
if (rotation != -1)
renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
renderer.renderBox(BOX, getIcon(ForgeDirection.DOWN), getIcon(ForgeDirection.UP), getIcon(ForgeDirection.WEST), getIcon(ForgeDirection.EAST), getIcon(ForgeDirection.NORTH), getIcon(ForgeDirection.SOUTH));
for (IGateComponent c : getComponents()) c.renderStatic(translation, renderer, pass);
return true;
}
use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.
the class PartLamp method renderStatic.
/**
* This render method gets called whenever there's a block update in the chunk. You should use this to remove load from the renderer if a part of
* the rendering code doesn't need to get called too often or just doesn't change at all. To call a render update to re-render this just call
* {@link com.bluepowermod.part.BPPart#markPartForRenderUpdate()}
*
* @param loc
* Distance from the player's position
* @param pass
* Render pass (0 or 1)
* @return Whether or not it rendered something
*/
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i loc, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
switch(getFace().ordinal()) {
case 0:
break;
case 1:
renderer.addTransformation(new Rotation(180, 0, 0, Vec3d.center));
break;
case 2:
renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
break;
case 3:
renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
break;
case 4:
renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
break;
case 5:
renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
break;
}
// Render base
renderLamp(renderer);
renderer.resetTransformations();
return true;
}
Aggregations