Java Code Examples for org.lwjgl.opengl.GL11#glRotated()

The following examples show how to use org.lwjgl.opengl.GL11#glRotated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void renderModel(float size, float progress, boolean renderBase, boolean rightGoing){
    if(renderBase) {
        Shape1.render(size);
        Shape2.render(size);
        Shape4.render(size);
        Shape5.render(size);
    }
    float cosinus = /*12 / 16F -*/(float)Math.sin(Math.toRadians((1 - progress) * 90)) * 12 / 16F;
    float sinus = 9 / 16F - (float)Math.cos(Math.toRadians((1 - progress) * 90)) * 9 / 16F;
    double extension = Math.sqrt(Math.pow(sinus, 2) + Math.pow(cosinus + 4 / 16F, 2));
    //System.out.println("sinus: " + sinus);
    GL11.glTranslated(((rightGoing ? -4 : 0) + 2.5) / 16F, 0, -6 / 16F);
    double cilinderAngle = Math.toDegrees(Math.atan(sinus / (cosinus + 14 / 16F)));
    GL11.glRotated(cilinderAngle, 0, rightGoing ? 1 : -1, 0);
    GL11.glTranslated(((rightGoing ? -3 : 0) - 2.5) / 16F, 0, 6 / 16F);
    double extensionPart = extension * 0.5D;
    Cilinder1.render(size);
    GL11.glTranslated(0, 0, extensionPart);
    Cilinder2.render(size);
    GL11.glTranslated(0, 0, extensionPart);
    Cilinder3.render(size);
}
 
Example 2
Source File: ModelGauge.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderDynamic(float size, TileEntity te, float partialTicks){
    Shape1.render(size);
    Shape2.render(size);

    float pressure = 0;
    float dangerPressure = 5;
    float critPressure = 7;
    if(gaugeModule != null && gaugeModule.getTube() != null) {
        TileEntityPneumaticBase base = (TileEntityPneumaticBase)((IPneumaticMachine)gaugeModule.getTube()).getAirHandler();
        pressure = base.getPressure(ForgeDirection.UNKNOWN);
        dangerPressure = base.DANGER_PRESSURE;
        critPressure = base.CRITICAL_PRESSURE;
    }
    GL11.glTranslated(0, 1, 0.378);
    double scale = 0.008D;
    GL11.glScaled(scale, scale, scale);
    GL11.glRotated(180, 0, 1, 0);
    GL11.glDisable(GL11.GL_LIGHTING);
    GuiUtils.drawPressureGauge(FMLClientHandler.instance().getClient().fontRenderer, -1, critPressure, dangerPressure, -1, pressure, 0, 0, 0);
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 3
Source File: RenderItemPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data){
    int itemDamage = item.getItemDamage();
    switch(type){
        case ENTITY: {
            render(0.0F, 0.0F, 1.0F, 1.0F, itemDamage);
            return;
        }
        case EQUIPPED: {
            GL11.glRotated(180, 0, 1, 0);
            // GL11.glTranslated(0, 2, 0);
            render(-0.7F, 0.4F, 0.3F, 0.8F, itemDamage);
            return;
        }
        case EQUIPPED_FIRST_PERSON: {
            GL11.glRotated(180, 0, 1, 0);
            render(0.0F, 1F, 0.4F, 1.2F, itemDamage);
            return;
        }
        case INVENTORY: {
            render(0.0F, 0.0F, 1.0F, 1.5F, itemDamage);
            return;
        }
        default:
            return;
    }
}
 
Example 4
Source File: RenderItemProgrammingPuzzle.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data){
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_LIGHTING);
    switch(type){
        case ENTITY: {
            GL11.glRotated(180, 0, 0, 1);
            GL11.glDisable(GL11.GL_CULL_FACE);
            render(0.0F, 0.0F, 0.0F, 0.5F, item);
            GL11.glEnable(GL11.GL_CULL_FACE);
            break;
        }
        case EQUIPPED: {
            GL11.glRotated(180, 0, 0, 1);
            render(-0.4F, -0.5F, -0.0F, 1.0F, item);
            //   GL11.glRotated(80, 1, 0, 0);
            break;
        }
        case EQUIPPED_FIRST_PERSON: {
            GL11.glRotated(180, 0, 0, 1);
            render(-0.8F, -0.5F, 0.3F, 1.0F, item);
            break;
        }
        case INVENTORY: {
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            render(8.0F, 8.0F, 0, 12F, item);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
            break;
        }
        default:
            break;
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}
 
Example 5
Source File: RenderItemMinigun.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data){
    GL11.glTranslated(0, 0.7, 0);

    switch(type){
        case ENTITY: {
            render(0.0F, 0.0F, 1.0F, 1.0F, item);
            return;
        }
        case EQUIPPED: {
            GL11.glRotatef(240F, 0, 1F, 0);
            render(0.1F, 0.6F, 1.3F, 2.0F, item);
            return;
        }
        case EQUIPPED_FIRST_PERSON: {
            GL11.glRotatef(150F, 0, 1F, 0);
            GL11.glRotated(-10, 1, 0, 0);
            ItemStack heldStack = PneumaticCraft.proxy.getPlayer().getCurrentEquippedItem();
            if(heldStack != null && heldStack.getItem() == Itemss.minigun) {
                item = heldStack;
            }
            render(-0.5F, 0.6F, 2.1F, 1.0F, item);
            renderEffects(item);
            return;
        }
        case INVENTORY: {
            render(0.0F, 0.0F, 1.0F, 1.0F, item);
            return;
        }
        default:
            return;
    }
}
 
Example 6
Source File: MapRenderer.java    From mapwriter with MIT License 5 votes vote down vote up
private void drawIcons() {
	GL11.glPushMatrix();
	
	if (this.mapMode.rotate) {
		GL11.glRotated(this.mw.mapRotationDegrees, 0.0f, 0.0f, 1.0f);
	}
	
	// draw markers
	this.mw.markerManager.drawMarkers(this.mapMode, this.mapView);
	
	// draw player trail
	if (this.mw.playerTrail.enabled) {
		this.mw.playerTrail.draw(this.mapMode, this.mapView);
	}
	
	// draw north arrow
	if (this.mapMode.rotate) {
		double y = this.mapMode.h / 2.0;
		double arrowSize = this.mapMode.playerArrowSize;
		Render.setColour(0xffffffff);
		this.mw.mc.renderEngine.bindTexture(this.northArrowTexture);
		Render.drawTexturedRect(
			-arrowSize, -y - (arrowSize * 2), arrowSize * 2, arrowSize * 2,
			0.0, 0.0, 1.0, 1.0
		);
	}
	
	GL11.glPopMatrix();
	
	// outside of the matrix pop as theplayer arrow
	// needs to be drawn without rotation
	this.drawPlayerArrow();
}
 
Example 7
Source File: ModuleRegulatorTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void renderModule(){
    super.renderModule();
    if(isFake()) {
        if(!hasTicked) {
            TileEntityPneumaticBase tile = (TileEntityPneumaticBase)getTube();
            NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.xCoord, tile.yCoord, tile.zCoord));
            TileEntity neighbor = tile.getWorldObj().getTileEntity(tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
            inLine = neighbor instanceof IPneumaticMachine;
            if(inLine) {
                inverted = ((IPneumaticMachine)neighbor).getAirHandler().getPressure(dir) > tile.getPressure(ForgeDirection.UNKNOWN);
                NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.xCoord, neighbor.yCoord, neighbor.zCoord));
            }
            hasTicked = true;
        }

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if(inLine && !inverted) {
            GL11.glColor4d(0, 1, 0, 0.3);
        } else {
            GL11.glColor4d(1, 0, 0, 0.3);
        }
        GL11.glPushMatrix();
        GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
        GL11.glRotated(90, 1, 0, 0);

        RenderUtils.render3DArrow();
        GL11.glColor4d(1, 1, 1, 1);
        GL11.glPopMatrix();
        GL11.glDisable(GL11.GL_BLEND);
    }
}
 
Example 8
Source File: RenderBeacon.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void render(TileEntity tile, double x,
		double y, double z, float f, int damage, float a) {
	TileMultiPowerConsumer multiBlockTile = (TileMultiPowerConsumer)tile;

	if(!multiBlockTile.canRender())
		return;

	GL11.glPushMatrix();

	//Initial setup

	GL11.glTranslated(x + 0.5, y, z + .5);
	//Rotate and move the model into position
	EnumFacing front = RotatableBlock.getFront(tile.getWorld().getBlockState(tile.getPos()));
	GL11.glRotatef((front.getFrontOffsetX() == 1 ? 180 : 0) + front.getFrontOffsetZ()*90f, 0, 1, 0);
	//GL11.glTranslated(2f, 0, 0f);
	bindTexture(baseTexture);
	model.renderOnly("Base");

	GL11.glTranslatef(1, 0, 0);
	GL11.glPushMatrix();
	if(multiBlockTile.getMachineEnabled())
		GL11.glRotated((System.currentTimeMillis() & 0xFFFF)/20d, 0, 1, 0);
	model.renderOnly("OuterSpin");
	GL11.glPopMatrix();

	GL11.glPushMatrix();
	if(multiBlockTile.getMachineEnabled())
		GL11.glRotated(-(System.currentTimeMillis() & 0xFFFF)/6d, 0, 1, 0);
	model.renderOnly("InnerSpin");
	GL11.glPopMatrix();


	GL11.glPopMatrix();
}
 
Example 9
Source File: TileEntitySelectorRenderer.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
	final TileEntitySelector selector = (TileEntitySelector)tileEntity;
	final Orientation orientation = selector.getOrientation();

	GL11.glPushMatrix();
	GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
	TransformProvider.instance.multMatrix(orientation);
	GL11.glTranslated(-0.5, 0.501, -0.5); // 0.001 offset for 2d items in fast mode

	final int gridSize = selector.getGridSize();

	renderer.setRenderManager(RenderManager.instance);

	for (ItemSlot slot : selector.getSlots(gridSize)) {
		ItemStack stack = selector.getSlot(slot.slot);
		if (stack != null) {
			EntityItem display = selector.getDisplayEntity();

			GL11.glPushMatrix();
			GL11.glTranslated(slot.x, 0, slot.y + 0.03); // 0.03, since items are rendered off-center
			GL11.glRotated(-90, 1, 0, 0);
			final double scale = slot.size * 5;
			GL11.glScaled(scale, scale, scale);
			display.setEntityItemStack(stack);
			RenderItem.renderInFrame = true;
			renderer.doRender(display, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
			GL11.glPopMatrix();
		}
	}

	RenderItem.renderInFrame = false;

	GL11.glPopMatrix();
}
 
Example 10
Source File: ModelVacuumPump.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderDynamic(float size, TileEntity te, float partialTicks){
    if(te instanceof TileEntityVacuumPump) {
        GL11.glRotated(-90, 0, 1, 0);
        TileEntityVacuumPump tile = (TileEntityVacuumPump)te;
        renderModel(size, tile.oldRotation + (tile.rotation - tile.oldRotation) * partialTicks);
    } else {
        renderModel(size, 0);
    }
}
 
Example 11
Source File: LiftLeverTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityLiftLever tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {

    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    GlStateManager.pushMatrix();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);
    IBlockState gearState = Minecraft.getMinecraft().world.getBlockState(tileentity.getPos());
    if (gearState.getBlock() instanceof BlockLiftLever) {
        EnumFacing facing = gearState.getValue(BlockHorizontal.FACING);

        GlStateManager.translate(0.5, 0.5, 0.5);
        switch (facing) {
            case UP:
                GL11.glRotated(90, 1, 0, 0);
                break;
            case DOWN:
                GL11.glRotated(270, 1, 0, 0);
                break;
            case NORTH:
                GL11.glRotated(0, 0, 1, 0);
                break;
            case EAST:
                GL11.glRotated(270, 0, 1, 0);
                break;
            case SOUTH:
                GL11.glRotated(180, 0, 1, 0);
                break;
            case WEST:
                GL11.glRotated(90, 0, 1, 0);
                break;
        }
        GlStateManager.translate(-0.5, -0.5, -0.5);
    }

    float leverOffset = tileentity.getPrevLeverOffset()
        + (tileentity.getLeverOffset() - tileentity.getPrevLeverOffset()) * partialTick;

    // double keyframe = ((Minecraft.getMinecraft().world.getTotalWorldTime() + partialTick) % 44) + 1;

    double keyframe = (44 * leverOffset) + 1;
    GibsAnimationRegistry.getAnimation("lift_lever").renderAnimation(keyframe, brightness);

    GlStateManager.popMatrix();
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 12
Source File: RotationAxleTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityRotationAxle tileentity, double x, double y, double z,
    float partialTick, int destroyStage, float alpha) {
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);
    IBlockState gearState = Minecraft.getMinecraft().world.getBlockState(tileentity.getPos());
    if (gearState.getBlock() instanceof BlockRotationAxle) {
        EnumFacing.Axis facingAxis = gearState.getValue(BlockRotationAxle.AXIS);

        GlStateManager.translate(0.5, 0.5, 0.5);
        switch (facingAxis) {
            case X:
                // Rotates (1, 0, 0) -> (1, 0, 0)
                break;
            case Y:
                // Rotates (1, 0, 0) -> (0, 1, 0)
                GL11.glRotated(90, 0, 0, 1);
                break;
            case Z:
                // Rotates (1, 0, 0) -> (0, 0, 1)
                GL11.glRotated(-90, 0, 1, 0);
                break;
        }
        GL11.glRotated(Math.toDegrees(tileentity.getRenderRotationRadians(partialTick)), 1, 0,
            0);
        GlStateManager.translate(-0.5, -0.5, -0.5);
    }

    double keyframe = 1;
    GibsAnimationRegistry.getAnimation("rotation_axle")
        .renderAnimation(keyframe, brightness);

    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 13
Source File: PhysObjectRenderManager.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public void applyRenderTransform(double partialTicks) {
    Vector centerOfRotation = parent.getCenterCoord();

    double p0 = Minecraft.getMinecraft().player.lastTickPosX
        + (Minecraft.getMinecraft().player.posX - Minecraft.getMinecraft().player.lastTickPosX)
        * partialTicks;
    double p1 = Minecraft.getMinecraft().player.lastTickPosY
        + (Minecraft.getMinecraft().player.posY - Minecraft.getMinecraft().player.lastTickPosY)
        * partialTicks;
    double p2 = Minecraft.getMinecraft().player.lastTickPosZ
        + (Minecraft.getMinecraft().player.posZ - Minecraft.getMinecraft().player.lastTickPosZ)
        * partialTicks;

    ShipTransform renderTransform = parent.getShipTransformationManager().getRenderTransform();

    Vector renderPos = new Vector(centerOfRotation);
    renderTransform.transform(renderPos, TransformType.SUBSPACE_TO_GLOBAL);

    double moddedX = renderPos.X;
    double moddedY = renderPos.Y;
    double moddedZ = renderPos.Z;

    double[] radians = renderTransform
        .createRotationQuaternion(TransformType.SUBSPACE_TO_GLOBAL).toRadians();

    double moddedPitch = Math.toDegrees(radians[0]);
    double moddedYaw = Math.toDegrees(radians[1]);
    double moddedRoll = Math.toDegrees(radians[2]);
    // Offset pos is used to prevent floating point errors when rendering stuff thats very far away.
    if (offsetPos != null) {
        double offsetX = offsetPos.getX() - centerOfRotation.X;
        double offsetY = offsetPos.getY() - centerOfRotation.Y;
        double offsetZ = offsetPos.getZ() - centerOfRotation.Z;

        GlStateManager.translate(-p0 + moddedX, -p1 + moddedY, -p2 + moddedZ);
        GL11.glRotated(moddedPitch, 1D, 0, 0);
        GL11.glRotated(moddedYaw, 0, 1D, 0);
        GL11.glRotated(moddedRoll, 0, 0, 1D);
        GL11.glTranslated(offsetX, offsetY, offsetZ);
    }
}
 
Example 14
Source File: SpeedTelegraphTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntitySpeedTelegraph tileentity, double x, double y, double z,
    float partialTick, int destroyStage, float alpha) {
    IBlockState telegraphState = tileentity.getWorld().getBlockState(tileentity.getPos());

    if (telegraphState.getBlock()
        != ValkyrienSkiesControl.INSTANCE.vsControlBlocks.speedTelegraph) {
        return;
    }

    GlStateManager.resetColor();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder tessellatorBuffer = tessellator.getBuffer();

    double oldX = tessellatorBuffer.xOffset;
    double oldY = tessellatorBuffer.yOffset;
    double oldZ = tessellatorBuffer.zOffset;

    tessellatorBuffer.setTranslation(0, 0, 0);
    GL11.glTranslated(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    BlockPos originPos = tileentity.getPos();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

    double multiplier = 1.9D;

    GL11.glTranslated((1D - multiplier) / 2.0D, 0, (1D - multiplier) / 2.0D);
    GL11.glScaled(multiplier, multiplier, multiplier);
    EnumFacing enumfacing = telegraphState.getValue(BlockSpeedTelegraph.FACING);
    double wheelAndCompassStateRotation = enumfacing.getHorizontalAngle();

    GL11.glTranslated(0.5D, 0, 0.5D);
    GL11.glRotated(wheelAndCompassStateRotation, 0, 1, 0);
    GL11.glTranslated(-0.5D, 0, -0.5D);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), helmStateToRender, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_speed_telegraph_simplevoxel_geo", brightness);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), dialState, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_dial_simplevoxel_geo", brightness);

    GL11.glPushMatrix();

    GL11.glTranslated(0.497D, 0.857D, 0.5D);
    GL11.glRotated(tileentity.getHandleRenderRotation(partialTick), 0D, 0D, 1D);
    GL11.glTranslated(-0.497D, -0.857D, -0.5D);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), rightHandleState, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_handles_simplevoxel_geo", brightness);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), leftHandleState, brightness);

    GL11.glPopMatrix();

    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), glassState, brightness);
    GibsModelRegistry.renderGibsModel("chadburn_glass_simplevoxel_geo", brightness);

    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    GL11.glPopMatrix();
    tessellatorBuffer.setTranslation(oldX, oldY, oldZ);

    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 15
Source File: ModelDroneMinigun.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void renderMinigun(Minigun minigun, float size, float partialTick, boolean renderMount){
    Minecraft.getMinecraft().getTextureManager().bindTexture(Textures.MODEL_DRONE_MINIGUN);
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glPushMatrix();
    if(renderMount) {
        GL11.glTranslated(0, 5 / 16D, -12 / 16D);
        mount.render(size);
        GL11.glTranslated(0, -5 / 16D, 12 / 16D);
    }

    float barrelRotation = 0;
    if(minigun != null) {
        barrelRotation = (float)(minigun.getOldMinigunRotation() + partialTick * (minigun.getMinigunRotation() - minigun.getOldMinigunRotation()));
        double yaw = minigun.oldMinigunYaw + partialTick * (minigun.minigunYaw - minigun.oldMinigunYaw);
        double pitch = minigun.oldMinigunPitch + partialTick * (minigun.minigunPitch - minigun.oldMinigunPitch);

        GL11.glTranslated(0, 23 / 16D, 0);
        GL11.glRotated(yaw, 0, 1, 0);
        GL11.glRotated(pitch, 1, 0, 0);
        GL11.glTranslated(0, -18 / 16D, -12 / 16D);
    }
    barrel.rotateAngleY = 0;
    barrel.rotateAngleX = 0;
    for(int i = 0; i < 6; i++) {
        barrel.rotateAngleZ = (float)(Math.PI / 3 * i) + barrelRotation;
        barrel.render(size);
    }
    support1.rotateAngleZ = barrelRotation;
    support2.rotateAngleZ = barrelRotation;
    support3.rotateAngleZ = barrelRotation;
    support4.rotateAngleZ = barrelRotation;
    support5.rotateAngleZ = barrelRotation;
    support1.render(size);
    support2.render(size);
    support3.render(size);
    support4.render(size);
    support5.render(size);
    magazine.render(size);
    main.render(size);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    RenderUtils.glColorHex(minigun != null ? 0xFF000000 | minigun.getAmmoColor() : 0xFF313131);
    magazineColor.render(size);
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
}
 
Example 16
Source File: RenderGolemHelper.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void renderToolItem(EntityGolemBase golem, ItemStack itemstack, ModelBase mainModel, RenderManager renderManager) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    float angle = (float) (0.195 * Math.PI / -1 * ((ModelGolem) mainModel).golemRightArm.rotateAngleX);

    float y = (float) (Math.cos(angle) * 1.15);
    float z = (float) (Math.sin(angle) * 1.15);

    GL11.glTranslatef(-0.25F, y, z * -0.5f);

    GL11.glRotated(angle / Math.PI * 180f, -1, 0, 0);

    float fs = 0.66F;
    GL11.glScalef(fs, fs, fs);

    net.minecraftforge.client.IItemRenderer customRenderer = net.minecraftforge.client.MinecraftForgeClient.getItemRenderer(itemstack, net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED);
    boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED, itemstack, net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D));

    Item item = itemstack.getItem();
    float f1;

    if (item instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType())))
    {
        f1 = 0.5F;
        GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
        f1 *= 0.75F;
        GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(-f1, -f1, f1);
    }
    else if (item == Items.bow)
    {
        f1 = 0.625F;
        GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
        GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(f1, -f1, f1);
        GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    }
    else if (item.isFull3D())
    {
        f1 = 0.625F;

        if (item.shouldRotateAroundWhenRendering())
        {
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0.0F, -0.125F, 0.0F);
        }

        GL11.glTranslatef(0.0F, 0.1875F, 0.0F);

        GL11.glScalef(f1, -f1, f1);
        GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    }
    else
    {
        f1 = 0.375F;
        GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
        GL11.glScalef(f1, f1, f1);
        GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
    }

    float f2;
    int i;
    float f5;

    if (itemstack.getItem().requiresMultipleRenderPasses())
    {
        for (i = 0; i < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i)
        {
            int j = itemstack.getItem().getColorFromItemStack(itemstack, i);
            f5 = (float)(j >> 16 & 255) / 255.0F;
            f2 = (float)(j >> 8 & 255) / 255.0F;
            float f3 = (float)(j & 255) / 255.0F;
            GL11.glColor4f(f5, f2, f3, 1.0F);

            renderManager.itemRenderer.renderItem(golem, itemstack, i);
        }
    }
    else
    {
        i = itemstack.getItem().getColorFromItemStack(itemstack, 0);
        float f4 = (float)(i >> 16 & 255) / 255.0F;
        f5 = (float)(i >> 8 & 255) / 255.0F;
        f2 = (float)(i & 255) / 255.0F;
        GL11.glColor4f(f4, f5, f2, 1.0F);

        renderManager.itemRenderer.renderItem(golem, itemstack, 0);
    }


    GL11.glScaled(1.0D, 1.0D, 1.0D);

    GL11.glPopMatrix();
}
 
Example 17
Source File: RenderGravityMachine.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public void render(TileEntity tile, double x,
		double y, double z, float f, int damage, float a) {
	TileGravityController multiBlockTile = (TileGravityController)tile;

	if(!multiBlockTile.canRender())
		return;

	GL11.glPushMatrix();

	//Initial setup

	GL11.glTranslated(x + 0.5, y - .5f, z + .5);
	//Rotate and move the model into position
	EnumFacing front = RotatableBlock.getFront(tile.getWorld().getBlockState(tile.getPos()));
	GL11.glRotatef((front.getFrontOffsetX() == 1 ? 180 : 0) + front.getFrontOffsetZ()*90f, 0, 1, 0);
	//GL11.glTranslated(2f, 0, 0f);
	bindTexture(texture);
	
	model.renderOnly("Base");
	GL11.glDisable(GL11.GL_LIGHTING);
	int maxSize = 5;
	
	//Render blur
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GlStateManager.color(0f, 1f, 1f, Math.max(((float)multiBlockTile.getGravityMultiplier() - 0.1f)*0.2f,0f));
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDepthMask(false);
	
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glAlphaFunc(GL11.GL_GREATER, 0f);
	
	GL11.glPushMatrix();
	GL11.glScaled(1.1, 1, 1.1);
	for(int i = 0; i < 4; i++) {
		GL11.glScaled(.93, 1, .93);
		model.renderOnly("Blur");
	}
	GL11.glPopMatrix();
	
	GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
	GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
	
	GL11.glDepthMask(true);
	GL11.glDisable(GL11.GL_BLEND);
	GlStateManager.color(1f, 1f, 1f,1f);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	// END render blur
	
	
	GL11.glRotated(multiBlockTile.getArmRotation(), 0, 1, 0);
	for(int i = 0; i < maxSize; i++) {
		GL11.glRotated(360/maxSize, 0, 1, 0);
		model.renderOnly("Arm");
	}
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glPopMatrix();
}
 
Example 18
Source File: ModelAssemblyController.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void renderModel(float size, boolean[] connectedSides, boolean shouldFacePlayer, String displayedText, boolean hasProblem){
    Base.render(size);
    GL11.glPushMatrix();
    if(connectedSides[ForgeDirection.NORTH.ordinal()]) {
        InputBack1.render(size);
        InputBack2.render(size);
        InputBack3.render(size);
        InputBack4.render(size);
        InputBack5.render(size);
        InputBack6.render(size);
        InputBack7.render(size);
    }
    GL11.glRotated(90, 0, 1, 0);
    if(connectedSides[ForgeDirection.EAST.ordinal()]) {
        InputBack1.render(size);
        InputBack2.render(size);
        InputBack3.render(size);
        InputBack4.render(size);
        InputBack5.render(size);
        InputBack6.render(size);
        InputBack7.render(size);
    }
    GL11.glRotated(90, 0, 1, 0);
    if(connectedSides[ForgeDirection.SOUTH.ordinal()]) {
        InputBack1.render(size);
        InputBack2.render(size);
        InputBack3.render(size);
        InputBack4.render(size);
        InputBack5.render(size);
        InputBack6.render(size);
        InputBack7.render(size);
    }
    GL11.glRotated(90, 0, 1, 0);
    if(connectedSides[ForgeDirection.WEST.ordinal()]) {
        InputBack1.render(size);
        InputBack2.render(size);
        InputBack3.render(size);
        InputBack4.render(size);
        InputBack5.render(size);
        InputBack6.render(size);
        InputBack7.render(size);
    }
    GL11.glPopMatrix();
    if(shouldFacePlayer) GL11.glRotatef(180 + RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
    ScreenLeg.render(size);
    Screen.render(size);
    ScreenLegPart.render(size);
    double textSize = 1 / 100D;
    GL11.glTranslated(-0.25D, 0.53D, 0.04D);
    GL11.glRotated(-34, 1, 0, 0);
    GL11.glScaled(textSize, textSize, textSize);
    GL11.glDisable(GL11.GL_LIGHTING);
    Minecraft.getMinecraft().fontRenderer.drawString(displayedText, 1, 4, 0xFFFFFFFF);
    if(hasProblem) GuiPneumaticContainerBase.drawTexture(Textures.GUI_PROBLEMS_TEXTURE, 28, 12);
    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 19
Source File: ModelAirCompressor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean rotateModelBasedOnBlockMeta(){
    GL11.glRotated(180, 0, 1, 0);
    return true;
}
 
Example 20
Source File: ModelAssemblyPlatform.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void renderModel(float size, float progress, EntityItem carriedItem){
    float clawTrans;
    float scaleFactor = 0.7F;

    IAssemblyRenderOverriding renderOverride = null;
    if(carriedItem != null) {
        renderOverride = AssemblyRenderOverriding.renderOverrides.get(carriedItem.getEntityItem());
        if(renderOverride != null) {
            clawTrans = renderOverride.getPlatformClawShift(carriedItem.getEntityItem());
        } else {
            if(carriedItem.getEntityItem().getItem() instanceof ItemBlock) {
                clawTrans = 1.5F / 16F - progress * 0.1F / 16F;
            } else {
                clawTrans = 1.5F / 16F - progress * 1.4F / 16F;
                scaleFactor = 0.4F;
            }
        }
    } else {
        clawTrans = 1.5F / 16F - progress * 1.5F / 16F;
    }
    Base.render(size);
    Platform.render(size);
    Leg1.render(size);
    Leg2.render(size);
    Leg3.render(size);
    Leg4.render(size);

    GL11.glPushMatrix();
    GL11.glTranslated(0, 0, clawTrans);
    Claw1.render(size);
    GL11.glTranslated(0, 0, -2 * clawTrans);
    Claw2.render(size);
    GL11.glPopMatrix();
    if(carriedItem != null) {
        if(renderOverride == null || renderOverride.applyRenderChangePlatform(carriedItem.getEntityItem())) {
            GL11.glRotated(180, 1, 0, 0);
            GL11.glTranslated(0, carriedItem.getEntityItem().getItem() instanceof ItemBlock ? -16.5 / 16F : -17.5 / 16F, 0);
            // GL11.glRotated(-90, 0, 1, 0);

            GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
            customRenderItem.doRender(carriedItem, 0, 0, 0, 0, 0);
        }
    }
}