Search in sources :

Example 1 with IWorldView

use of com.xcompwiz.lookingglass.api.view.IWorldView in project SecurityCraft by Geforce132.

the class LookingGlassAPIProvider method createLookingGlassView.

/**
	 * Creates an {@link IWorldView} object, then adds it to ClientProxy.worldViews.
	 * 
	 * Only works on the CLIENT side.
	 * 
	 * @param world The world we are in.
	 * @param dimension The dimension to view. (0 = Overworld, -1 = Nether)
	 * @param xCoord View X coordinate.
	 * @param yCoord View Y coordinate.
	 * @param zCoord View Z coordinate.
	 * @param viewWidth View width in pixels.
	 * @param viewHeight View height in pixels.
	 */
@SideOnly(Side.CLIENT)
public static void createLookingGlassView(World world, int dimension, int xCoord, int yCoord, int zCoord, int viewWidth, int viewHeight) {
    if (!Loader.isModLoaded("LookingGlass")) {
        return;
    }
    IWorldView lgView = mod_SecurityCraft.instance.getLGPanelRenderer().getApi().createWorldView(dimension, new ChunkCoordinates(xCoord, yCoord, zCoord), viewWidth, viewHeight);
    lgView.setAnimator(new CameraAnimatorSecurityCamera(lgView.getCamera(), xCoord, yCoord, zCoord, world.getBlockMetadata(xCoord, yCoord, zCoord)));
    if (!mod_SecurityCraft.instance.hasViewForCoords(xCoord + " " + yCoord + " " + zCoord + " " + dimension)) {
        mod_SecurityCraft.log("Inserting new view at" + Utils.getFormattedCoordinates(xCoord, yCoord, zCoord));
        ((ClientProxy) mod_SecurityCraft.serverProxy).worldViews.put(xCoord + " " + yCoord + " " + zCoord + " " + dimension, new IWorldViewHelper(lgView));
    }
}
Also used : ChunkCoordinates(net.minecraft.util.ChunkCoordinates) IWorldView(com.xcompwiz.lookingglass.api.view.IWorldView) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with IWorldView

use of com.xcompwiz.lookingglass.api.view.IWorldView in project SecurityCraft by Geforce132.

the class ItemCameraMonitorRenderer method renderItem.

public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (type == ItemRenderType.FIRST_PERSON_MAP) {
        //Draw the base monitor texture.
        ((TextureManager) data[1]).bindTexture(new ResourceLocation("securitycraft:textures/gui/camera/cameraBackground.png"));
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, 0.0D, 1.0D);
        tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 1.0D, 1.0D);
        tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 1.0D, 0.0D);
        tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, 0.0D, 0.0D);
        tessellator.draw();
        if (item != null && item.getItem() instanceof ItemCameraMonitor && ((ItemCameraMonitor) item.getItem()).hasCameraAdded(item.getTagCompound())) {
            CameraView view = ((ItemCameraMonitor) item.getItem()).getCameraView(item.getTagCompound());
            if (mod_SecurityCraft.instance.hasViewForCoords(view.toNBTString())) {
                IWorldView worldView = mod_SecurityCraft.instance.getViewFromCoords(view.toNBTString()).getView();
                if (worldView.isReady() && worldView.getTexture() != 0) {
                    //Bind the IWorldView texture then draw it.
                    GL11.glDisable(3008);
                    GL11.glDisable(2896);
                    GL11.glBindTexture(GL11.GL_TEXTURE_2D, worldView.getTexture());
                    tessellator.startDrawingQuads();
                    tessellator.addVertexWithUV(128 + 7, 0 - 7, 0.0D, 0.0D, 1.0D);
                    tessellator.addVertexWithUV(0 - 7, 0 - 7, 0.0D, -1.0D, 1.0D);
                    tessellator.addVertexWithUV(0 - 7, 128 + 7, 0.0D, -1.0D, 0.0D);
                    tessellator.addVertexWithUV(128 + 7, 128 + 7, 0.0D, 0.0D, 0.0D);
                    tessellator.draw();
                    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
                    GL11.glEnable(3008);
                    GL11.glEnable(2896);
                //
                }
                //Update the camera.
                worldView.markDirty();
            }
        }
    }
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Tessellator(net.minecraft.client.renderer.Tessellator) ItemCameraMonitor(net.geforcemods.securitycraft.items.ItemCameraMonitor) ResourceLocation(net.minecraft.util.ResourceLocation) CameraView(net.geforcemods.securitycraft.misc.CameraView) IWorldView(com.xcompwiz.lookingglass.api.view.IWorldView)

Example 3 with IWorldView

use of com.xcompwiz.lookingglass.api.view.IWorldView in project SecurityCraft by Geforce132.

the class TileEntityFrameRenderer method renderTileEntityAt.

public void renderTileEntityAt(TileEntity par1TileEntity, double x, double y, double z, float par5) {
    int meta = par1TileEntity.hasWorldObj() ? par1TileEntity.getBlockMetadata() : par1TileEntity.blockMetadata;
    IWorldView lgView = null;
    float rotation = 0F;
    Tessellator tessellator = Tessellator.instance;
    if (par1TileEntity.hasWorldObj()) {
        float f = par1TileEntity.getWorldObj().getLightBrightness(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
        int l = par1TileEntity.getWorldObj().getLightBrightnessForSkyBlocks(par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord, 0);
        int l1 = l % 65536;
        int l2 = l / 65536;
        tessellator.setColorOpaque_F(f, f, f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
    }
    if (par1TileEntity.hasWorldObj() && lgView == null && ((TileEntityFrame) par1TileEntity).hasCameraLocation() && mod_SecurityCraft.instance.hasViewForCoords(((TileEntityFrame) par1TileEntity).getCameraView().toNBTString()) && ((TileEntityFrame) par1TileEntity).shouldShowView()) {
        lgView = mod_SecurityCraft.instance.getViewFromCoords(((TileEntityFrame) par1TileEntity).getCameraView().toNBTString()).getView();
    }
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    Minecraft.getMinecraft().renderEngine.bindTexture(frameTexture);
    GL11.glPushMatrix();
    if (par1TileEntity.hasWorldObj()) {
        if (meta == 2) {
            rotation = 0F;
        } else if (meta == 4) {
            rotation = 1F;
        } else if (meta == 3) {
            rotation = -10000F;
        } else if (meta == 5) {
            rotation = -1F;
        }
    } else {
        rotation = -1F;
    }
    GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
    this.frameModel.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    if (lgView != null) {
        if (lgView.getTexture() != 0) {
            GL11.glTranslatef(0.625F, 0.375F, -0.475F);
            GL11.glRotated(180D, 0D, 1D, 0D);
            GL11.glDisable(3008);
            GL11.glDisable(2896);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, lgView.getTexture());
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(0.25, 1, 0, 1, 0);
            tessellator.addVertexWithUV(0.25, 0.25, 0, 1, 1);
            tessellator.addVertexWithUV(1, 0.25, 0, 0, 1);
            tessellator.addVertexWithUV(1, 1, 0, 0, 0);
            tessellator.draw();
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
            GL11.glEnable(3008);
            GL11.glEnable(2896);
        }
        lgView.markDirty();
    }
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TileEntityFrame(net.geforcemods.securitycraft.tileentity.TileEntityFrame) IWorldView(com.xcompwiz.lookingglass.api.view.IWorldView)

Aggregations

IWorldView (com.xcompwiz.lookingglass.api.view.IWorldView)3 Tessellator (net.minecraft.client.renderer.Tessellator)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ItemCameraMonitor (net.geforcemods.securitycraft.items.ItemCameraMonitor)1 CameraView (net.geforcemods.securitycraft.misc.CameraView)1 TileEntityFrame (net.geforcemods.securitycraft.tileentity.TileEntityFrame)1 TextureManager (net.minecraft.client.renderer.texture.TextureManager)1 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)1 ResourceLocation (net.minecraft.util.ResourceLocation)1