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

The following examples show how to use org.lwjgl.opengl.GL11#glPopMatrix() . 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: RenderBlockArrows.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void drawArrow(float progress){
    double arrowBaseWidth = 0.4D;
    double arrowBaseLength = 0.8D;
    double arrowLength = 1.5D;
    double arrowWidth = 0.7D;
    double scale = 0.1D;
    GL11.glPushMatrix();
    GL11.glScaled(scale, scale, scale);
    GL11.glTranslatef(0, progress * 4, 0);
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINE_STRIP);
    tess.addVertex(-arrowBaseWidth, -arrowLength * 0.5D, 0);
    tess.addVertex(-arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(-arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(0, arrowLength * 0.5D, 0);
    tess.addVertex(arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(arrowBaseWidth, -arrowLength * 0.5D, 0);
    tess.draw();
    GL11.glPopMatrix();
}
 
Example 2
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private void updateCyanList()
{
	GL11.glNewList(displayLists[0], GL11.GL_COMPILE);
	
	GL11.glPushMatrix();
	GL11.glTranslated(start.getX(), start.getY(), start.getZ());
	GL11.glTranslated(0.5, 0.5, 0.5);
	
	GL11.glColor4f(0, 1, 1, 0.5F);
	GL11.glBegin(GL11.GL_LINES);
	RenderUtils
		.drawNode(new AxisAlignedBB(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25));
	GL11.glEnd();
	
	RenderUtils.drawArrow(
		new Vec3d(direction.getDirectionVec()).scale(0.25),
		new Vec3d(direction.getDirectionVec())
			.scale(Math.max(0.5, length)));
	
	GL11.glPopMatrix();
	GL11.glEndList();
}
 
Example 3
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Restore the old OpenGL state that's backed up in {@code state}.
 * @param state the old state to restore
 */
private void restoreRenderState(RenderState state) {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPopMatrix();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPopMatrix();
	GL11.glEnable(GL11.GL_BLEND);
	GL20.glUseProgram(state.oldProgram);
	GL13.glActiveTexture(state.texUnit);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer);
	if (!state.depthWriteEnabled)
		GL11.glDepthMask(false);
	if (!state.depthEnabled)
		GL11.glDisable(GL11.GL_DEPTH_TEST);
	if (state.texEnabled)
		GL11.glEnable(GL11.GL_TEXTURE_2D);
	if (state.smoothedPoly)
		GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
	if (!state.blendEnabled)
		GL11.glDisable(GL11.GL_BLEND);
}
 
Example 4
Source File: TrajectoriesHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawEndOfLine(Vec3d end, Vec3d camPos)
{
	double renderX = end.x - camPos.x;
	double renderY = end.y - camPos.y;
	double renderZ = end.z - camPos.z;
	
	GL11.glPushMatrix();
	GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
	
	GL11.glColor4f(0, 1, 0, 0.25F);
	RenderUtils.drawSolidBox();
	
	GL11.glColor4f(0, 1, 0, 0.75F);
	RenderUtils.drawOutlinedBox();
	
	GL11.glPopMatrix();
}
 
Example 5
Source File: TileEntityModelHelmRenderer.java    From archimedes-ships with MIT License 6 votes vote down vote up
@Override
public void renderTileEntityAt( TileEntity tileEntity, double x, double y, double z, float f )
{
	GL11.glPushMatrix();
	GL11.glTranslated( x, y, z );

	// Translate to centre of block
	GL11.glTranslatef(0.5F, 0.5F, 0.5F);
	
	// Rotate model according to metadata
	float rotate = 0F;
	if( tileEntity.blockMetadata == 1 ) rotate = -90f;
	if( tileEntity.blockMetadata == 2 ) rotate = 180f;
	if( tileEntity.blockMetadata == 3 ) rotate = 90f;

	GL11.glRotatef( rotate, 0F, 1F, 0F);

	// Bind the texture and render the model
	bindTexture( helmTexture );
	helmModel.renderAll();

	GL11.glPopMatrix();
}
 
Example 6
Source File: BoxRenderer.java    From OpenModsLib with MIT License 6 votes vote down vote up
public void render(Gui gui, int x, int y, int width, int height, int color) {
	RenderUtils.setColor(color);

	GL11.glPushMatrix();
	GL11.glTranslatef(x, y, 0);
	renderBackground(gui, width, height);
	renderTopEdge(gui, width);
	renderBottomEdge(gui, width, height);
	renderLeftEdge(gui, height);
	renderRightEdge(gui, width, height);

	renderTopLeftCorner(gui);
	renderTopRightCorner(gui, width);
	renderBottomLeftCorner(gui, height);
	renderBottomRightCorner(gui, width, height);
	GL11.glPopMatrix();
}
 
Example 7
Source File: ItemRenderFamiliar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if(item == null || !(item.getItem() instanceof ItemEtherealFamiliar)) return;
    GL11.glPushMatrix();
    if(type == ItemRenderType.EQUIPPED) {
        GL11.glTranslatef(0.5F, 0.5F, 0.7F);
    } else if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslatef(0, 1F, 0.8F);
    } else if(type == ItemRenderType.INVENTORY) {
        GL11.glTranslatef(0, -0.45F, 0);
    }

    try {
        cleanActiveRenderInfo(type);
        GL11.glScalef(1.3F, 1.3F, 1.3F);
        if(ItemEtherealFamiliar.hasFamiliarAspect(item)) {
            if(ENTITY_WISP == null) ENTITY_WISP = new EntityWisp(new FakeWorld());
            ENTITY_WISP.ticksExisted = FamiliarHandlerClient.PartialEntityFamiliar.DUMMY_FAMILIAR.ticksExisted;
            ENTITY_WISP.setType(ItemEtherealFamiliar.getFamiliarAspect(item).getTag());
            renderEntityWispFor(null, ENTITY_WISP, 0, 0, 0, 0, 0);
        }
    } finally {
        restoreActiveRenderInfo();
    }
    GL11.glPopMatrix();
}
 
Example 8
Source File: ItemRenderTEKnowledgeBook.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    if(type.equals(ItemRenderType.INVENTORY)) {
        GL11.glScalef(1.4F, 1.4F, 1.4F);
    } else if(type.equals(ItemRenderType.ENTITY)) {
        GL11.glScalef(2F, 2F, 2F);
    } else if(type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotatef(15F, 1, 0, 0);
        GL11.glRotatef(-50F, 0, 1, 0);
        GL11.glTranslatef(-0.4F, 0F, -1.25F);
        GL11.glScalef(1.8F, 1.8F, 1.8F);
    } else if(type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslatef(-0.2F, 0.4F, 0);
        GL11.glRotatef(30F, 0, 1, 0);
        GL11.glRotatef(55F, 0, 0, 1);
    }
    super.renderItem(type, item, data);
    GL11.glPopMatrix();
}
 
Example 9
Source File: ItemRenderRemoteJar.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) {
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    AspectList aspects = ((ItemJarFilled)ConfigItems.itemJarFilled).getAspects(stack);
    if(aspects != null) {
        tile.aspect = aspects.getAspects()[0];
        tile.amount = aspects.getAmount(tile.aspect);
    } else {
        tile.aspect = null;
        tile.amount = 0;
    }

    if(stack.hasTagCompound()) {
        tile.networkId = NBTHelper.getUUID(stack.getTagCompound(), "networkId");
    }

    super.renderItem(type, stack, data);

    GL11.glPushMatrix();
    GL11.glTranslatef(0.5f, 0.5f, 0.5f);

    RenderingRegistry.instance().renderInventoryBlock(RenderBlocks.getInstance(), RegisteredBlocks.blockRemoteJar, 0, RegisteredBlocks.blockRemoteJar.getRenderType());
    GL11.glPopMatrix();
}
 
Example 10
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
public static void startDrawingESPs(double d, double d1, double d2, double r, double g, double b2) {

        GL11.glPushMatrix();
        GL11.glEnable(3042);
        GL11.glBlendFunc(770, 771);
        GL11.glLineWidth(1.5f);
        GL11.glDisable(2896);
        GL11.glDisable(3553);
        GL11.glEnable(2848);
        GL11.glDisable(2929);
        GL11.glDepthMask(false);
        GL11.glColor4d(r, g, b2, 0.1850000023841858);
        GLUtils.drawBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
        GL11.glColor4d(r, g, b2, 1.0);
        GLUtils.drawOutlinedBoundingBox(new AltAxisAlignedBB(d, d1, d2, d + 1.0, d1 + 1.0, d2 + 1.0));
        GL11.glLineWidth(2.0f);
        GL11.glDisable(2848);
        GL11.glEnable(3553);
        GL11.glEnable(2896);
        GL11.glEnable(2929);
        GL11.glDepthMask(true);
        GL11.glDisable(3042);
        GL11.glPopMatrix();
    }
 
Example 11
Source File: PlayerEspHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRender(float partialTicks)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glDisable(GL11.GL_LIGHTING);
	
	GL11.glPushMatrix();
	RenderUtils.applyRenderOffset();
	
	// draw boxes
	if(style.getSelected().boxes)
		renderBoxes(partialTicks);
	
	if(style.getSelected().lines)
		renderTracers(partialTicks);
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 12
Source File: RenderUtilsLiving.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public static void glCleanup() {
	//GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glPopMatrix();
}
 
Example 13
Source File: MobEspHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRender(float partialTicks)
{
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	GL11.glDisable(GL11.GL_LIGHTING);
	
	GL11.glPushMatrix();
	RenderUtils.applyRenderOffset();
	
	if(style.getSelected().boxes)
		renderBoxes(partialTicks);
	
	if(style.getSelected().lines)
		renderTracers(partialTicks);
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example 14
Source File: ModelCable.java    From ExtraCells1 with MIT License 5 votes vote down vote up
public void renderBase(double x, double y, double z, Colors color)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(color.getTexture());
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x + 0.5F, (float) y + -0.5F, (float) z + 0.5F);
	GL11.glScalef(0.8799F, 1, 0.8799F);
	CableBase.render(0.0625f);
	GL11.glPopMatrix();
}
 
Example 15
Source File: RenderButtonUIEntity.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void doRender(EntityUIButton entity, double x, double y, double z,
		float entityYaw, float partialTicks) {

	GL11.glPushMatrix();
	GL11.glTranslated(0, -.25, 0);
	

	RenderHelper.renderTag(Minecraft.getMinecraft().player.getDistanceSqToEntity(entity), "Up a level", x,y,z, 8);
	GL11.glPopMatrix();

	//Clean up and make player not transparent
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 0, 0);
}
 
Example 16
Source File: RenderAirCannon.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public void renderModelAt(TileEntityAirCannon tile, double d, double d1, double d2, float f){
    GL11.glPushMatrix(); // start
    FMLClientHandler.instance().getClient().getTextureManager().bindTexture(Textures.MODEL_AIR_CANNON);
    GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); // size
    GL11.glScalef(1.0F, -1F, -1F); // to make your block have a normal
                                   // positioning. comment out to see what
                                   // happens
    float angle = (float)PneumaticCraftUtils.rotateMatrixByMetadata(tile.getBlockMetadata());
    float rotationAngle = tile.rotationAngle - angle + 180F;
    model.renderModel(0.0625F, rotationAngle, tile.heightAngle, false, false);
    GL11.glPopMatrix(); // end

}
 
Example 17
Source File: TileEntityScannerRenderer.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntityScanner te, double x, double y, double z, float partialTicks, int destroyStage)
{
	if (te != null)
	{
		float ticks = Minecraft.getMinecraft().thePlayer.ticksExisted + partialTicks;
		
		GL11.glPushMatrix();
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		GL11.glTranslated(x+.5, y+.5, z+.5);
		
		IBlockState state = te.getWorld().getBlockState(te.getPos());
		if (state.getBlock() == CyberwareContent.scanner)
		{
			ItemStack stack = te.slots.getStackInSlot(0);
			if (stack != null)
			{
				Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
				GL11.glPushMatrix();
				GlStateManager.color(1F, 1F, 1F, 1F);
				GL11.glTranslatef(0F, -1.6F / 16F, 0F);
				GL11.glScalef(.8F, .8F, .8F);
				GL11.glRotatef(90F, 1F, 0F, 0F);
				Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
				GL11.glPopMatrix();
			}
			ClientUtils.bindTexture(texture);

			int difference = Math.abs(te.x - te.lastX);
			float timeToTake = difference * 3;
			float time = Math.min(timeToTake, te.ticks + partialTicks - te.ticksMove);
			float progress = (float) Math.cos((Math.PI / 2) * (1F - (time / timeToTake)));
			if (difference == 0)
			{
				progress = 1.0F;
			}
			GL11.glTranslatef(0F, 0F, ((te.lastX + (te.x - te.lastX) * progress) + 1.5F) * 1F / 16F);
			
			model.render(null, 0, 0, 0, 0, 0, .0625f);
			
			int difference2 = Math.abs(te.z - te.lastZ);
			float timeToTake2 = difference2 * 3;
			float time2 = Math.max(0, Math.min(timeToTake2, te.ticks + partialTicks - te.ticksMove/* - timeToTake*/));
			float progress2 = (float) Math.cos((Math.PI / 2) * (1F - (time2 / timeToTake2)));
			if (difference2 == 0)
			{
				progress2 = 1.0F;
			}
			GL11.glTranslatef(((te.lastZ + (te.z - te.lastZ) * progress2) + .5F) * 1F / 16F, 0F, 0F);
			
			model.renderScanner(null, 0, 0, 0, 0, 0, .0625f);

			if (te.ticks > 0 && (progress2 >= 1F && progress >= 1F) && (((int) (te.ticks + partialTicks)) % 2F == 0))
			{
				GL11.glEnable(GL11.GL_BLEND);
				model.renderBeam(null, 0, 0, 0, 0, 0, 0.0625F);
				GL11.glDisable(GL11.GL_BLEND);
			}
			
			
			GL11.glPopMatrix();
		}
	}
}
 
Example 18
Source File: RenderCoordWireframe.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void render(float partialTicks){
    /*
    Block block = Block.blocksList[world.getBlockId(x, y, z)];
    block.setBlockBoundsBasedOnState(world, x, y, z);
    double minX = block.getBlockBoundsMinX();
    double minY = block.getBlockBoundsMinY();
    double minZ = block.getBlockBoundsMinZ();
    double maxX = minX + (block.getBlockBoundsMaxX() - minX) * progress;
    double maxY = minY + (block.getBlockBoundsMaxY() - minY) * progress;
    double maxZ = minZ + (block.getBlockBoundsMaxX() - minZ) * progress;
    */
    double minX = 0;
    double minY = 0;
    double minZ = 0;
    double maxX = 1;
    double maxY = 1;
    double maxZ = 1;
    float progress = (ticksExisted % 20 + partialTicks) / 20;
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glLineWidth(1.0F);
    // GL11.glColor4d(0, 1, 1, progress < 0.5F ? progress + 0.5F : 1.5 - progress);
    GL11.glColor4d(0, progress < 0.5F ? progress + 0.5F : 1.5 - progress, 1, 1);
    GL11.glPushMatrix();
    // GL11.glTranslated(-0.5D, -0.5D, -0.5D);
    GL11.glTranslated(x, y, z);
    Tessellator tess = Tessellator.instance;

    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(minX, minY, minZ);
    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(minX, maxY, maxZ);

    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(maxX, minY, maxZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.addVertex(minX, minY, minZ);
    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(maxX, minY, maxZ);

    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(minX, maxY, maxZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.addVertex(minX, minY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(maxX, minY, maxZ);

    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(minX, maxY, maxZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.draw();

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 19
Source File: FXVortex.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void render(Tessellator tessellator, float pTicks) {
    float arX = ActiveRenderInfo.rotationX;
    float arXZ = ActiveRenderInfo.rotationXZ;
    float arZ = ActiveRenderInfo.rotationZ;
    float arYZ = ActiveRenderInfo.rotationYZ;
    float arXY = ActiveRenderInfo.rotationXY;

    GL11.glPushMatrix();
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    float agescale = (float) (ClientHandler.ticks % 800) / 400F;
    if(agescale >= 1.0F) agescale = 2 - agescale;
    float size = 0.2F + 0.1F * agescale;
    if(parent != null) {
        size += size * (((float) parent.getSizeStage()) * 0.04F);
    }

    float anglePerc = (float) (ClientHandler.ticks % 300) / 300F;
    float angle = RAD - RAD * anglePerc;

    Vector3 iV = MiscUtils.interpolateEntityPosition(Minecraft.getMinecraft().renderViewEntity, pTicks);
    if(parent != null && parent.getSizeStage() > 4) {
        float mult = 0.001F * (parent.getSizeStage() - 4F);
        Vector3 shake = new Vector3(
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1),
                RAND.nextFloat() * mult * (RAND.nextBoolean() ? 1 : -1));
        iV.add(shake);
    }

    GL11.glTranslated(-iV.getX(), -iV.getY(), -iV.getZ());

    UtilsFX.bindTexture(TC_VORTEX_TEXTURE);

    tessellator.startDrawingQuads();
    tessellator.setBrightness(220);
    tessellator.setColorRGBA_F(1F, 1F, 1F, 1F);

    Vec3 v1 = Vec3.createVectorHelper(-arX * size - arYZ * size, -arXZ * size, -arZ * size - arXY * size);
    Vec3 v2 = Vec3.createVectorHelper(-arX * size + arYZ * size, arXZ * size, -arZ * size + arXY * size);
    Vec3 v3 = Vec3.createVectorHelper(arX * size + arYZ * size, arXZ * size, arZ * size + arXY * size);
    Vec3 v4 = Vec3.createVectorHelper(arX * size - arYZ * size, -arXZ * size, arZ * size - arXY * size);
    if (angle != 0.0F) {
        Vec3 pvec = Vec3.createVectorHelper(iV.getX(), iV.getY(), iV.getZ());
        Vec3 tvec = Vec3.createVectorHelper(x, y, z);
        Vec3 qvec = pvec.subtract(tvec).normalize();
        QuadHelper.setAxis(qvec, angle).rotate(v1);
        QuadHelper.setAxis(qvec, angle).rotate(v2);
        QuadHelper.setAxis(qvec, angle).rotate(v3);
        QuadHelper.setAxis(qvec, angle).rotate(v4);
    }
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    tessellator.addVertexWithUV(x + v1.xCoord, y + v1.yCoord, z + v1.zCoord, 0, 1);
    tessellator.addVertexWithUV(x + v2.xCoord, y + v2.yCoord, z + v2.zCoord, 1, 1);
    tessellator.addVertexWithUV(x + v3.xCoord, y + v3.yCoord, z + v3.zCoord, 1, 0);
    tessellator.addVertexWithUV(x + v4.xCoord, y + v4.yCoord, z + v4.zCoord, 0, 0);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    GL11.glPopMatrix();
}
 
Example 20
Source File: ShipHelmTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityShipHelm tileentity, double x, double y, double z,
    float partialTick, int destroyStage,
    float alpha) {
    if (tileentity instanceof TileEntityShipHelm) {
        IBlockState helmState = tileentity.getWorld().getBlockState(tileentity.getPos());

        if (helmState.getBlock() != ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipHelm) {
            return;
        }

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

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

        double smoothCompassDif = (tileentity.compassAngle - tileentity.lastCompassAngle);
        if (smoothCompassDif < -180) {
            smoothCompassDif += 360;
        }
        if (smoothCompassDif > 180) {
            smoothCompassDif -= 360;
        }

        double smoothWheelDif = (tileentity.wheelRotation - tileentity.lastWheelRotation);
        if (smoothWheelDif < -180) {
            smoothWheelDif += 360;
        }
        if (smoothWheelDif > 180) {
            smoothWheelDif -= 360;
        }

        double smoothCompass =
            tileentity.lastCompassAngle + (smoothCompassDif) * partialTick + 180D;
        double smoothWheel = tileentity.lastWheelRotation + (smoothWheelDif) * partialTick;
        BlockPos originPos = tileentity.getPos();

        IBlockState wheelState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(0);
        IBlockState compassState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(1);
        IBlockState glassState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(2);
        IBlockState helmStateToRender = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(3);
        // TODO: Better rendering cache
        int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

        double multiplier = 2.0D;
        GL11.glTranslated((1D - multiplier) / 2.0D, 0, (1D - multiplier) / 2.0D);
        GL11.glScaled(multiplier, multiplier, multiplier);
        EnumFacing enumfacing = helmState.getValue(BlockShipHelm.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);
        GibsModelRegistry.renderGibsModel("ship_helm_base", brightness);

        GL11.glPushMatrix();
        GL11.glTranslated(.5, .522, 0);
        GL11.glRotated(smoothWheel, 0, 0, 1);
        GL11.glTranslated(-.5, -.522, 0);
        GibsModelRegistry.renderGibsModel("ship_helm_wheel", brightness);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glTranslated(0.5D, 0, 0.5D);
        GL11.glRotated(smoothCompass, 0, 1, 0);
        GL11.glTranslated(-0.5D, 0, -0.5D);
        GibsModelRegistry.renderGibsModel("ship_helm_dial", brightness);

        GL11.glPopMatrix();
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GibsModelRegistry.renderGibsModel("ship_helm_dial_glass", brightness);
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();
        GL11.glPopMatrix();

        GlStateManager.enableLighting();
        GlStateManager.resetColor();
    }
}